fx_man.h
1 /* 2 Copyright (C) 1994-1995 Apogee Software, Ltd. 3 4 This program is free software; you can redistribute it and/or 5 modify it under the terms of the GNU General Public License 6 as published by the Free Software Foundation; either version 2 7 of the License, or (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 13 See the GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 19 */ 20 /********************************************************************** 21 module: FX_MAN.H 22 23 author: James R. Dose 24 date: March 17, 1994 25 26 Public header for FX_MAN.C 27 28 (c) Copyright 1994 James R. Dose. All Rights Reserved. 29 **********************************************************************/ 30 31 #ifndef FX_MAN_H_ 32 #define FX_MAN_H_ 33 34 #include <inttypes.h> 35 #include "sndcards.h" 36 #include "limits.h" 37 #include "multivoc.h" 38 39 #ifdef __cplusplus 40 extern "C" { 41 #endif 42 43 enum FX_ERRORS 44 { 45 FX_Warning = -2, 46 FX_Error = -1, 47 FX_Ok = 0, 48 FX_InvalidCard, 49 FX_MultiVocError, 50 }; 51 52 enum FX_LOOP_HOW 53 { 54 FX_ONESHOT = -1, 55 FX_LOOP = 0, 56 }; 57 58 #define FX_MUSIC_PRIORITY INT_MAX 59 60 const char *FX_ErrorString(int ErrorNumber); 61 int FX_Init(int numvoices, int numchannels, int mixrate, void *initdata); 62 void FX_InitCvars(void); 63 int FX_Shutdown(void); 64 int FX_GetDevice(void); 65 66 /* returns true only after program startup */ 67 static FORCE_INLINE int FX_WarmedUp(void) 68 { 69 return ASS_PCMSoundDriver != ASS_AutoDetect; 70 } 71 72 73 int FX_Play(char *ptr, uint32_t ptrlength, int loopstart, int loopend, int pitchoffset, 74 int vol, int left, int right, int priority, fix16_t volume, intptr_t callbackval); 75 int FX_Play3D(char *ptr, uint32_t ptrlength, int loophow, int pitchoffset, int angle, 76 int distance, int priority, fix16_t volume, intptr_t callbackval); 77 int FX_PlayRaw(char *ptr, uint32_t ptrlength, int rate, int pitchoffset, int vol, 78 int left, int right, int priority, fix16_t volume, intptr_t callbackval); 79 int FX_PlayLoopedRaw(char *ptr, uint32_t ptrlength, char *loopstart, char *loopend, int rate, 80 int pitchoffset, int vol, int left, int right, int priority, fix16_t volume, intptr_t callbackval); 81 82 int FX_StartDemandFeedPlayback(void (*function)(const char** ptr, uint32_t* length, void* userdata), int bitdepth, int channels, int rate, int pitchoffset, 83 int vol, int left, int right, int priority, fix16_t volume, intptr_t callbackval, void* userdata); 84 85 int FX_StartDemandFeedPlayback3D(void (*function)(const char** ptr, uint32_t* length, void* userdata), int bitdepth, int channels, int rate, int pitchoffset, 86 int angle, int distance, int priority, fix16_t volume, intptr_t callbackval, void* userdata); 87 88 extern int FX_ErrorCode; 89 extern int FX_MixRate; 90 91 static FORCE_INLINE int FX_SetErrorCode(int status) 92 { 93 FX_ErrorCode = status; 94 return FX_Error; 95 } 96 97 static FORCE_INLINE int FX_CheckMVErr(int status) 98 { 99 if (status != MV_Ok) 100 { 101 FX_SetErrorCode(FX_MultiVocError); 102 status = FX_Warning; 103 } 104 105 return status; 106 } 107 108 static FORCE_INLINE void FX_SetCallBack(void(*function)(intptr_t)) { MV_SetCallBack(function); } 109 static FORCE_INLINE void FX_SetVolume(int volume) { MV_SetVolume(volume); } 110 static FORCE_INLINE int FX_GetVolume(void) { return MV_GetVolume(); } 111 #ifdef ASS_REVERSESTEREO 112 static FORCE_INLINE void FX_SetReverseStereo(int setting) { MV_SetReverseStereo(setting); } 113 static FORCE_INLINE int FX_GetReverseStereo(void) { return MV_GetReverseStereo(); } 114 #endif 115 static FORCE_INLINE void FX_SetReverb(int reverb) { MV_SetReverb(reverb); } 116 static FORCE_INLINE int FX_GetMaxReverbDelay(void) { return MV_GetMaxReverbDelay(); } 117 static FORCE_INLINE int FX_GetReverbDelay(void) { return MV_GetReverbDelay(); } 118 static FORCE_INLINE void FX_SetReverbDelay(int delay) { MV_SetReverbDelay(delay); } 119 static FORCE_INLINE int FX_VoiceAvailable(int priority) { return MV_VoiceAvailable(priority); } 120 static FORCE_INLINE int FX_PauseVoice(int handle, int pause) { return FX_CheckMVErr(MV_PauseVoice(handle, pause)); } 121 static FORCE_INLINE int FX_GetPosition(int handle, int *position) { return FX_CheckMVErr(MV_GetPosition(handle, position)); } 122 static FORCE_INLINE int FX_SetPosition(int handle, int position) { return FX_CheckMVErr(MV_SetPosition(handle, position)); } 123 static FORCE_INLINE int FX_EndLooping(int handle) { return FX_CheckMVErr(MV_EndLooping(handle)); } 124 static FORCE_INLINE int FX_SetPan(int handle, int vol, int left, int right) 125 { 126 return FX_CheckMVErr(MV_SetPan(handle, vol, left, right)); 127 } 128 static FORCE_INLINE int FX_SetPitch(int handle, int pitchoffset) { return FX_CheckMVErr(MV_SetPitch(handle, pitchoffset)); } 129 static FORCE_INLINE int FX_SetFrequency(int handle, int frequency) { return FX_CheckMVErr(MV_SetFrequency(handle, frequency)); } 130 static FORCE_INLINE int32_t FX_GetFrequency(int handle, int *frequency) { return FX_CheckMVErr(MV_GetFrequency(handle, frequency)); } 131 static FORCE_INLINE int FX_Pan3D(int handle, int angle, int distance) 132 { 133 return FX_CheckMVErr(MV_Pan3D(handle, angle, distance)); 134 } 135 static FORCE_INLINE int FX_SoundActive(int handle) { return MV_VoicePlaying(handle); } 136 static FORCE_INLINE int FX_SoundValidAndActive(int handle) { return handle > 0 && MV_VoicePlaying(handle); } 137 static FORCE_INLINE int FX_SoundsPlaying(void) { return MV_VoicesPlaying(); } 138 static FORCE_INLINE int FX_StopSound(int handle, bool useCallBack = true) { return FX_CheckMVErr(MV_Kill(handle, useCallBack)); } 139 static FORCE_INLINE int FX_StopAllSounds(bool useCallBack = true) { return FX_CheckMVErr(MV_KillAllVoices(useCallBack)); } 140 141 #ifdef __cplusplus 142 } 143 #endif 144 145 #endif