AUDIO.H 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. /* Header File for Actua Soccer Audio */
  2. #if !defined(__AUDIO_H)
  3. #define __AUDIO_H
  4. //************************************************************************************************
  5. // General
  6. //************************************************************************************************
  7. extern short int CrowdVolume;
  8. extern short int PitchVolume;
  9. extern short int CommentaryVolume;
  10. extern short int MusicVolume;
  11. extern short int MasterVolume;
  12. typedef struct tagmadfile
  13. {
  14. char name[16];
  15. unsigned long int offset;
  16. unsigned long int length;
  17. }madfile;
  18. enum // Team names
  19. {
  20. HOME_TEAM,
  21. AWAY_TEAM
  22. };
  23. struct memstatus
  24. {
  25. unsigned long int ext; // Running total for Extended memory allocations
  26. unsigned long int base; // Running total for Base memory allocations
  27. unsigned long int fail; // Running total for Failed memory allocations
  28. };
  29. // Structure for storing a sample in memory
  30. typedef struct tagmemsam
  31. {
  32. char *name; // Name of the samples disk file
  33. unsigned char *mem; // Pointer to the sample when in memory
  34. long int size; // Length of the sample when in memory
  35. unsigned short int flags;
  36. }memsam;
  37. // Memory Sample Flags
  38. #define MSF_LOADING 0x01 // Sample is currently loading (ie dont play)
  39. #define MSF_DONTKEEP 0x02 // Sample should not be kept in memory after use (ie free it)
  40. #define MSF_PLAYED 0x04 // Sample has already been played.
  41. //************************************************************************************************
  42. // Front End
  43. //************************************************************************************************
  44. #define MAX_FRONTEND_SAMPLES 4
  45. enum
  46. {
  47. FS_CROWD, // Crowd sample
  48. FS_PITCH, // Pitch Sample
  49. FS_COMMENT, // Commetary
  50. FS_CHEAT // Cheat Sample
  51. };
  52. //************************************************************************************************
  53. // Pitch
  54. //************************************************************************************************
  55. #define MAX_PITCH_SAMPLES 20
  56. enum
  57. {
  58. MS_AMBI2, // Low Crowd Ambience
  59. MS_AMBI4, // Low Crowd Ambience (Alternative)
  60. MS_AMBI6, // Low Crowd Ambience (Alternative)
  61. MS_AMBI8, // Low Crowd Ambience (Alternative)
  62. MS_GOAL, // Crowd Cheers for a goal
  63. MS_MISS, // Crowd Just Missed (Ooooh)
  64. MS_SAVE, // Great Save (Claps)
  65. MS_LAUGH, // Fluff (Laughs)
  66. MS_FOWL,
  67. MS_RESTLESS, // Crowd Cheers for a goal
  68. MS_LNGREF, // Long referee whistle
  69. MS_SHRTREF, // Short referee whistle
  70. MS_HRDKICK, // Hard Kick
  71. MS_KICK1, // Kick
  72. MS_PASS1, // Kick
  73. MS_BOOT, // Kick
  74. MS_BOUNCE, // Bounce
  75. MS_FALL, // Sliding Tackle
  76. MS_FULL, // Full time whistle
  77. MS_HALF // Half time whistle
  78. // MS_C_FOWL,
  79. // MS_C_MISS,
  80. // MS_CHANT0, // Random Chant for Variety
  81. // MS_CHANT1, // Random Chant for Variety
  82. // MS_CHANT2, // Random Chant for Variety
  83. // MS_CHANT3, // Random Chant for Variety
  84. // MS_CHANT4, // Random Chant for Variety
  85. // MS_CHANT5 // Random Chant for Variety
  86. };
  87. // Sound effects for on the pitch, The frequency will be altered slightly for variety
  88. enum
  89. {
  90. PS_NULL, // Diddly Squat
  91. PS_LONGWHISTLE, // Various Whistles
  92. PS_SHORTWHISTLE,
  93. PS_HALFTIMEWHISTLE,
  94. PS_FULLTIMEWHISTLE,
  95. PS_SOFTKICK, // Various Ball Kicks
  96. PS_MEDKICK,
  97. PS_HARDKICK,
  98. PS_SOFTHEAD, // Various Headers
  99. PS_HARDHEAD,
  100. PS_SOFTCATCH, // Various Handling of the Ball
  101. PS_HARDCATCH,
  102. PS_PUNCH,
  103. PS_SOFTBOUNCE, // Various Ball Bounces
  104. PS_HARDBOUNCE,
  105. PS_SOFTWOOD, // Various Ball Rebounds off the Woodwork
  106. PS_HARDWOOD,
  107. // PS_SOFTFOUL, // Various Fouls
  108. // PS_MEDFOUL,
  109. // PS_HARDFOUL,
  110. PS_SLIDING, // Sliding Tackle
  111. PS_SOFTGOAL, // Various Balls Hitting the back of the net
  112. PS_HARDGOAL
  113. };
  114. typedef struct tagpitchsam
  115. {
  116. memsam *info;
  117. short int amp; // Amplitude of Sample (volume 0x0 - 0x7fff)
  118. long int freq; // Frequency Divider (typically 0x8000 - half)
  119. unsigned short int flags;
  120. }pitchsam;
  121. #define PSF_THREED 0x01 // Use Pan and Volume from the call (3D Sound)
  122. #define PSF_APPROX 0x02 // Play the sample at approximately the correct freqeuncy for Variety
  123. //************************************************************************************************
  124. // Crowd
  125. //************************************************************************************************
  126. enum
  127. {
  128. CS_NULL, // Diddly Squat
  129. CS_AMBIENCE1, // Various Ambience levels
  130. CS_AMBIENCE2,
  131. CS_AMBIENCE3,
  132. CS_AMBIENCE4,
  133. CS_GOAL, // Triggerd cheers
  134. CS_RESTLESS,
  135. CS_MISS,
  136. CS_SAVE,
  137. CS_LAUGH,
  138. CS_FOWL
  139. // CS_CHANT0, // Crowd Chants
  140. // CS_CHANT1, // Crowd Chants
  141. // CS_CHANT2, // Crowd Chants
  142. // CS_CHANT3, // Crowd Chants
  143. // CS_CHANT4, // Crowd Chants
  144. // CS_CHANT5 // Crowd Chants
  145. };
  146. // Crowd noise definitions... (mood)
  147. enum
  148. {
  149. CN_OFF,
  150. CN_NORMAL,
  151. CN_PENSIVE,
  152. CN_ENCOURAGING,
  153. CN_EXCITED,
  154. CN_CELEBRATE,
  155. CN_BOO,
  156. CN_SAVE,
  157. CN_MISS,
  158. CN_LAUGH,
  159. CN_FOWL
  160. };
  161. struct crowdsam
  162. {
  163. long int mood; // Current mood of Crowd
  164. long int tranmood; // Mood in for transition to
  165. long int mainhandle; // Main sample handle of crowd sample
  166. long int mainvol; // Volume of main crowd sample
  167. long int maindelta; // Volume difference of main crowd sample
  168. long int mergehandle; // Sample handle of Merging Crowd Sample
  169. long int mergevol; // Volume of Merging Crowd Sample
  170. long int mergedelta; // Volume Difference of Merging Sample
  171. long int volmax; // Maximum volume crowd can reach
  172. long int pan; // Pan Position of Crowd Sample
  173. long int pandelta; // Pan Difference of Crowd Sample
  174. long int ticks; // Number of Ticks since last random event
  175. long int nextevent; // Number of Ticks to next event
  176. short int flags; // Flags to control the above
  177. };
  178. // Events currently happening in the Crowd Update
  179. #define CF_PAN 0x01
  180. #define CF_TRAN 0x02
  181. //************************************************************************************************
  182. // Commentary
  183. //************************************************************************************************
  184. #define MAX_REPEAT_BUFFER 64 // Amount of samples that must be played before a repeat
  185. #define MAX_REPEAT_ATTEMPTS 4 // Amount of attempts to find a sample that does not repeat
  186. #define MAX_LINKS 4 // Maximum amount of samples that can be load into link buffer
  187. #define MAX_COMMENTARY_CATEGORIES 35
  188. // Maximum Samples for each commentary category
  189. enum // Team Intonation
  190. {
  191. TI_WELCOME,
  192. TI_AND_NAME,
  193. TI_NAME
  194. };
  195. enum // Player Intonation
  196. {
  197. PI_OWN_HALF,
  198. PI_OPPONENTS_HALF,
  199. PI_SHOOTING
  200. };
  201. enum
  202. {
  203. CM_NULL,
  204. SP_CORNER, // Set piece
  205. SP_GOALKICK,
  206. SP_THROWIN,
  207. SP_LONGTHROWIN,
  208. SP_PENALTY,
  209. FU_FREEKICK, // Foul
  210. FU_WALL,
  211. FU_BADFOUL,
  212. FU_YELLOWCARD,
  213. FU_REDCARD,
  214. FU_INJURY,
  215. FU_DIVE,
  216. CP_LONG, // Completed pass
  217. CP_SHORT,
  218. CP_TARGET,
  219. CP_HEAD,
  220. CP_NICEMOVE,
  221. CP_SETPIECE,
  222. FP_LONG, // Failed Pass
  223. FP_SHORT,
  224. FP_LOOSE,
  225. GL_GENERIC, // Goal
  226. GL_DEFLECT,
  227. GL_HARDKICK,
  228. GL_HEADER,
  229. GL_KEEPER,
  230. GL_POST,
  231. GL_CURVE,
  232. GL_CURVEWALL,
  233. PM_CATCH, // Player missed goal attempt
  234. PM_BLOCK,
  235. PM_WIDE,
  236. PM_CLOSE,
  237. PM_POST,
  238. PM_CROSSBAR,
  239. MC_PREMATCH,
  240. OT_GOODPLAY,
  241. OT_POORPLAY,
  242. SU_ONFOR,
  243. SU_TEAM,
  244. SU_INJURED,
  245. TI_HALFTIME,
  246. TI_FULLTIME,
  247. CM_LINKBANK
  248. };
  249. #define MAX_SP_CORNER 12
  250. #define MAX_SP_GOALKICK 8
  251. #define MAX_SP_THROWIN 5
  252. #define MAX_SP_LONGTHROWIN 6
  253. #define MAX_SP_PENALTY 24
  254. #define MAX_FU_FREEKICK 9
  255. #define MAX_FU_WALL 9
  256. #define MAX_FU_BADFOUL 15
  257. #define MAX_FU_YELLOWCARD 8
  258. #define MAX_FU_REDCARD 9
  259. #define MAX_FU_INJURY 8
  260. #define MAX_FU_DIVE 8
  261. #define MAX_CP_LONG 6
  262. #define MAX_CP_SHORT 4
  263. #define MAX_CP_TARGET 20
  264. #define MAX_CP_HEAD 2
  265. #define MAX_CP_NICEMOVE 7
  266. #define MAX_CP_SETPIECE 13
  267. #define MAX_FP_LONG 3
  268. #define MAX_FP_SHORT 2
  269. #define MAX_FP_LOOSE 8
  270. #define MAX_GL_GENERIC 36
  271. #define MAX_GL_DEFLECT 8
  272. #define MAX_GL_HARDKICK 8
  273. #define MAX_GL_HEADER 15
  274. #define MAX_GL_KEEPER 9
  275. #define MAX_GL_POST 8
  276. #define MAX_GL_CURVE 7
  277. #define MAX_GL_CURVEWALL 4
  278. #define MAX_PM_CATCH 21
  279. #define MAX_PM_BLOCK 14
  280. #define MAX_PM_WIDE 21
  281. #define MAX_PM_CLOSE 16
  282. #define MAX_PM_POST 8
  283. #define MAX_PM_CROSSBAR 11
  284. #define MAX_MC_PREMATCH 19
  285. #define MAX_OT_GOODPLAY 26
  286. #define MAX_OT_POORPLAY 13
  287. #define MAX_SU_ONFOR 4
  288. #define MAX_SU_TEAM 5
  289. #define MAX_SU_INJURED 4
  290. struct commcat
  291. {
  292. char name[4];
  293. short int count;
  294. };
  295. typedef struct tagintonsam
  296. {
  297. memsam x; // x,y,z are types of Intonation
  298. memsam y;
  299. memsam z;
  300. }intonsam;
  301. typedef struct tagteamsam
  302. {
  303. int team; // Number of team in game data
  304. intonsam country;
  305. intonsam manager;
  306. intonsam players[11];
  307. }teamsam;
  308. //************************************************************************************************
  309. // External Functions
  310. //************************************************************************************************
  311. extern unsigned long int InitMatchAudio(unsigned long int seed);
  312. extern void UpdateVolumeLevels(void);
  313. extern long int StartMusic(char *name,int volume);
  314. extern void StopMusic(void);
  315. extern long int UpdateMusic(void);
  316. extern int CheckMusic(void);
  317. extern unsigned long int LoadPitchSamples(void);
  318. extern void FreePitchSamples(void);
  319. extern long int PlayPitchSample(int sam,short int amp,short int pan);
  320. extern void StartCrowd(int team);
  321. extern void StopAudio(void);
  322. extern long int PlayCrowdSample(int sam);
  323. extern void UpdateCrowd(int mood,int team);
  324. extern unsigned long int LoadTeamSamples(int team_num,int team);
  325. extern void FreeTeamSamples(int team);
  326. extern unsigned long int LoadFrontEndSamples(void);
  327. extern void FreeFrontEndSamples(void);
  328. extern unsigned long int LoadCommentarySamples(void);
  329. extern void FreeCommentarySamples(void);
  330. extern void UpdateCommentary(void);
  331. extern void PauseCommentary(void);
  332. extern void ResumeCommentary(void);
  333. extern long int PlayTeamSample(int player,int intonation);
  334. extern void PlayWelcomeMessage(void);
  335. extern void PlaySubstitutionMessage(int team,int player_off,int player_on,int injured);
  336. extern void PlayScoreSample(int home,int away);
  337. extern void PlayCommentaryMessage(int type);
  338. extern void PlayPossessionSample(int team);
  339. extern long int PlayFrontEndSample(int sam,int amp);
  340. //************************************************************************************************
  341. // Internal Functions
  342. //************************************************************************************************
  343. void FreeLinkBank(void);
  344. short int CheckCommentary(void);
  345. void CreateMusicFileName(char *name,char *dest);
  346. void CreateScoreFileName(char *home,char *away,char *mad,char *dest);
  347. void CreatePitchFileName(char *name,char *mad,char *dest);
  348. void CreatePlayerFileName(char *country,char *number,char *intonation,char *mad,char *dest);
  349. void CreateCommentaryFileName(char *category,char *number,char *mad,char *dest);
  350. void CreateFrontEndFileName(char *category,char *name,char *mad,char *dest);
  351. int LoadSample(char *mad,char *name,memsam *bank,struct memstatus *MemStatus);
  352. void FreeSample(memsam *bank);
  353. void LoadCommentarySample(char *category,int samples,memsam *bank);
  354. int MADFindFile(FILE *fp,char *name);
  355. int CheckRepeatBuffer(char *category,int num);
  356. void ShowMemoryUsage(memstatus MemStatus,char *title);
  357. void LogText(char *format,...);
  358. #endif /* __AUDIO_H */