soundcmn.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. #ifndef ___SOUNDCMN_H
  2. #define ___SOUNDCMN_H
  3. #include "fqcodec.h"
  4. #include "fqeffect.h"
  5. #include "types.h"
  6. #include "soundlow.h"
  7. #include "file.h"
  8. #define NUM_FADE_BLOCKS 20
  9. #define DELAY_BUF_SIZE (18 * FQ_SIZE) // approx 200 msec delay buffer
  10. #define SND_BLOCK_TIME ((float)FQ_SLICE / 1000.0F) // approx 11.6 msec (in secs)
  11. #define VCE_BACKWARDS_COMPATIBLE 1 //backwards compatible with older version with the "DATA" before the "INFO"
  12. /* structures */
  13. typedef struct
  14. {
  15. udword id;
  16. udword priority;
  17. sdword pitch;
  18. sdword dataoffset;
  19. sdword datasize;
  20. sdword loopstart;
  21. sdword loopend;
  22. sword bitrate;
  23. sword flags;
  24. ubyte volume;
  25. sbyte pan;
  26. sbyte pad[2];
  27. WAVEFORMATEX waveformat;
  28. sword wavepad;
  29. } PATCH;
  30. typedef struct
  31. {
  32. udword id;
  33. udword checksum;
  34. sdword numpatches;
  35. sdword firstpatch;
  36. } BANK;
  37. typedef struct
  38. {
  39. sdword priority;
  40. sdword status;
  41. sdword handle;
  42. bool mute;
  43. PATCH *ppatch;
  44. real32 volume;
  45. real32 volfade;
  46. sword voltarget;
  47. sword volticksleft;
  48. sword pan;
  49. sword pantarget;
  50. sword panfade;
  51. sword panticksleft;
  52. real32 pitch;
  53. real32 pitchtarget;
  54. real32 pitchfade;
  55. sdword pitchticksleft;
  56. sword heading;
  57. sword bitrate;
  58. sdword fqsize;
  59. sdword looping;
  60. sdword numchannels; //new
  61. sbyte *freqdata;
  62. sbyte *currentpos;
  63. sbyte *endpos;
  64. sdword amountread;
  65. real32 shift;
  66. real32 volfactorL;
  67. real32 volfactorR;
  68. ubyte exponentblockL[FQ_SIZE];
  69. ubyte exponentblockR[FQ_SIZE];
  70. real32 mixbuffer1[FQ_SIZE];
  71. real32 mixbuffer2[FQ_SIZE];
  72. real32 mixbuffer1R[FQ_SIZE];
  73. real32 mixbuffer2R[FQ_SIZE];
  74. real32 filter[SOUND_EQ_SIZE];
  75. real32 cardiodfilter[SOUND_EQ_SIZE];
  76. bool usecardiod;
  77. } CHANNEL; /* 80 bytes + mixbuffers */
  78. typedef struct
  79. {
  80. filehandle fhandle; /* this is the stream file handle */
  81. sdword offset; /* this is the offset within that file */
  82. sdword flags; /* looping? */
  83. sdword size;
  84. sword vol;
  85. sword pan;
  86. sword numchannels;
  87. sword bitrate;
  88. real32 fadetime;
  89. real32 volfactorL;
  90. real32 volfactorR;
  91. real32 silencetime;
  92. sbyte *nextplay;
  93. PATCH *pmixPatch;
  94. sdword mixHandle;
  95. sword mixLevel;
  96. sword pad;
  97. STREAMDELAY *delay;
  98. STREAMEQ *eq;
  99. EFFECT *effect;
  100. sdword actornum; //needed for subtitles
  101. sdword speechEvent;//ditto
  102. } STREAMQUEUE;
  103. typedef struct
  104. {
  105. sdword ID; /* this is the ID to check that this is a valid stream */
  106. sdword size; /* this is the size of this stream */
  107. } STREAMHEADER;
  108. typedef struct
  109. {
  110. STREAMHEADER header;
  111. BYTE *buffer; /* this is a pointer to the buffer to read data from the stream file */
  112. sdword buffersize; /* this is the size of the stream buffer / SOUND_STREAM_NUM_BUFFERS */
  113. sdword blocksize; /* this is the size of the stream buffer / SOUND_STREAM_NUM_BUFFERS */
  114. BYTE *writepos;
  115. BYTE *bufferend;
  116. sdword blockstatus[2];
  117. // sdword bufferstatus[SOUND_STREAM_NUM_BUFFERS];
  118. // sdword readbuffer; /* this is which buffer is being read to the DirectSound buffer */
  119. // sdword writebuffer;/* this is which buffer is being written into from the CD */
  120. sdword readblock; /* this is which buffer is being read to the DirectSound buffer */
  121. sdword writeblock; /* this is which buffer is being written into from the CD */
  122. sdword dataleft; /* amount of data left to read in this stream */
  123. sdword lastpos;
  124. // sdword writepos; /* location in the DirectSound buffer to write at */
  125. sdword status;
  126. sdword filepos;
  127. sdword playing;
  128. sdword handle; /* this is the sound handle that this stream is being played on */
  129. sdword queueindex; /* this is which queue to play next */
  130. sdword writeindex; /* this is which queue to play next */
  131. sdword numqueued;
  132. sdword numtoplay;
  133. sdword playindex;
  134. STREAMQUEUE queue[SOUND_MAX_STREAM_QUEUE];
  135. sdword delaypos1;
  136. sdword delaypos2;
  137. real32 delaybuffer1[DELAY_BUF_SIZE];
  138. real32 delaybuffer2[DELAY_BUF_SIZE];
  139. real32 dataPeriod; //inverse of data rate, seconds per byte
  140. } STREAM;
  141. typedef struct
  142. {
  143. HANDLE filehandle; /* this is the O/S handle to the file */
  144. sdword handle; /* this handle is used for indexing into the streamfiles array */
  145. } STREAMFILE;
  146. typedef struct
  147. {
  148. sdword status;
  149. udword timeout;
  150. } SOUNDCOMPONENT;
  151. /* functions */
  152. sdword isoundmixerinit(WAVEFORMATEX *pcmwf);
  153. void isoundmixerrestore(void);
  154. void isoundstreamupdate(void *dummy);
  155. sdword SNDreleasebuffer(CHANNEL *pchan);
  156. sdword SNDchannel(sdword handle);
  157. void SNDcalcvolpan(CHANNEL *pchan);
  158. sdword SNDcreatehandle(sdword channel);
  159. PATCH *SNDgetpatch(void *bankaddress, sdword patnum);
  160. sdword smixCreateDSoundBuffer(WAVEFORMATEX *pcmwf);
  161. sdword smixInitMixBuffer(WAVEFORMATEX *pcmwf);
  162. sdword streamStartThread(void);
  163. #endif