libspu.pas 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. // Copyright (c) 1993, 1994, 1995, 1996 Sony Computer Entertainment Inc.
  2. // All Rights Reserved.
  3. //
  4. // This file is part of ``PlayStation(R)'' Programmer Tool /
  5. // Runtime Library.
  6. //
  7. // R & D Division, Sony Computer Entertainment Inc.
  8. //
  9. // $Id: libspu.h,v 1.80 1997/06/24 11:14:04 kaol Exp $
  10. //
  11. // $PSLibId: Run-time Library Release 4.6$
  12. {$MODE OBJFPC}
  13. unit libspu;
  14. interface
  15. const
  16. // CONSTANT
  17. SPU_SUCCESS = 0;
  18. SPU_INVALID_ARGS = -3;
  19. SPU_DIAG = -2;
  20. SPU_CHECK = -1;
  21. SPU_OFF = 0;
  22. SPU_ON = 1;
  23. SPU_CLEAR = 2;
  24. SPU_RESET = 3;
  25. SPU_DONT_CARE = 4;
  26. SPU_ALL = 0;
  27. SPU_CDONLY = 5;
  28. SPU_VOICEONLY = 6;
  29. SPU_CONT = 7;
  30. SPU_BIT = 8;
  31. SPU_NULL = 0;
  32. // Macros below will be obsoleted.
  33. SpuDiag = SPU_DIAG;
  34. SpuCheck = SPU_CHECK;
  35. SpuOff = SPU_OFF;
  36. SpuOn = SPU_ON;
  37. SpuClear = SPU_CLEAR;
  38. SpuReset = SPU_RESET;
  39. SpuDontCare = SPU_DONT_CARE;
  40. SpuALL = SPU_ALL;
  41. SpuCDOnly = SPU_CDONLY;
  42. SpuVoiceOnly = SPU_VOICEONLY;
  43. SpuCont = SPU_CONT;
  44. SpuNull = SPU_NULL;
  45. SPU_OFF_ENV_ON = 2;
  46. SPU_ON_ENV_OFF = 3;
  47. // Macros below will be obsoleted.
  48. SpuOffEnvOn = SPU_OFF_ENV_ON;
  49. SpuOnEnvOff = SPU_ON_ENV_OFF;
  50. SPU_ERROR = -1;
  51. // Macros below will be obsoleted.
  52. SpuError = SPU_ERROR;
  53. SPU_TRANSFER_BY_DMA = 0;
  54. SPU_TRANSFER_BY_IO = 1;
  55. // Macros below will be obsoleted.
  56. SpuTransferByDMA = SPU_TRANSFER_BY_DMA;
  57. SpuTransferByIO = SPU_TRANSFER_BY_IO;
  58. SpuTransByDMA = SpuTransferByDMA;
  59. SpuTransByIO = SpuTransferByIO;
  60. SPU_TRANSFER_WAIT = 1;
  61. SPU_TRANSFER_PEEK = 0;
  62. SPU_TRANSFER_GLANCE = SPU_TRANSFER_PEEK;
  63. // Voice designate
  64. SPU_00CH = 1 shl 0;
  65. SPU_01CH = 1 shl 1;
  66. SPU_02CH = 1 shl 2;
  67. SPU_03CH = 1 shl 3;
  68. SPU_04CH = 1 shl 4;
  69. SPU_05CH = 1 shl 5;
  70. SPU_06CH = 1 shl 6;
  71. SPU_07CH = 1 shl 7;
  72. SPU_08CH = 1 shl 8;
  73. SPU_09CH = 1 shl 9;
  74. SPU_10CH = 1 shl 10;
  75. SPU_11CH = 1 shl 11;
  76. SPU_12CH = 1 shl 12;
  77. SPU_13CH = 1 shl 13;
  78. SPU_14CH = 1 shl 14;
  79. SPU_15CH = 1 shl 15;
  80. SPU_16CH = 1 shl 16;
  81. SPU_17CH = 1 shl 17;
  82. SPU_18CH = 1 shl 18;
  83. SPU_19CH = 1 shl 19;
  84. SPU_20CH = 1 shl 20;
  85. SPU_21CH = 1 shl 21;
  86. SPU_22CH = 1 shl 22;
  87. SPU_23CH = 1 shl 23;
  88. SPU_0CH = SPU_00CH;
  89. SPU_1CH = SPU_01CH;
  90. SPU_2CH = SPU_02CH;
  91. SPU_3CH = SPU_03CH;
  92. SPU_4CH = SPU_04CH;
  93. SPU_5CH = SPU_05CH;
  94. SPU_6CH = SPU_06CH;
  95. SPU_7CH = SPU_07CH;
  96. SPU_8CH = SPU_08CH;
  97. SPU_9CH = SPU_09CH;
  98. SPU_ALLCH = SPU_00CH or SPU_01CH or SPU_02CH or SPU_03CH or SPU_04CH or SPU_05CH or SPU_06CH or SPU_07CH or SPU_08CH or SPU_09CH or SPU_10CH or SPU_11CH or SPU_12CH or SPU_13CH or SPU_14CH or SPU_15CH or SPU_16CH or SPU_17CH or SPU_18CH or SPU_19CH or SPU_20CH or SPU_21CH or SPU_22CH or SPU_23CH;
  99. function SPU_KEYCH(x: longint): longint;
  100. function SPU_VOICECH(x: longint): longint;
  101. // for Voice setting
  102. const
  103. SPU_VOICE_VOLL = 1 shl 0; // volume (left)
  104. SPU_VOICE_VOLR = 1 shl 1; // volume (right)
  105. SPU_VOICE_VOLMODEL = 1 shl 2; // volume mode (left)
  106. SPU_VOICE_VOLMODER = 1 shl 3; // volume mode (right)
  107. SPU_VOICE_PITCH = 1 shl 4; // tone (pitch setting)
  108. SPU_VOICE_NOTE = 1 shl 5; // tone (note setting)
  109. SPU_VOICE_SAMPLE_NOTE= 1 shl 6; // waveform data sample note
  110. SPU_VOICE_WDSA = 1 shl 7; // waveform data start address
  111. SPU_VOICE_ADSR_AMODE = 1 shl 8; // ADSR Attack rate mode
  112. SPU_VOICE_ADSR_SMODE = 1 shl 9; // ADSR Sustain rate mode
  113. SPU_VOICE_ADSR_RMODE = 1 shl 10; // ADSR Release rate mode
  114. SPU_VOICE_ADSR_AR = 1 shl 11; // ADSR Attack rate
  115. SPU_VOICE_ADSR_DR = 1 shl 12; // ADSR Decay rate
  116. SPU_VOICE_ADSR_SR = 1 shl 13; // ADSR Sustain rate
  117. SPU_VOICE_ADSR_RR = 1 shl 14; // ADSR Release rate
  118. SPU_VOICE_ADSR_SL = 1 shl 15; // ADSR Sustain level
  119. SPU_VOICE_LSAX = 1 shl 16; // start address for loop
  120. SPU_VOICE_ADSR_ADSR1 = 1 shl 17; // ADSR adsr1 for `VagAtr'
  121. SPU_VOICE_ADSR_ADSR2 = 1 shl 18; // ADSR adsr2 for `VagAtr'
  122. SPU_VOICE_DIRECT = 0;
  123. SPU_VOICE_LINEARIncN = 1;
  124. SPU_VOICE_LINEARIncR = 2;
  125. SPU_VOICE_LINEARDecN = 3;
  126. SPU_VOICE_LINEARDecR = 4;
  127. SPU_VOICE_EXPIncN = 5;
  128. SPU_VOICE_EXPIncR = 6;
  129. SPU_VOICE_EXPDec = 7;
  130. SPU_VOICE_EXPDecN = SPU_VOICE_EXPDec;
  131. SPU_VOICE_EXPDecR = SPU_VOICE_EXPDec;
  132. SPU_DECODED_FIRSTHALF= 0;
  133. SPU_DECODED_SECONDHALF= 1;
  134. SPU_DECODE_FIRSTHALF = SPU_DECODED_FIRSTHALF;
  135. SPU_DECODE_SECONDHALF= SPU_DECODED_SECONDHALF;
  136. SPU_COMMON_MVOLL = 1 shl 0; // master volume (left)
  137. SPU_COMMON_MVOLR = 1 shl 1; // master volume (right)
  138. SPU_COMMON_MVOLMODEL = 1 shl 2; // master volume mode (left)
  139. SPU_COMMON_MVOLMODER = 1 shl 3; // master volume mode (right)
  140. SPU_COMMON_RVOLL = 1 shl 4; // reverb volume (left)
  141. SPU_COMMON_RVOLR = 1 shl 5; // reverb volume (right)
  142. SPU_COMMON_CDVOLL = 1 shl 6; // CD input volume (left)
  143. SPU_COMMON_CDVOLR = 1 shl 7; // CD input volume (right)
  144. SPU_COMMON_CDREV = 1 shl 8; // CD input reverb on/off
  145. SPU_COMMON_CDMIX = 1 shl 9; // CD input on/off
  146. SPU_COMMON_EXTVOLL = 1 shl 10; // external digital input volume (left)
  147. SPU_COMMON_EXTVOLR = 1 shl 11; // external digital input volume (right)
  148. SPU_COMMON_EXTREV = 1 shl 12; // external digital input reverb on/off
  149. SPU_COMMON_EXTMIX = 1 shl 13; // external digital input on/off
  150. // for Reverb setting
  151. SPU_REV_MODE = 1 shl 0; // mode setting
  152. SPU_REV_DEPTHL = 1 shl 1; // reverb depth (left)
  153. SPU_REV_DEPTHR = 1 shl 2; // reverb depth (right)
  154. SPU_REV_DELAYTIME = 1 shl 3; // Delay Time (ECHO, DELAY only)
  155. SPU_REV_FEEDBACK = 1 shl 4; // Feedback (ECHO only)
  156. SPU_REV_MODE_CHECK = -1;
  157. SPU_REV_MODE_OFF = 0;
  158. SPU_REV_MODE_ROOM = 1;
  159. SPU_REV_MODE_STUDIO_A= 2;
  160. SPU_REV_MODE_STUDIO_B= 3;
  161. SPU_REV_MODE_STUDIO_C= 4;
  162. SPU_REV_MODE_HALL = 5;
  163. SPU_REV_MODE_SPACE = 6;
  164. SPU_REV_MODE_ECHO = 7;
  165. SPU_REV_MODE_DELAY = 8;
  166. SPU_REV_MODE_PIPE = 9;
  167. SPU_REV_MODE_MAX = 10;
  168. SPU_REV_MODE_CLEAR_WA= $100;
  169. // Event flushing
  170. SPU_EVENT_KEY = 1 shl 0;
  171. SPU_EVENT_PITCHLFO = 1 shl 1;
  172. SPU_EVENT_NOISE = 1 shl 2;
  173. SPU_EVENT_REVERB = 1 shl 3;
  174. SPU_EVENT_ALL = 0;
  175. type
  176. SpuVolume = packed record
  177. left : smallint;
  178. right : smallint;
  179. end;
  180. SpuVoiceAttr = packed record
  181. voice : dword; // set voice:
  182. // SpuSetVoiceAttr: each voice is a bit array
  183. // SpuGetVoiceAttr: voice is a bit value
  184. mask : dword; // settings attribute bit (invalid with Get)
  185. volume : SpuVolume; // volume
  186. volmode : SpuVolume; // volume mode
  187. volumex : SpuVolume; // current volume (invalid with Set)
  188. pitch : word; // tone (pitch setting)
  189. note : word; // tone (note setting)
  190. sample_note : word; // tone (note setting)
  191. envx : smallint; // current envelope value (invalid with Set)
  192. addr : dword; // waveform data start address
  193. loop_addr : dword; // loop start address
  194. a_mode : longint; // Attack rate mode
  195. s_mode : longint; // Sustain rate mode
  196. r_mode : longint; // Release rate mode
  197. ar : word; // Attack rate
  198. dr : word; // Decay rate
  199. sr : word; // Sustain rate
  200. rr : word; // Release rate
  201. sl : word; // Sustain level
  202. adsr1 : word; // adsr1 for `VagAtr'
  203. adsr2 : word; // adsr2 for `VagAtr'
  204. end;
  205. PSpuVoiceAttr = ^SpuVoiceAttr;
  206. SpuLVoiceAttr = packed record
  207. voiceNum : smallint; // voice number
  208. pad : smallint; // padding
  209. attr : SpuVoiceAttr; // voice attribute
  210. end;
  211. PSpuLVoiceAttr = ^SpuLVoiceAttr;
  212. SpuReverbAttr = packed record
  213. mask : dword; // settings mask
  214. mode : longint; // reverb mode
  215. depth : SpuVolume; // reverb depth
  216. delay : longint; // Delay Time (ECHO, DELAY only)
  217. feedback : longint; // Feedback (ECHO only)
  218. end;
  219. PSpuReverbAttr = ^SpuReverbAttr;
  220. const
  221. SPU_DECODEDDATA_SIZE = $200;
  222. SPU_DECODEDATA_SIZE = SPU_DECODEDDATA_SIZE;
  223. type
  224. SpuDecodedData = packed record
  225. cd_left : array [0..SPU_DECODEDDATA_SIZE - 1] of smallint;
  226. cd_right : array [0..SPU_DECODEDDATA_SIZE - 1] of smallint;
  227. voice1 : array [0..SPU_DECODEDDATA_SIZE - 1] of smallint;
  228. voice3 : array [0..SPU_DECODEDDATA_SIZE - 1] of smallint;
  229. end;
  230. SpuDecodeData = SpuDecodedData;
  231. PSpuDecodedData = ^SpuDecodedData;
  232. SpuExtAttr = packed record
  233. volume : SpuVolume; // volume
  234. reverb : longint; // reverb on/off
  235. mix : longint; // mixing on/off
  236. end;
  237. SpuCommonAttr = packed record
  238. mask : dword; // settings mask
  239. mvol : SpuVolume; // master volume
  240. mvolmode : SpuVolume; // master volume mode
  241. mvolx : SpuVolume; // current master volume
  242. cd : SpuExtAttr; // CD input attributes
  243. ext : SpuExtAttr; // external digital input attributes
  244. end;
  245. PSpuCommonAttr = ^SpuCommonAttr;
  246. SpuIRQCallbackProc = procedure;
  247. SpuTransferCallbackProc = procedure;
  248. // for SPU Malloc (used in SpuInitMalloc())
  249. const
  250. SPU_MALLOC_RECSIZ = 8;
  251. // User specifiable global environment
  252. type
  253. SpuEnv = packed record
  254. mask : dword;
  255. queueing : dword;
  256. end;
  257. PSpuEnv = ^SpuEnv;
  258. const
  259. SPU_ENV_EVENT_QUEUEING = 01 shl 0;
  260. procedure SpuInit; stdcall; external;
  261. procedure SpuInitHot; stdcall; external;
  262. procedure SpuStart; stdcall; external;
  263. procedure SpuQuit; stdcall; external;
  264. function SpuSetMute(on_off: longint): longint; stdcall; external;
  265. function SpuGetMute: longint; stdcall; external;
  266. procedure SpuSetEnv(env: PSpuEnv); stdcall; external;
  267. function SpuSetNoiseClock(n_clock: longint): longint; stdcall; external;
  268. function SpuGetNoiseClock: longint; stdcall; external;
  269. function SpuSetNoiseVoice(on_off: longint; voice_bit: dword): dword; stdcall; external;
  270. function SpuGetNoiseVoice: dword; stdcall; external;
  271. function SpuSetReverb(on_off: longint): longint; stdcall; external;
  272. function SpuGetReverb: longint; stdcall; external;
  273. function SpuSetReverbModeParam(attr: PSpuReverbAttr): longint; stdcall; external;
  274. procedure SpuGetReverbModeParam(attr: PSpuReverbAttr); stdcall; external;
  275. function SpuSetReverbDepth(attr: PSpuReverbAttr): longint; stdcall; external;
  276. function SpuReserveReverbWorkArea(on_off: longint): longint; stdcall; external;
  277. function SpuIsReverbWorkAreaReserved(on_off: longint): longint; stdcall; external;
  278. function SpuSetReverbVoice(on_off: longint; voice_bit: dword): dword; stdcall; external;
  279. function SpuGetReverbVoice: dword; stdcall; external;
  280. function SpuClearReverbWorkArea(mode: longint): longint; stdcall; external;
  281. function SpuWrite(addr: pointer; size: dword): dword; stdcall; external;
  282. function SpuWrite0(size: dword): dword; stdcall; external;
  283. function SpuRead(addr: pointer; size: dword): dword; stdcall; external;
  284. function SpuSetTransferMode(mode: longint): longint; stdcall; external;
  285. function SpuSetTransMode(mode: longint):longint; // NO EXTERNAL
  286. function SpuGetTransferMode: longint; stdcall; external;
  287. function SpuGetTransMode: longint; // NO EXTERNAL
  288. function SpuSetTransferStartAddr(addr: dword): dword; stdcall; external;
  289. function SpuSetTransStartAddr(addr: dword): dword; // NO EXTERNAL
  290. function SpuGetTransferStartAddr: dword; stdcall; external;
  291. function SpuGetTransStartAddr: dword; // NO EXTERNAL
  292. function SpuWritePartly(addr: pointer; size: dword): dword; stdcall; external;
  293. function SpuIsTransferCompleted(flag: longint): longint; stdcall; external;
  294. function SpuSetTransferCallback(func: SpuTransferCallbackProc): SpuTransferCallbackProc; stdcall; external;
  295. function SpuReadDecodedData(d_data: PSpuDecodedData; flag: longint): longint; stdcall; external;
  296. function SpuReadDecodeData(d_data: PSpuDecodedData; flag: longint): longint; // NO EXTERNAL
  297. function SpuSetIRQ(on_off: longint): longint; stdcall; external;
  298. function SpuGetIRQ: longint; stdcall; external;
  299. function SpuSetIRQAddr(addr: dword): dword; stdcall; external;
  300. function SpuGetIRQAddr: dword; stdcall; external;
  301. function SpuSetIRQCallback(func: SpuIRQCallbackProc): SpuIRQCallbackProc; stdcall; external;
  302. procedure SpuSetVoiceAttr(arg: PSpuVoiceAttr); stdcall; external;
  303. procedure SpuGetVoiceAttr(arg: PSpuVoiceAttr); stdcall; external;
  304. procedure SpuSetKey(on_off: longint; voice_bit: dword); stdcall; external;
  305. procedure SpuSetKeyOnWithAttr(attr: PSpuVoiceAttr); stdcall; external;
  306. function SpuGetKeyStatus(voice_bit: dword): longint; stdcall; external;
  307. procedure SpuGetAllKeysStatus(status: pointer); stdcall; external;
  308. function SpuFlush(ev: dword): dword; stdcall; external;
  309. function SpuSetPitchLFOVoice(on_off: longint; voice_bit: dword): dword; stdcall; external;
  310. function SpuGetPitchLFOVoice: dword; stdcall; external;
  311. procedure SpuSetCommonAttr(attr: PSpuCommonAttr); stdcall; external;
  312. procedure SpuGetCommonAttr(attr: PSpuCommonAttr); stdcall; external;
  313. function SpuInitMalloc(num: longint; top: pointer): longint; stdcall; external;
  314. function SpuMalloc(size: longint): longint; stdcall; external;
  315. function SpuMallocWithStartAddr(addr: dword; size: longint): longint; stdcall; external;
  316. procedure SpuFree(addr: dword); stdcall; external;
  317. function SpuRGetAllKeysStatus(min_, max_: longint; status: pointer): longint; stdcall; external;
  318. function SpuRSetVoiceAttr(min_, max_: longint; arg: PSpuVoiceAttr): longint; stdcall; external;
  319. procedure SpuNSetVoiceAttr(vNum: longint; arg: PSpuVoiceAttr); stdcall; external;
  320. procedure SpuNGetVoiceAttr(vNum: longint; arg: PSpuVoiceAttr); stdcall; external;
  321. procedure SpuLSetVoiceAttr(num: longint; argList: PSpuLVoiceAttr); stdcall; external;
  322. procedure SpuSetVoiceVolume(vNum: longint; volL, volR: smallint); stdcall; external;
  323. procedure SpuSetVoiceVolumeAttr(vNum: longint; volL, volR: smallint; volModeL, volModeR: smallint); stdcall; external;
  324. procedure SpuSetVoicePitch(vNum: longint; pitch: word); stdcall; external;
  325. procedure SpuSetVoiceNote(vNum: longint; note: word); stdcall; external;
  326. procedure SpuSetVoiceSampleNote(vNum: longint; sampleNote: word); stdcall; external;
  327. procedure SpuSetVoiceStartAddr(vNum: longint; startAddr: dword); stdcall; external;
  328. procedure SpuSetVoiceLoopStartAddr(vNum: longint; lsa: dword); stdcall; external;
  329. procedure SpuSetVoiceAR(vNum: longint; AR: word); stdcall; external;
  330. procedure SpuSetVoiceDR(vNum: longint; DR: word); stdcall; external;
  331. procedure SpuSetVoiceSR(vNum: longint; SR: word); stdcall; external;
  332. procedure SpuSetVoiceRR(vNum: longint; RR: word); stdcall; external;
  333. procedure SpuSetVoiceSL(vNum: longint; SL: word); stdcall; external;
  334. procedure SpuSetVoiceARAttr(vNum: longint; AR: word; ARmode: longint); stdcall; external;
  335. procedure SpuSetVoiceSRAttr(vNum: longint; SR: word; SRmode: longint); stdcall; external;
  336. procedure SpuSetVoiceRRAttr(vNum: longint; RR: word; RRmode: longint); stdcall; external;
  337. procedure SpuSetVoiceADSR(vNum: longint; AR, DR, SR, RR, SL: word); stdcall; external;
  338. procedure SpuSetVoiceADSRAttr(vNum: longint; AR, DR, SR, RR, SL: word; ARmode, SRmode, RRmode: longint); stdcall; external;
  339. procedure SpuGetVoiceVolume(vNum: longint; volL, volR: psmallint); stdcall; external;
  340. procedure SpuGetVoiceVolumeAttr(vNum: longint; volL, volR, volModeL, volModeR: psmallint); stdcall; external;
  341. procedure SpuGetVoiceVolumeX(vNum: longint; volXL, volXR: psmallint); stdcall; external;
  342. procedure SpuGetVoicePitch(vNum: longint; pitch: pword); stdcall; external;
  343. procedure SpuGetVoiceNote(vNum: longint; note:pword); stdcall; external;
  344. procedure SpuGetVoiceSampleNote(vNum: longint; sampleNote: pword); stdcall; external;
  345. procedure SpuGetVoiceEnvelope(vNum: longint; envx: psmallint); stdcall; external;
  346. procedure SpuGetVoiceStartAddr(vNum: longint; startAddr: pword); stdcall; external;
  347. procedure SpuGetVoiceLoopStartAddr(vNum: longint; loopStartAddr: pword); stdcall; external;
  348. procedure SpuGetVoiceAR(vNum: longint; AR: pword); stdcall; external;
  349. procedure SpuGetVoiceDR(vNum: longint; DR: pword); stdcall; external;
  350. procedure SpuGetVoiceSR(vNum: longint; SR: pword); stdcall; external;
  351. procedure SpuGetVoiceRR(vNum: longint; RR: pword); stdcall; external;
  352. procedure SpuGetVoiceSL(vNum: longint; SL: pword); stdcall; external;
  353. procedure SpuGetVoiceARAttr(vNum: longint; AR: pword; ARmode: plongint); stdcall; external;
  354. procedure SpuGetVoiceSRAttr(vNum: longint; SR: pword; SRmode: plongint); stdcall; external;
  355. procedure SpuGetVoiceRRAttr(vNum: longint; RR: pword; RRmode: plongint); stdcall; external;
  356. procedure SpuGetVoiceADSR(vNum: longint; AR, DR, SR, RR, SL: pword); stdcall; external;
  357. procedure SpuGetVoiceADSRAttr(vNum: longint; AR, DR, SR, RR, SL: pword; ARmode, SRmode, RRmode: plongint); stdcall; external;
  358. procedure SpuGetVoiceEnvelopeAttr(vNum: longint; keyStat: plongint; envx: psmallint); stdcall; external;
  359. procedure SpuSetCommonMasterVolume(mvol_left, mvol_right: smallint); stdcall; external;
  360. procedure SpuSetCommonMasterVolumeAttr(mvol_left, mvol_right, mvolmode_left, mvolmode_right: smallint); stdcall; external;
  361. procedure SpuSetCommonCDMix(cd_mix: longint); stdcall; external;
  362. procedure SpuSetCommonCDVolume(cd_left, cd_right: smallint); stdcall; external;
  363. procedure SpuSetCommonCDReverb(cd_reverb: longint); stdcall; external;
  364. procedure SpuGetCommonMasterVolume(mvol_left, mvol_right: psmallint); stdcall; external;
  365. procedure SpuGetCommonMasterVolumeX(mvolx_left, mvolx_right: psmallint); stdcall; external;
  366. procedure SpuGetCommonMasterVolumeAttr(mvol_left, mvol_right, mvolmode_left, mvolmode_right: psmallint); stdcall; external;
  367. procedure SpuGetCommonCDMix(cd_mix: plongint); stdcall; external;
  368. procedure SpuGetCommonCDVolume(cd_left, cd_right: psmallint); stdcall; external;
  369. procedure SpuGetCommonCDReverb(cd_reverb: plongint); stdcall; external;
  370. function SpuSetReverbModeType(mode: longint): longint; stdcall; external;
  371. procedure SpuSetReverbModeDepth(depth_left, depth_right: smallint); stdcall; external;
  372. procedure SpuSetReverbModeDelayTime(del: longint); stdcall; external;
  373. procedure SpuSetReverbModeFeedback(feedback: longint); stdcall; external;
  374. procedure SpuGetReverbModeType(mode: plongint); stdcall; external;
  375. procedure SpuGetReverbModeDepth(depth_left, depth_right: psmallint); stdcall; external;
  376. procedure SpuGetReverbModeDelayTime(del: plongint); stdcall; external;
  377. procedure SpuGetReverbModeFeedback(feedback: plongint); stdcall; external;
  378. procedure SpuSetESA(revAddr: longint); stdcall; external;
  379. const
  380. SPU_ST_NOT_AVAILABLE = 0;
  381. SPU_ST_ACCEPT = 1;
  382. SPU_ST_ERROR = -1;
  383. SPU_ST_INVALID_ARGUMENT = -2;
  384. SPU_ST_WRONG_STATUS = -3;
  385. SPU_ST_STOP = 2;
  386. SPU_ST_IDLE = 3;
  387. SPU_ST_PREPARE = 4;
  388. SPU_ST_START = 5;
  389. SPU_ST_PLAY = 6;
  390. SPU_ST_TRANSFER = 7;
  391. SPU_ST_FINAL = 8;
  392. // VAG's header size
  393. const
  394. SPU_ST_VAG_HEADER_SIZE = $30;
  395. type
  396. SpuStVoiceAttr = packed record
  397. status : byte; // stream status
  398. pad1 : byte; // padding
  399. pad2 : byte; // padding
  400. pad3 : byte; // padding
  401. last_size : longint; // the size of last transferring (last_size <= (size / 2))
  402. buf_addr : dword; // The start address of stream buffer
  403. data_addr : dword; // The start address of SPU streaming data in main memory
  404. end;
  405. SpuStEnv = packed record
  406. size : longint; // The size of stream buffer
  407. low_priority : longint; // transfer priority
  408. voice : array [0..23] of SpuStVoiceAttr;
  409. end;
  410. PSpuStEnv = ^SpuStEnv;
  411. type
  412. SpuStCallbackProc = function(d: dword; l: longint): pointer;
  413. function SpuStInit(x: longint): PSpuStEnv; stdcall; external;
  414. function SpuStQuit: longint; stdcall; external;
  415. function SpuStGetStatus: longint; stdcall; external;
  416. function SpuStGetVoiceStatus: dword; stdcall; external;
  417. function SpuStTransfer(flag: longint; voice_bit: dword): longint; stdcall; external;
  418. function SpuStSetPreparationFinishedCallback(func: SpuStCallbackProc): SpuStCallbackProc; stdcall; external;
  419. function SpuStSetTransferFinishedCallback(func: SpuStCallbackProc): SpuStCallbackProc; stdcall; external;
  420. function SpuStSetStreamFinishedCallback(func: SpuStCallbackProc): SpuStCallbackProc; stdcall; external;
  421. implementation
  422. function SPU_KEYCH(x: longint): longint;
  423. begin
  424. result:= 1 shl x;
  425. end;
  426. function SPU_VOICECH(x: longint): longint;
  427. begin
  428. result:= SPU_KEYCH(x);
  429. end;
  430. function SpuSetTransMode(mode: longint): longint;
  431. begin
  432. result:= SpuSetTransferMode(mode);
  433. end;
  434. function SpuGetTransMode: longint;
  435. begin
  436. result:= SpuGetTransferMode;
  437. end;
  438. function SpuSetTransStartAddr(addr: dword): dword;
  439. begin
  440. result:= SpuSetTransferStartAddr(addr);
  441. end;
  442. function SpuGetTransStartAddr: dword;
  443. begin
  444. result:= SpuGetTransferStartAddr;
  445. end;
  446. function SpuReadDecodeData(d_data: PSpuDecodedData; flag: longint): longint;
  447. begin
  448. result:= SpuReadDecodedData(d_data, flag);
  449. end;
  450. begin
  451. end.