FX_MAN.C 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337
  1. /*
  2. Copyright (C) 1994-1995 Apogee Software, Ltd.
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. See the GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. /**********************************************************************
  16. module: FX_MAN.C
  17. author: James R. Dose
  18. date: March 17, 1994
  19. Device independant sound effect routines.
  20. (c) Copyright 1994 James R. Dose. All Rights Reserved.
  21. **********************************************************************/
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include "sndcards.h"
  25. #include "multivoc.h"
  26. #include "blaster.h"
  27. #include "pas16.h"
  28. #include "sndscape.h"
  29. #include "guswave.h"
  30. #include "sndsrc.h"
  31. #include "ll_man.h"
  32. #include "user.h"
  33. #include "fx_man.h"
  34. #define TRUE ( 1 == 1 )
  35. #define FALSE ( !TRUE )
  36. static unsigned FX_MixRate;
  37. int FX_SoundDevice = -1;
  38. int FX_ErrorCode = FX_Ok;
  39. int FX_Installed = FALSE;
  40. void TextMode( void );
  41. #pragma aux TextMode = \
  42. "mov ax, 0003h", \
  43. "int 10h" \
  44. modify [ ax ];
  45. #define FX_SetErrorCode( status ) \
  46. FX_ErrorCode = ( status );
  47. /*---------------------------------------------------------------------
  48. Function: FX_ErrorString
  49. Returns a pointer to the error message associated with an error
  50. number. A -1 returns a pointer the current error.
  51. ---------------------------------------------------------------------*/
  52. char *FX_ErrorString
  53. (
  54. int ErrorNumber
  55. )
  56. {
  57. char *ErrorString;
  58. switch( ErrorNumber )
  59. {
  60. case FX_Warning :
  61. case FX_Error :
  62. ErrorString = FX_ErrorString( FX_ErrorCode );
  63. break;
  64. case FX_Ok :
  65. ErrorString = "Fx ok.";
  66. break;
  67. case FX_ASSVersion :
  68. ErrorString = "Apogee Sound System Version " ASS_VERSION_STRING " "
  69. "Programmed by Jim Dose\n"
  70. "(c) Copyright 1995 James R. Dose. All Rights Reserved.\n";
  71. break;
  72. case FX_BlasterError :
  73. ErrorString = BLASTER_ErrorString( BLASTER_Error );
  74. break;
  75. case FX_SoundCardError :
  76. switch( FX_SoundDevice )
  77. {
  78. case SoundBlaster :
  79. case Awe32 :
  80. ErrorString = BLASTER_ErrorString( BLASTER_Error );
  81. break;
  82. case ProAudioSpectrum :
  83. case SoundMan16 :
  84. ErrorString = PAS_ErrorString( PAS_Error );
  85. break;
  86. case SoundScape :
  87. ErrorString = SOUNDSCAPE_ErrorString( SOUNDSCAPE_Error );
  88. break;
  89. case UltraSound :
  90. ErrorString = GUSWAVE_ErrorString( GUSWAVE_Error );
  91. break;
  92. case SoundSource :
  93. case TandySoundSource :
  94. ErrorString = SS_ErrorString( SS_Error );
  95. break;
  96. }
  97. break;
  98. case FX_InvalidCard :
  99. ErrorString = "Invalid Sound Fx device.";
  100. break;
  101. case FX_MultiVocError :
  102. ErrorString = MV_ErrorString( MV_Error );
  103. break;
  104. case FX_DPMI_Error :
  105. ErrorString = "DPMI Error in FX_MAN.";
  106. break;
  107. default :
  108. ErrorString = "Unknown Fx error code.";
  109. break;
  110. }
  111. return( ErrorString );
  112. }
  113. /*---------------------------------------------------------------------
  114. Function: FX_SetupCard
  115. Sets the configuration of a sound device.
  116. ---------------------------------------------------------------------*/
  117. int FX_SetupCard
  118. (
  119. int SoundCard,
  120. fx_device *device
  121. )
  122. {
  123. int status;
  124. int DeviceStatus;
  125. if ( USER_CheckParameter( "ASSVER" ) )
  126. {
  127. FX_SetErrorCode( FX_ASSVersion );
  128. return( FX_Error );
  129. }
  130. FX_SoundDevice = SoundCard;
  131. status = FX_Ok;
  132. FX_SetErrorCode( FX_Ok );
  133. switch( SoundCard )
  134. {
  135. case SoundBlaster :
  136. case Awe32 :
  137. DeviceStatus = BLASTER_Init();
  138. if ( DeviceStatus != BLASTER_Ok )
  139. {
  140. FX_SetErrorCode( FX_SoundCardError );
  141. status = FX_Error;
  142. break;
  143. }
  144. device->MaxVoices = 32;
  145. BLASTER_GetCardInfo( &device->MaxSampleBits, &device->MaxChannels );
  146. break;
  147. case ProAudioSpectrum :
  148. case SoundMan16 :
  149. DeviceStatus = PAS_Init();
  150. if ( DeviceStatus != PAS_Ok )
  151. {
  152. FX_SetErrorCode( FX_SoundCardError );
  153. status = FX_Error;
  154. break;
  155. }
  156. device->MaxVoices = 32;
  157. PAS_GetCardInfo( &device->MaxSampleBits, &device->MaxChannels );
  158. break;
  159. case GenMidi :
  160. case SoundCanvas :
  161. case WaveBlaster :
  162. device->MaxVoices = 0;
  163. device->MaxSampleBits = 0;
  164. device->MaxChannels = 0;
  165. break;
  166. case SoundScape :
  167. device->MaxVoices = 32;
  168. DeviceStatus = SOUNDSCAPE_GetCardInfo( &device->MaxSampleBits,
  169. &device->MaxChannels );
  170. if ( DeviceStatus != SOUNDSCAPE_Ok )
  171. {
  172. FX_SetErrorCode( FX_SoundCardError );
  173. status = FX_Error;
  174. }
  175. break;
  176. case UltraSound :
  177. if ( GUSWAVE_Init( 8 ) != GUSWAVE_Ok )
  178. {
  179. FX_SetErrorCode( FX_SoundCardError );
  180. status = FX_Error;
  181. break;
  182. }
  183. device->MaxVoices = 8;
  184. device->MaxSampleBits = 0;
  185. device->MaxChannels = 0;
  186. break;
  187. case SoundSource :
  188. case TandySoundSource :
  189. DeviceStatus = SS_Init( SoundCard );
  190. if ( DeviceStatus != SS_Ok )
  191. {
  192. FX_SetErrorCode( FX_SoundCardError );
  193. status = FX_Error;
  194. break;
  195. }
  196. SS_Shutdown();
  197. device->MaxVoices = 32;
  198. device->MaxSampleBits = 8;
  199. device->MaxChannels = 1;
  200. break;
  201. default :
  202. FX_SetErrorCode( FX_InvalidCard );
  203. status = FX_Error;
  204. }
  205. return( status );
  206. }
  207. /*---------------------------------------------------------------------
  208. Function: FX_GetBlasterSettings
  209. Returns the current BLASTER environment variable settings.
  210. ---------------------------------------------------------------------*/
  211. int FX_GetBlasterSettings
  212. (
  213. fx_blaster_config *blaster
  214. )
  215. {
  216. int status;
  217. BLASTER_CONFIG Blaster;
  218. FX_SetErrorCode( FX_Ok );
  219. status = BLASTER_GetEnv( &Blaster );
  220. if ( status != BLASTER_Ok )
  221. {
  222. FX_SetErrorCode( FX_BlasterError );
  223. return( FX_Error );
  224. }
  225. blaster->Type = Blaster.Type;
  226. blaster->Address = Blaster.Address;
  227. blaster->Interrupt = Blaster.Interrupt;
  228. blaster->Dma8 = Blaster.Dma8;
  229. blaster->Dma16 = Blaster.Dma16;
  230. blaster->Midi = Blaster.Midi;
  231. blaster->Emu = Blaster.Emu;
  232. return( FX_Ok );
  233. }
  234. /*---------------------------------------------------------------------
  235. Function: FX_SetupSoundBlaster
  236. Handles manual setup of the Sound Blaster information.
  237. ---------------------------------------------------------------------*/
  238. int FX_SetupSoundBlaster
  239. (
  240. fx_blaster_config blaster,
  241. int *MaxVoices,
  242. int *MaxSampleBits,
  243. int *MaxChannels
  244. )
  245. {
  246. int DeviceStatus;
  247. BLASTER_CONFIG Blaster;
  248. FX_SetErrorCode( FX_Ok );
  249. FX_SoundDevice = SoundBlaster;
  250. Blaster.Type = blaster.Type;
  251. Blaster.Address = blaster.Address;
  252. Blaster.Interrupt = blaster.Interrupt;
  253. Blaster.Dma8 = blaster.Dma8;
  254. Blaster.Dma16 = blaster.Dma16;
  255. Blaster.Midi = blaster.Midi;
  256. Blaster.Emu = blaster.Emu;
  257. BLASTER_SetCardSettings( Blaster );
  258. DeviceStatus = BLASTER_Init();
  259. if ( DeviceStatus != BLASTER_Ok )
  260. {
  261. FX_SetErrorCode( FX_SoundCardError );
  262. return( FX_Error );
  263. }
  264. *MaxVoices = 8;
  265. BLASTER_GetCardInfo( MaxSampleBits, MaxChannels );
  266. return( FX_Ok );
  267. }
  268. /*---------------------------------------------------------------------
  269. Function: FX_Init
  270. Selects which sound device to use.
  271. ---------------------------------------------------------------------*/
  272. int FX_Init
  273. (
  274. int SoundCard,
  275. int numvoices,
  276. int numchannels,
  277. int samplebits,
  278. unsigned mixrate
  279. )
  280. {
  281. int status;
  282. int devicestatus;
  283. if ( FX_Installed )
  284. {
  285. FX_Shutdown();
  286. }
  287. if ( USER_CheckParameter( "ASSVER" ) )
  288. {
  289. FX_SetErrorCode( FX_ASSVersion );
  290. return( FX_Error );
  291. }
  292. status = LL_LockMemory();
  293. if ( status != LL_Ok )
  294. {
  295. FX_SetErrorCode( FX_DPMI_Error );
  296. return( FX_Error );
  297. }
  298. FX_MixRate = mixrate;
  299. status = FX_Ok;
  300. FX_SoundDevice = SoundCard;
  301. switch( SoundCard )
  302. {
  303. case SoundBlaster :
  304. case Awe32 :
  305. case ProAudioSpectrum :
  306. case SoundMan16 :
  307. case SoundScape :
  308. case SoundSource :
  309. case TandySoundSource :
  310. case UltraSound :
  311. devicestatus = MV_Init( SoundCard, FX_MixRate, numvoices,
  312. numchannels, samplebits );
  313. if ( devicestatus != MV_Ok )
  314. {
  315. FX_SetErrorCode( FX_MultiVocError );
  316. status = FX_Error;
  317. }
  318. break;
  319. default :
  320. FX_SetErrorCode( FX_InvalidCard );
  321. status = FX_Error;
  322. }
  323. if ( status != FX_Ok )
  324. {
  325. LL_UnlockMemory();
  326. }
  327. else
  328. {
  329. FX_Installed = TRUE;
  330. }
  331. return( status );
  332. }
  333. /*---------------------------------------------------------------------
  334. Function: FX_Shutdown
  335. Terminates use of sound device.
  336. ---------------------------------------------------------------------*/
  337. int FX_Shutdown
  338. (
  339. void
  340. )
  341. {
  342. int status;
  343. if ( !FX_Installed )
  344. {
  345. return( FX_Ok );
  346. }
  347. status = FX_Ok;
  348. switch( FX_SoundDevice )
  349. {
  350. case SoundBlaster :
  351. case Awe32 :
  352. case ProAudioSpectrum :
  353. case SoundMan16 :
  354. case SoundScape :
  355. case SoundSource :
  356. case TandySoundSource :
  357. case UltraSound :
  358. status = MV_Shutdown();
  359. if ( status != MV_Ok )
  360. {
  361. FX_SetErrorCode( FX_MultiVocError );
  362. status = FX_Error;
  363. }
  364. break;
  365. default :
  366. FX_SetErrorCode( FX_InvalidCard );
  367. status = FX_Error;
  368. }
  369. FX_Installed = FALSE;
  370. LL_UnlockMemory();
  371. return( status );
  372. }
  373. /*---------------------------------------------------------------------
  374. Function: FX_SetCallback
  375. Sets the function to call when a voice is done.
  376. ---------------------------------------------------------------------*/
  377. int FX_SetCallBack
  378. (
  379. void ( *function )( unsigned long )
  380. )
  381. {
  382. int status;
  383. status = FX_Ok;
  384. switch( FX_SoundDevice )
  385. {
  386. case SoundBlaster :
  387. case Awe32 :
  388. case ProAudioSpectrum :
  389. case SoundMan16 :
  390. case SoundScape :
  391. case SoundSource :
  392. case TandySoundSource :
  393. case UltraSound :
  394. MV_SetCallBack( function );
  395. break;
  396. default :
  397. FX_SetErrorCode( FX_InvalidCard );
  398. status = FX_Error;
  399. }
  400. return( status );
  401. }
  402. /*---------------------------------------------------------------------
  403. Function: FX_SetVolume
  404. Sets the volume of the current sound device.
  405. ---------------------------------------------------------------------*/
  406. void FX_SetVolume
  407. (
  408. int volume
  409. )
  410. {
  411. int status;
  412. switch( FX_SoundDevice )
  413. {
  414. case SoundBlaster :
  415. case Awe32 :
  416. if ( BLASTER_CardHasMixer() )
  417. {
  418. BLASTER_SetVoiceVolume( volume );
  419. }
  420. else
  421. {
  422. MV_SetVolume( volume );
  423. }
  424. break;
  425. case ProAudioSpectrum :
  426. case SoundMan16 :
  427. status = PAS_SetPCMVolume( volume );
  428. if ( status != PAS_Ok )
  429. {
  430. MV_SetVolume( volume );
  431. }
  432. break;
  433. case GenMidi :
  434. case SoundCanvas :
  435. case WaveBlaster :
  436. break;
  437. case SoundScape :
  438. MV_SetVolume( volume );
  439. break;
  440. case UltraSound :
  441. GUSWAVE_SetVolume( volume );
  442. break;
  443. case SoundSource :
  444. case TandySoundSource :
  445. MV_SetVolume( volume );
  446. break;
  447. }
  448. }
  449. /*---------------------------------------------------------------------
  450. Function: FX_GetVolume
  451. Returns the volume of the current sound device.
  452. ---------------------------------------------------------------------*/
  453. int FX_GetVolume
  454. (
  455. void
  456. )
  457. {
  458. int volume;
  459. switch( FX_SoundDevice )
  460. {
  461. case SoundBlaster :
  462. case Awe32 :
  463. if ( BLASTER_CardHasMixer() )
  464. {
  465. volume = BLASTER_GetVoiceVolume();
  466. }
  467. else
  468. {
  469. volume = MV_GetVolume();
  470. }
  471. break;
  472. case ProAudioSpectrum :
  473. case SoundMan16 :
  474. volume = PAS_GetPCMVolume();
  475. if ( volume == PAS_Error )
  476. {
  477. volume = MV_GetVolume();
  478. }
  479. break;
  480. case GenMidi :
  481. case SoundCanvas :
  482. case WaveBlaster :
  483. volume = 255;
  484. break;
  485. case SoundScape :
  486. volume = MV_GetVolume();
  487. break;
  488. case UltraSound :
  489. volume = GUSWAVE_GetVolume();
  490. break;
  491. case SoundSource :
  492. case TandySoundSource :
  493. volume = MV_GetVolume();
  494. break;
  495. default :
  496. volume = 0;
  497. }
  498. return( volume );
  499. }
  500. /*---------------------------------------------------------------------
  501. Function: FX_SetReverseStereo
  502. Set the orientation of the left and right channels.
  503. ---------------------------------------------------------------------*/
  504. void FX_SetReverseStereo
  505. (
  506. int setting
  507. )
  508. {
  509. MV_SetReverseStereo( setting );
  510. }
  511. /*---------------------------------------------------------------------
  512. Function: FX_GetReverseStereo
  513. Returns the orientation of the left and right channels.
  514. ---------------------------------------------------------------------*/
  515. int FX_GetReverseStereo
  516. (
  517. void
  518. )
  519. {
  520. return MV_GetReverseStereo();
  521. }
  522. /*---------------------------------------------------------------------
  523. Function: FX_SetReverb
  524. Sets the reverb level.
  525. ---------------------------------------------------------------------*/
  526. void FX_SetReverb
  527. (
  528. int reverb
  529. )
  530. {
  531. MV_SetReverb( reverb );
  532. }
  533. /*---------------------------------------------------------------------
  534. Function: FX_SetFastReverb
  535. Sets the reverb level.
  536. ---------------------------------------------------------------------*/
  537. void FX_SetFastReverb
  538. (
  539. int reverb
  540. )
  541. {
  542. MV_SetFastReverb( reverb );
  543. }
  544. /*---------------------------------------------------------------------
  545. Function: FX_GetMaxReverbDelay
  546. Returns the maximum delay time for reverb.
  547. ---------------------------------------------------------------------*/
  548. int FX_GetMaxReverbDelay
  549. (
  550. void
  551. )
  552. {
  553. return MV_GetMaxReverbDelay();
  554. }
  555. /*---------------------------------------------------------------------
  556. Function: FX_GetReverbDelay
  557. Returns the current delay time for reverb.
  558. ---------------------------------------------------------------------*/
  559. int FX_GetReverbDelay
  560. (
  561. void
  562. )
  563. {
  564. return MV_GetReverbDelay();
  565. }
  566. /*---------------------------------------------------------------------
  567. Function: FX_SetReverbDelay
  568. Sets the delay level of reverb to add to mix.
  569. ---------------------------------------------------------------------*/
  570. void FX_SetReverbDelay
  571. (
  572. int delay
  573. )
  574. {
  575. MV_SetReverbDelay( delay );
  576. }
  577. /*---------------------------------------------------------------------
  578. Function: FX_VoiceAvailable
  579. Checks if a voice can be play at the specified priority.
  580. ---------------------------------------------------------------------*/
  581. int FX_VoiceAvailable
  582. (
  583. int priority
  584. )
  585. {
  586. return MV_VoiceAvailable( priority );
  587. }
  588. /*---------------------------------------------------------------------
  589. Function: FX_EndLooping
  590. Stops the voice associated with the specified handle from looping
  591. without stoping the sound.
  592. ---------------------------------------------------------------------*/
  593. int FX_EndLooping
  594. (
  595. int handle
  596. )
  597. {
  598. int status;
  599. status = MV_EndLooping( handle );
  600. if ( status == MV_Error )
  601. {
  602. FX_SetErrorCode( FX_MultiVocError );
  603. status = FX_Warning;
  604. }
  605. return( status );
  606. }
  607. /*---------------------------------------------------------------------
  608. Function: FX_SetPan
  609. Sets the stereo and mono volume level of the voice associated
  610. with the specified handle.
  611. ---------------------------------------------------------------------*/
  612. int FX_SetPan
  613. (
  614. int handle,
  615. int vol,
  616. int left,
  617. int right
  618. )
  619. {
  620. int status;
  621. status = MV_SetPan( handle, vol, left, right );
  622. if ( status == MV_Error )
  623. {
  624. FX_SetErrorCode( FX_MultiVocError );
  625. status = FX_Warning;
  626. }
  627. return( status );
  628. }
  629. /*---------------------------------------------------------------------
  630. Function: FX_SetPitch
  631. Sets the pitch of the voice associated with the specified handle.
  632. ---------------------------------------------------------------------*/
  633. int FX_SetPitch
  634. (
  635. int handle,
  636. int pitchoffset
  637. )
  638. {
  639. int status;
  640. status = MV_SetPitch( handle, pitchoffset );
  641. if ( status == MV_Error )
  642. {
  643. FX_SetErrorCode( FX_MultiVocError );
  644. status = FX_Warning;
  645. }
  646. return( status );
  647. }
  648. /*---------------------------------------------------------------------
  649. Function: FX_SetFrequency
  650. Sets the frequency of the voice associated with the specified handle.
  651. ---------------------------------------------------------------------*/
  652. int FX_SetFrequency
  653. (
  654. int handle,
  655. int frequency
  656. )
  657. {
  658. int status;
  659. status = MV_SetFrequency( handle, frequency );
  660. if ( status == MV_Error )
  661. {
  662. FX_SetErrorCode( FX_MultiVocError );
  663. status = FX_Warning;
  664. }
  665. return( status );
  666. }
  667. /*---------------------------------------------------------------------
  668. Function: FX_PlayVOC
  669. Begin playback of sound data with the given volume and priority.
  670. ---------------------------------------------------------------------*/
  671. int FX_PlayVOC
  672. (
  673. char *ptr,
  674. int pitchoffset,
  675. int vol,
  676. int left,
  677. int right,
  678. int priority,
  679. unsigned long callbackval
  680. )
  681. {
  682. int handle;
  683. handle = MV_PlayVOC( ptr, pitchoffset, vol, left, right,
  684. priority, callbackval );
  685. if ( handle < MV_Ok )
  686. {
  687. FX_SetErrorCode( FX_MultiVocError );
  688. handle = FX_Warning;
  689. }
  690. return( handle );
  691. }
  692. /*---------------------------------------------------------------------
  693. Function: FX_PlayLoopedVOC
  694. Begin playback of sound data with the given volume and priority.
  695. ---------------------------------------------------------------------*/
  696. int FX_PlayLoopedVOC
  697. (
  698. char *ptr,
  699. long loopstart,
  700. long loopend,
  701. int pitchoffset,
  702. int vol,
  703. int left,
  704. int right,
  705. int priority,
  706. unsigned long callbackval
  707. )
  708. {
  709. int handle;
  710. handle = MV_PlayLoopedVOC( ptr, loopstart, loopend, pitchoffset,
  711. vol, left, right, priority, callbackval );
  712. if ( handle < MV_Ok )
  713. {
  714. FX_SetErrorCode( FX_MultiVocError );
  715. handle = FX_Warning;
  716. }
  717. return( handle );
  718. }
  719. /*---------------------------------------------------------------------
  720. Function: FX_PlayWAV
  721. Begin playback of sound data with the given volume and priority.
  722. ---------------------------------------------------------------------*/
  723. int FX_PlayWAV
  724. (
  725. char *ptr,
  726. int pitchoffset,
  727. int vol,
  728. int left,
  729. int right,
  730. int priority,
  731. unsigned long callbackval
  732. )
  733. {
  734. int handle;
  735. handle = MV_PlayWAV( ptr, pitchoffset, vol, left, right,
  736. priority, callbackval );
  737. if ( handle < MV_Ok )
  738. {
  739. FX_SetErrorCode( FX_MultiVocError );
  740. handle = FX_Warning;
  741. }
  742. return( handle );
  743. }
  744. /*---------------------------------------------------------------------
  745. Function: FX_PlayWAV
  746. Begin playback of sound data with the given volume and priority.
  747. ---------------------------------------------------------------------*/
  748. int FX_PlayLoopedWAV
  749. (
  750. char *ptr,
  751. long loopstart,
  752. long loopend,
  753. int pitchoffset,
  754. int vol,
  755. int left,
  756. int right,
  757. int priority,
  758. unsigned long callbackval
  759. )
  760. {
  761. int handle;
  762. handle = MV_PlayLoopedWAV( ptr, loopstart, loopend,
  763. pitchoffset, vol, left, right, priority, callbackval );
  764. if ( handle < MV_Ok )
  765. {
  766. FX_SetErrorCode( FX_MultiVocError );
  767. handle = FX_Warning;
  768. }
  769. return( handle );
  770. }
  771. /*---------------------------------------------------------------------
  772. Function: FX_PlayVOC3D
  773. Begin playback of sound data at specified angle and distance
  774. from listener.
  775. ---------------------------------------------------------------------*/
  776. int FX_PlayVOC3D
  777. (
  778. char *ptr,
  779. int pitchoffset,
  780. int angle,
  781. int distance,
  782. int priority,
  783. unsigned long callbackval
  784. )
  785. {
  786. int handle;
  787. handle = MV_PlayVOC3D( ptr, pitchoffset, angle, distance,
  788. priority, callbackval );
  789. if ( handle < MV_Ok )
  790. {
  791. FX_SetErrorCode( FX_MultiVocError );
  792. handle = FX_Warning;
  793. }
  794. return( handle );
  795. }
  796. /*---------------------------------------------------------------------
  797. Function: FX_PlayWAV3D
  798. Begin playback of sound data at specified angle and distance
  799. from listener.
  800. ---------------------------------------------------------------------*/
  801. int FX_PlayWAV3D
  802. (
  803. char *ptr,
  804. int pitchoffset,
  805. int angle,
  806. int distance,
  807. int priority,
  808. unsigned long callbackval
  809. )
  810. {
  811. int handle;
  812. handle = MV_PlayWAV3D( ptr, pitchoffset, angle, distance,
  813. priority, callbackval );
  814. if ( handle < MV_Ok )
  815. {
  816. FX_SetErrorCode( FX_MultiVocError );
  817. handle = FX_Warning;
  818. }
  819. return( handle );
  820. }
  821. /*---------------------------------------------------------------------
  822. Function: FX_PlayRaw
  823. Begin playback of raw sound data with the given volume and priority.
  824. ---------------------------------------------------------------------*/
  825. int FX_PlayRaw
  826. (
  827. char *ptr,
  828. unsigned long length,
  829. unsigned rate,
  830. int pitchoffset,
  831. int vol,
  832. int left,
  833. int right,
  834. int priority,
  835. unsigned long callbackval
  836. )
  837. {
  838. int handle;
  839. handle = MV_PlayRaw( ptr, length, rate, pitchoffset,
  840. vol, left, right, priority, callbackval );
  841. if ( handle < MV_Ok )
  842. {
  843. FX_SetErrorCode( FX_MultiVocError );
  844. handle = FX_Warning;
  845. }
  846. return( handle );
  847. }
  848. /*---------------------------------------------------------------------
  849. Function: FX_PlayLoopedRaw
  850. Begin playback of raw sound data with the given volume and priority.
  851. ---------------------------------------------------------------------*/
  852. int FX_PlayLoopedRaw
  853. (
  854. char *ptr,
  855. unsigned long length,
  856. char *loopstart,
  857. char *loopend,
  858. unsigned rate,
  859. int pitchoffset,
  860. int vol,
  861. int left,
  862. int right,
  863. int priority,
  864. unsigned long callbackval
  865. )
  866. {
  867. int handle;
  868. handle = MV_PlayLoopedRaw( ptr, length, loopstart, loopend,
  869. rate, pitchoffset, vol, left, right, priority, callbackval );
  870. if ( handle < MV_Ok )
  871. {
  872. FX_SetErrorCode( FX_MultiVocError );
  873. handle = FX_Warning;
  874. }
  875. return( handle );
  876. }
  877. /*---------------------------------------------------------------------
  878. Function: FX_Pan3D
  879. Set the angle and distance from the listener of the voice associated
  880. with the specified handle.
  881. ---------------------------------------------------------------------*/
  882. int FX_Pan3D
  883. (
  884. int handle,
  885. int angle,
  886. int distance
  887. )
  888. {
  889. int status;
  890. status = MV_Pan3D( handle, angle, distance );
  891. if ( status != MV_Ok )
  892. {
  893. FX_SetErrorCode( FX_MultiVocError );
  894. status = FX_Warning;
  895. }
  896. return( status );
  897. }
  898. /*---------------------------------------------------------------------
  899. Function: FX_SoundActive
  900. Tests if the specified sound is currently playing.
  901. ---------------------------------------------------------------------*/
  902. int FX_SoundActive
  903. (
  904. int handle
  905. )
  906. {
  907. return( MV_VoicePlaying( handle ) );
  908. }
  909. /*---------------------------------------------------------------------
  910. Function: FX_SoundsPlaying
  911. Reports the number of voices playing.
  912. ---------------------------------------------------------------------*/
  913. int FX_SoundsPlaying
  914. (
  915. void
  916. )
  917. {
  918. return( MV_VoicesPlaying() );
  919. }
  920. /*---------------------------------------------------------------------
  921. Function: FX_StopSound
  922. Halts playback of a specific voice
  923. ---------------------------------------------------------------------*/
  924. int FX_StopSound
  925. (
  926. int handle
  927. )
  928. {
  929. int status;
  930. status = MV_Kill( handle );
  931. if ( status != MV_Ok )
  932. {
  933. FX_SetErrorCode( FX_MultiVocError );
  934. return( FX_Warning );
  935. }
  936. return( FX_Ok );
  937. }
  938. /*---------------------------------------------------------------------
  939. Function: FX_StopAllSounds
  940. Halts playback of all sounds.
  941. ---------------------------------------------------------------------*/
  942. int FX_StopAllSounds
  943. (
  944. void
  945. )
  946. {
  947. int status;
  948. status = MV_KillAllVoices();
  949. if ( status != MV_Ok )
  950. {
  951. FX_SetErrorCode( FX_MultiVocError );
  952. return( FX_Warning );
  953. }
  954. return( FX_Ok );
  955. }
  956. /*---------------------------------------------------------------------
  957. Function: FX_StartDemandFeedPlayback
  958. Plays a digitized sound from a user controlled buffering system.
  959. ---------------------------------------------------------------------*/
  960. int FX_StartDemandFeedPlayback
  961. (
  962. void ( *function )( char **ptr, unsigned long *length ),
  963. int rate,
  964. int pitchoffset,
  965. int vol,
  966. int left,
  967. int right,
  968. int priority,
  969. unsigned long callbackval
  970. )
  971. {
  972. int handle;
  973. handle = MV_StartDemandFeedPlayback( function, rate,
  974. pitchoffset, vol, left, right, priority, callbackval );
  975. if ( handle < MV_Ok )
  976. {
  977. FX_SetErrorCode( FX_MultiVocError );
  978. handle = FX_Warning;
  979. }
  980. return( handle );
  981. }
  982. /*---------------------------------------------------------------------
  983. Function: FX_StartRecording
  984. Starts the sound recording engine.
  985. ---------------------------------------------------------------------*/
  986. int FX_StartRecording
  987. (
  988. int MixRate,
  989. void ( *function )( char *ptr, int length )
  990. )
  991. {
  992. int status;
  993. switch( FX_SoundDevice )
  994. {
  995. case SoundBlaster :
  996. case Awe32 :
  997. case ProAudioSpectrum :
  998. case SoundMan16 :
  999. status = MV_StartRecording( MixRate, function );
  1000. if ( status != MV_Ok )
  1001. {
  1002. FX_SetErrorCode( FX_MultiVocError );
  1003. status = FX_Warning;
  1004. }
  1005. else
  1006. {
  1007. status = FX_Ok;
  1008. }
  1009. break;
  1010. default :
  1011. FX_SetErrorCode( FX_InvalidCard );
  1012. status = FX_Warning;
  1013. break;
  1014. }
  1015. return( status );
  1016. }
  1017. /*---------------------------------------------------------------------
  1018. Function: FX_StopRecord
  1019. Stops the sound record engine.
  1020. ---------------------------------------------------------------------*/
  1021. void FX_StopRecord
  1022. (
  1023. void
  1024. )
  1025. {
  1026. // Stop sound playback
  1027. switch( FX_SoundDevice )
  1028. {
  1029. case SoundBlaster :
  1030. case Awe32 :
  1031. case ProAudioSpectrum :
  1032. case SoundMan16 :
  1033. MV_StopRecord();
  1034. break;
  1035. }
  1036. }