44 while (FirstInst) RemoveInst(FirstInst);
45 #if AUDIO_TK == AUDIO_TK_SDL_MIXER
46 if (pSample) Mix_FreeChunk(pSample);
47 #elif AUDIO_TK == AUDIO_TK_OPENAL
48 if (pSample) alDeleteBuffers(1, &pSample);
59 if (!hGroup.
LoadEntry(szFileName, &WaveBuffer))
return false;
89 if (loader->ReadInfo(&info, pData, iDataLen))
98 #if AUDIO_TK == AUDIO_TK_OPENAL
100 alGenBuffers(1, &pSample);
103 Log(
"SoundLoader does not provide a ready-made handle");
121 if (!pInst->Playing())
135 if (!pInst->
Create(
this, fLoop, iVolume, pObj, 0, iCustomFalloffDistance, iPitch, modifier)) {
delete pInst;
return nullptr; }
145 if (pInst->getObj() == pObj)
153 pInst->ClearPointers(pObj);
160 if (pInst->isStarted() && pInst->getObj() && pInst->Inside(iX, iY, iRad))
169 if (pInst->isStarted() && pInst->Playing() && !pInst->getObj())
176 pInst->
pNext = FirstInst;
182 if (pInst == FirstInst)
183 FirstInst = pInst->
pNext;
187 while (pPos && pPos->
pNext != pInst) pPos = pPos->
pNext;
270 #if AUDIO_TK == AUDIO_TK_SDL_MIXER
275 #elif AUDIO_TK == AUDIO_TK_OPENAL
277 alGenSources(1, (ALuint*)&
iChannel);
297 #if AUDIO_TK == AUDIO_TK_SDL_MIXER
301 #elif AUDIO_TK == AUDIO_TK_OPENAL
306 alDeleteSources(1, &c);
319 #if AUDIO_TK == AUDIO_TK_SDL_MIXER
321 #elif AUDIO_TK == AUDIO_TK_OPENAL
327 alGetSourcei(
iChannel, AL_SOURCE_STATE, &state);
328 return state == AL_PLAYING;
350 iVol = iVol * iAudibility / 100;
359 #if AUDIO_TK == AUDIO_TK_SDL_MIXER
361 #elif AUDIO_TK == AUDIO_TK_OPENAL
362 alDeleteSources(1, (ALuint*)&
iChannel);
374 #if AUDIO_TK == AUDIO_TK_SDL_MIXER
375 Mix_Volume(
iChannel, (iVol * MIX_MAX_VOLUME) / (100 * 256));
377 #elif AUDIO_TK == AUDIO_TK_OPENAL
378 alSource3f(
iChannel, AL_POSITION, Clamp<float>(
float(
iPan)/100.0f, -1.0f, +1.0f), 0, -0.7f);
379 alSourcef(
iChannel, AL_GAIN,
float(iVol) / (100.0f*256.0f));
383 alSourcef(
iChannel, AL_PITCH, std::max(
float(
iPitch + 100) / 100.0f, 0.1f));
436 if (old_modifier) old_modifier->
DelRef();
442 #if AUDIO_TK == AUDIO_TK_OPENAL
448 #if (AUDIO_TK == AUDIO_TK_OPENAL) && defined(HAVE_ALEXT)
449 alSource3i(
iChannel, AL_AUXILIARY_SEND_FILTER, AL_EFFECTSLOT_NULL, 0, AL_FILTER_NULL);
C4Application Application
bool Log(const char *szMessage)
const int32_t C4AudibilityRadius
const int32_t C4MaxSoundInstances
const int32_t C4NearSoundRadius
const int32_t C4MaxSoundName
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
void SAppend(const char *szSource, char *szTarget, int iMaxL)
T Clamp(T bval, T lbound, T rbound)
C4MusicSystem MusicSystem
C4SoundSystem SoundSystem
bool LoadEntry(const char *entry_name, char **buffer, size_t *size_info=nullptr, int zeros_to_append=0)
void RemoveInst(C4SoundInstance *pInst)
bool Load(const char *szFileName, C4Group &hGroup, const char *namespace_prefix)
int32_t GetStartedInstanceCount()
C4SoundInstance * New(bool fLoop=false, int32_t iVolume=100, C4Object *pObj=nullptr, int32_t iCustomFalloffDistance=0, int32_t iPitch=0, C4SoundModifier *modifier=nullptr)
void ClearPointers(C4Object *pObj)
C4SoundInstance * GetInstance(C4Object *pObj)
void AddInst(C4SoundInstance *pInst)
int32_t GetStartedInstanceCount(int32_t iX, int32_t iY, int32_t iRad)
void SetVolumeByPos(int32_t x, int32_t y, int32_t relative_volume=100)
void SetPitch(int32_t inPitch)
bool Create(C4SoundEffect *pEffect, bool fLoop=false, int32_t iVolume=100, C4Object *pObj=nullptr, int32_t iNearInstanceMax=0, int32_t iFalloffDistance=0, int32_t inPitch=0, C4SoundModifier *modifier=nullptr)
C4SoundModifier * modifier
C4TimeMilliseconds tStarted
void SetModifier(C4SoundModifier *new_modifier, bool is_global)
void ClearPointers(C4Object *pObj)
void SetPlayer(int32_t new_player)
bool Inside(int32_t iX, int32_t iY, int32_t iRad)
static SoundLoader * first_loader
static const int OPTION_Raw
void ApplyTo(ALuint source)
C4SoundModifier * GetGlobalModifier(int32_t player_index) const
C4SoundModifierList Modifiers
static C4TimeMilliseconds Now()
int32_t GetAudibility(int32_t x, int32_t y, int32_t *pan, int32_t audibility_radius=0, int32_t *out_player=nullptr)
std::vector< BYTE > sound_data
C4SoundHandle final_handle