wiiu: audio fixes

This commit is contained in:
GaryOderNichts 2020-12-18 20:46:49 +01:00
parent 2ec0e7f27e
commit f9b5b7e016
6 changed files with 212 additions and 187 deletions

View File

@ -276,33 +276,30 @@ int ALDeviceList::GetNextFilteredDevice()
*/
unsigned int ALDeviceList::GetMaxNumSources()
{
// ALuint uiSources[256];
// unsigned int iSourceCount = 0;
ALuint uiSources[256];
unsigned int iSourceCount = 0;
// // Clear AL Error Code
// alGetError();
// Clear AL Error Code
alGetError();
// // Generate up to 256 Sources, checking for any errors
// for (iSourceCount = 0; iSourceCount < 256; iSourceCount++)
// {
// alGenSources(1, &uiSources[iSourceCount]);
// if (alGetError() != AL_NO_ERROR)
// break;
// }
// Generate up to 256 Sources, checking for any errors
for (iSourceCount = 0; iSourceCount < 256; iSourceCount++)
{
alGenSources(1, &uiSources[iSourceCount]);
if (alGetError() != AL_NO_ERROR)
break;
}
// // Release the Sources
// alDeleteSources(iSourceCount, uiSources);
// if (alGetError() != AL_NO_ERROR)
// {
// for (unsigned int i = 0; i < 256; i++)
// {
// alDeleteSources(1, &uiSources[i]);
// }
// }
// Release the Sources
alDeleteSources(iSourceCount, uiSources);
if (alGetError() != AL_NO_ERROR)
{
for (unsigned int i = 0; i < 256; i++)
{
alDeleteSources(1, &uiSources[i]);
}
}
// return iSourceCount;
// allocating sources until it errors seems to just crash. using a hardcoded value for now
return 100;
return iSourceCount;
}
#endif

View File

@ -57,7 +57,7 @@ void CChannel::Init(bool Is2D)
else
{
if ( IsFXSupported() )
reAlGenFilters(1,&alFilter);
alGenFilters(1,&alFilter);
}
}
}
@ -72,7 +72,7 @@ void CChannel::Term()
alSource3i(alSource, AL_AUXILIARY_SEND_FILTER, AL_EFFECTSLOT_NULL, 0, AL_FILTER_NULL);
if(alFilter != AL_FILTER_NULL)
reAlDeleteFilters(1,&alFilter);
alDeleteFilters(1,&alFilter);
}
alDeleteSources(1, &alSource);

View File

@ -3,89 +3,93 @@
#ifdef AUDIO_OAL
LPALGENEFFECTS reAlGenEffects;
LPALDELETEEFFECTS reAlDeleteEffects;
LPALISEFFECT reAlIsEffect;
LPALEFFECTI reAlEffecti;
LPALEFFECTIV reAlEffectiv;
LPALEFFECTF reAlEffectf;
LPALEFFECTFV reAlEffectfv;
LPALGETEFFECTI reAlGetEffecti;
LPALGETEFFECTIV reAlGetEffectiv;
LPALGETEFFECTF reAlGetEffectf;
LPALGETEFFECTFV reAlGetEffectfv;
LPALGENAUXILIARYEFFECTSLOTS reAlGenAuxiliaryEffectSlots;
LPALDELETEAUXILIARYEFFECTSLOTS reAlDeleteAuxiliaryEffectSlots;
LPALISAUXILIARYEFFECTSLOT reAlIsAuxiliaryEffectSlot;
LPALAUXILIARYEFFECTSLOTI reAlAuxiliaryEffectSloti;
LPALAUXILIARYEFFECTSLOTIV reAlAuxiliaryEffectSlotiv;
LPALAUXILIARYEFFECTSLOTF reAlAuxiliaryEffectSlotf;
LPALAUXILIARYEFFECTSLOTFV reAlAuxiliaryEffectSlotfv;
LPALGETAUXILIARYEFFECTSLOTI reAlGetAuxiliaryEffectSloti;
LPALGETAUXILIARYEFFECTSLOTIV reAlGetAuxiliaryEffectSlotiv;
LPALGETAUXILIARYEFFECTSLOTF reAlGetAuxiliaryEffectSlotf;
LPALGETAUXILIARYEFFECTSLOTFV reAlGetAuxiliaryEffectSlotfv;
LPALGENFILTERS reAlGenFilters;
LPALDELETEFILTERS reAlDeleteFilters;
LPALISFILTER reAlIsFilter;
LPALFILTERI reAlFilteri;
LPALFILTERIV reAlFilteriv;
LPALFILTERF reAlFilterf;
LPALFILTERFV reAlFilterfv;
LPALGETFILTERI reAlGetFilteri;
LPALGETFILTERIV reAlGetFilteriv;
LPALGETFILTERF reAlGetFilterf;
LPALGETFILTERFV reAlGetFilterfv;
#ifndef __WIIU__
LPALGENEFFECTS alGenEffects;
LPALDELETEEFFECTS alDeleteEffects;
LPALISEFFECT alIsEffect;
LPALEFFECTI alEffecti;
LPALEFFECTIV alEffectiv;
LPALEFFECTF alEffectf;
LPALEFFECTFV alEffectfv;
LPALGETEFFECTI alGetEffecti;
LPALGETEFFECTIV alGetEffectiv;
LPALGETEFFECTF alGetEffectf;
LPALGETEFFECTFV alGetEffectfv;
LPALGENAUXILIARYEFFECTSLOTS alGenAuxiliaryEffectSlots;
LPALDELETEAUXILIARYEFFECTSLOTS alDeleteAuxiliaryEffectSlots;
LPALISAUXILIARYEFFECTSLOT alIsAuxiliaryEffectSlot;
LPALAUXILIARYEFFECTSLOTI alAuxiliaryEffectSloti;
LPALAUXILIARYEFFECTSLOTIV alAuxiliaryEffectSlotiv;
LPALAUXILIARYEFFECTSLOTF alAuxiliaryEffectSlotf;
LPALAUXILIARYEFFECTSLOTFV alAuxiliaryEffectSlotfv;
LPALGETAUXILIARYEFFECTSLOTI alGetAuxiliaryEffectSloti;
LPALGETAUXILIARYEFFECTSLOTIV alGetAuxiliaryEffectSlotiv;
LPALGETAUXILIARYEFFECTSLOTF alGetAuxiliaryEffectSlotf;
LPALGETAUXILIARYEFFECTSLOTFV alGetAuxiliaryEffectSlotfv;
LPALGENFILTERS alGenFilters;
LPALDELETEFILTERS alDeleteFilters;
LPALISFILTER alIsFilter;
LPALFILTERI alFilteri;
LPALFILTERIV alFilteriv;
LPALFILTERF alFilterf;
LPALFILTERFV alFilterfv;
LPALGETFILTERI alGetFilteri;
LPALGETFILTERIV alGetFilteriv;
LPALGETFILTERF alGetFilterf;
LPALGETFILTERFV alGetFilterfv;
#endif
void EFXInit()
{
#ifndef __WIIU__
/* Define a macro to help load the function pointers. */
/* Prefix all the function pointers with re* to avoid linking issue with the library functions */
#define LOAD_PROC(T, x, y) ((x) = (T)alGetProcAddress(#y))
LOAD_PROC(LPALGENEFFECTS, reAlGenEffects, alGenEffects);
LOAD_PROC(LPALDELETEEFFECTS, reAlDeleteEffects, alDeleteEffects);
LOAD_PROC(LPALISEFFECT, reAlIsEffect, alIsEffect);
LOAD_PROC(LPALEFFECTI, reAlEffecti, alEffecti);
LOAD_PROC(LPALEFFECTIV, reAlEffectiv, alEffectiv);
LOAD_PROC(LPALEFFECTF, reAlEffectf, alEffectf);
LOAD_PROC(LPALEFFECTFV, reAlEffectfv, alEffectfv);
LOAD_PROC(LPALGETEFFECTI, reAlGetEffecti, alGetEffecti);
LOAD_PROC(LPALGETEFFECTIV, reAlGetEffectiv, alGetEffectiv);
LOAD_PROC(LPALGETEFFECTF, reAlGetEffectf, alGetEffectf);
LOAD_PROC(LPALGETEFFECTFV, reAlGetEffectfv, alGetEffectfv);
#define LOAD_PROC(T, x) ((x) = (T)alGetProcAddress(#x))
LOAD_PROC(LPALGENEFFECTS, alGenEffects);
LOAD_PROC(LPALDELETEEFFECTS, alDeleteEffects);
LOAD_PROC(LPALISEFFECT, alIsEffect);
LOAD_PROC(LPALEFFECTI, alEffecti);
LOAD_PROC(LPALEFFECTIV, alEffectiv);
LOAD_PROC(LPALEFFECTF, alEffectf);
LOAD_PROC(LPALEFFECTFV, alEffectfv);
LOAD_PROC(LPALGETEFFECTI, alGetEffecti);
LOAD_PROC(LPALGETEFFECTIV, alGetEffectiv);
LOAD_PROC(LPALGETEFFECTF, alGetEffectf);
LOAD_PROC(LPALGETEFFECTFV, alGetEffectfv);
LOAD_PROC(LPALGENFILTERS, reAlGenFilters, alGenFilters);
LOAD_PROC(LPALDELETEFILTERS, reAlDeleteFilters, alDeleteFilters);
LOAD_PROC(LPALISFILTER, reAlIsFilter, alIsFilter);
LOAD_PROC(LPALFILTERI, reAlFilteri, alFilteri);
LOAD_PROC(LPALFILTERIV, reAlFilteriv, alFilteriv);
LOAD_PROC(LPALFILTERF, reAlFilterf, alFilterf);
LOAD_PROC(LPALFILTERFV, reAlFilterfv, alFilterfv);
LOAD_PROC(LPALGETFILTERI, reAlGetFilteri, alGetFilteri);
LOAD_PROC(LPALGETFILTERIV, reAlGetFilteriv, alGetFilteriv);
LOAD_PROC(LPALGETFILTERF, reAlGetFilterf, alGetFilterf);
LOAD_PROC(LPALGETFILTERFV, reAlGetFilterfv, alGetFilterfv);
LOAD_PROC(LPALGENFILTERS, alGenFilters);
LOAD_PROC(LPALDELETEFILTERS, alDeleteFilters);
LOAD_PROC(LPALISFILTER, alIsFilter);
LOAD_PROC(LPALFILTERI, alFilteri);
LOAD_PROC(LPALFILTERIV, alFilteriv);
LOAD_PROC(LPALFILTERF, alFilterf);
LOAD_PROC(LPALFILTERFV, alFilterfv);
LOAD_PROC(LPALGETFILTERI, alGetFilteri);
LOAD_PROC(LPALGETFILTERIV, alGetFilteriv);
LOAD_PROC(LPALGETFILTERF, alGetFilterf);
LOAD_PROC(LPALGETFILTERFV, alGetFilterfv);
LOAD_PROC(LPALGENAUXILIARYEFFECTSLOTS, reAlGenAuxiliaryEffectSlots, alGenAuxiliaryEffectSlots);
LOAD_PROC(LPALDELETEAUXILIARYEFFECTSLOTS, reAlDeleteAuxiliaryEffectSlots, alDeleteAuxiliaryEffectSlots);
LOAD_PROC(LPALISAUXILIARYEFFECTSLOT, reAlIsAuxiliaryEffectSlot, alIsAuxiliaryEffectSlot);
LOAD_PROC(LPALAUXILIARYEFFECTSLOTI, reAlAuxiliaryEffectSloti, alAuxiliaryEffectSloti);
LOAD_PROC(LPALAUXILIARYEFFECTSLOTIV, reAlAuxiliaryEffectSlotiv, alAuxiliaryEffectSlotiv);
LOAD_PROC(LPALAUXILIARYEFFECTSLOTF, reAlAuxiliaryEffectSlotf, alAuxiliaryEffectSlotf);
LOAD_PROC(LPALAUXILIARYEFFECTSLOTFV, reAlAuxiliaryEffectSlotfv, alAuxiliaryEffectSlotfv);
LOAD_PROC(LPALGETAUXILIARYEFFECTSLOTI, reAlGetAuxiliaryEffectSloti, alGetAuxiliaryEffectSloti);
LOAD_PROC(LPALGETAUXILIARYEFFECTSLOTIV, reAlGetAuxiliaryEffectSlotiv, alGetAuxiliaryEffectSlotiv);
LOAD_PROC(LPALGETAUXILIARYEFFECTSLOTF, reAlGetAuxiliaryEffectSlotf, alGetAuxiliaryEffectSlotf);
LOAD_PROC(LPALGETAUXILIARYEFFECTSLOTFV, reAlGetAuxiliaryEffectSlotfv, alGetAuxiliaryEffectSlotfv);
LOAD_PROC(LPALGENAUXILIARYEFFECTSLOTS, alGenAuxiliaryEffectSlots);
LOAD_PROC(LPALDELETEAUXILIARYEFFECTSLOTS, alDeleteAuxiliaryEffectSlots);
LOAD_PROC(LPALISAUXILIARYEFFECTSLOT, alIsAuxiliaryEffectSlot);
LOAD_PROC(LPALAUXILIARYEFFECTSLOTI, alAuxiliaryEffectSloti);
LOAD_PROC(LPALAUXILIARYEFFECTSLOTIV, alAuxiliaryEffectSlotiv);
LOAD_PROC(LPALAUXILIARYEFFECTSLOTF, alAuxiliaryEffectSlotf);
LOAD_PROC(LPALAUXILIARYEFFECTSLOTFV, alAuxiliaryEffectSlotfv);
LOAD_PROC(LPALGETAUXILIARYEFFECTSLOTI, alGetAuxiliaryEffectSloti);
LOAD_PROC(LPALGETAUXILIARYEFFECTSLOTIV, alGetAuxiliaryEffectSlotiv);
LOAD_PROC(LPALGETAUXILIARYEFFECTSLOTF, alGetAuxiliaryEffectSlotf);
LOAD_PROC(LPALGETAUXILIARYEFFECTSLOTFV, alGetAuxiliaryEffectSlotfv);
#undef LOAD_PROC
#endif
}
void SetEffectsLevel(ALuint uiFilter, float level)
{
reAlFilteri(uiFilter, AL_FILTER_TYPE, AL_FILTER_LOWPASS);
reAlFilterf(uiFilter, AL_LOWPASS_GAIN, 1.0f);
reAlFilterf(uiFilter, AL_LOWPASS_GAINHF, level);
alFilteri(uiFilter, AL_FILTER_TYPE, AL_FILTER_LOWPASS);
alFilterf(uiFilter, AL_LOWPASS_GAIN, 1.0f);
alFilterf(uiFilter, AL_LOWPASS_GAINHF, level);
}
static inline float gain_to_mB(float gain)
@ -107,49 +111,49 @@ static inline float clampF(float val, float minval, float maxval)
void EAX3_Set(ALuint effect, const EAXLISTENERPROPERTIES *props)
{
reAlEffecti (effect, AL_EFFECT_TYPE, AL_EFFECT_EAXREVERB);
reAlEffectf (effect, AL_EAXREVERB_DENSITY, clampF(powf(props->flEnvironmentSize, 3.0f) / 16.0f, 0.0f, 1.0f));
reAlEffectf (effect, AL_EAXREVERB_DIFFUSION, props->flEnvironmentDiffusion);
reAlEffectf (effect, AL_EAXREVERB_GAIN, mB_to_gain((float)props->lRoom));
reAlEffectf (effect, AL_EAXREVERB_GAINHF, mB_to_gain((float)props->lRoomHF));
reAlEffectf (effect, AL_EAXREVERB_GAINLF, mB_to_gain((float)props->lRoomLF));
reAlEffectf (effect, AL_EAXREVERB_DECAY_TIME, props->flDecayTime);
reAlEffectf (effect, AL_EAXREVERB_DECAY_HFRATIO, props->flDecayHFRatio);
reAlEffectf (effect, AL_EAXREVERB_DECAY_LFRATIO, props->flDecayLFRatio);
reAlEffectf (effect, AL_EAXREVERB_REFLECTIONS_GAIN, clampF(mB_to_gain((float)props->lReflections), AL_EAXREVERB_MIN_REFLECTIONS_GAIN, AL_EAXREVERB_MAX_REFLECTIONS_GAIN));
reAlEffectf (effect, AL_EAXREVERB_REFLECTIONS_DELAY, props->flReflectionsDelay);
reAlEffectfv(effect, AL_EAXREVERB_REFLECTIONS_PAN, &props->vReflectionsPan.x);
reAlEffectf (effect, AL_EAXREVERB_LATE_REVERB_GAIN, clampF(mB_to_gain((float)props->lReverb), AL_EAXREVERB_MIN_LATE_REVERB_GAIN, AL_EAXREVERB_MAX_LATE_REVERB_GAIN));
reAlEffectf (effect, AL_EAXREVERB_LATE_REVERB_DELAY, props->flReverbDelay);
reAlEffectfv(effect, AL_EAXREVERB_LATE_REVERB_PAN, &props->vReverbPan.x);
reAlEffectf (effect, AL_EAXREVERB_ECHO_TIME, props->flEchoTime);
reAlEffectf (effect, AL_EAXREVERB_ECHO_DEPTH, props->flEchoDepth);
reAlEffectf (effect, AL_EAXREVERB_MODULATION_TIME, props->flModulationTime);
reAlEffectf (effect, AL_EAXREVERB_MODULATION_DEPTH, props->flModulationDepth);
reAlEffectf (effect, AL_EAXREVERB_AIR_ABSORPTION_GAINHF, clampF(mB_to_gain(props->flAirAbsorptionHF), AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF, AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF));
reAlEffectf (effect, AL_EAXREVERB_HFREFERENCE, props->flHFReference);
reAlEffectf (effect, AL_EAXREVERB_LFREFERENCE, props->flLFReference);
reAlEffectf (effect, AL_EAXREVERB_ROOM_ROLLOFF_FACTOR, props->flRoomRolloffFactor);
reAlEffecti (effect, AL_EAXREVERB_DECAY_HFLIMIT, (props->ulFlags&EAXLISTENERFLAGS_DECAYHFLIMIT) ? AL_TRUE : AL_FALSE);
alEffecti (effect, AL_EFFECT_TYPE, AL_EFFECT_EAXREVERB);
alEffectf (effect, AL_EAXREVERB_DENSITY, clampF(powf(props->flEnvironmentSize, 3.0f) / 16.0f, 0.0f, 1.0f));
alEffectf (effect, AL_EAXREVERB_DIFFUSION, props->flEnvironmentDiffusion);
alEffectf (effect, AL_EAXREVERB_GAIN, mB_to_gain((float)props->lRoom));
alEffectf (effect, AL_EAXREVERB_GAINHF, mB_to_gain((float)props->lRoomHF));
alEffectf (effect, AL_EAXREVERB_GAINLF, mB_to_gain((float)props->lRoomLF));
alEffectf (effect, AL_EAXREVERB_DECAY_TIME, props->flDecayTime);
alEffectf (effect, AL_EAXREVERB_DECAY_HFRATIO, props->flDecayHFRatio);
alEffectf (effect, AL_EAXREVERB_DECAY_LFRATIO, props->flDecayLFRatio);
alEffectf (effect, AL_EAXREVERB_REFLECTIONS_GAIN, clampF(mB_to_gain((float)props->lReflections), AL_EAXREVERB_MIN_REFLECTIONS_GAIN, AL_EAXREVERB_MAX_REFLECTIONS_GAIN));
alEffectf (effect, AL_EAXREVERB_REFLECTIONS_DELAY, props->flReflectionsDelay);
alEffectfv(effect, AL_EAXREVERB_REFLECTIONS_PAN, &props->vReflectionsPan.x);
alEffectf (effect, AL_EAXREVERB_LATE_REVERB_GAIN, clampF(mB_to_gain((float)props->lReverb), AL_EAXREVERB_MIN_LATE_REVERB_GAIN, AL_EAXREVERB_MAX_LATE_REVERB_GAIN));
alEffectf (effect, AL_EAXREVERB_LATE_REVERB_DELAY, props->flReverbDelay);
alEffectfv(effect, AL_EAXREVERB_LATE_REVERB_PAN, &props->vReverbPan.x);
alEffectf (effect, AL_EAXREVERB_ECHO_TIME, props->flEchoTime);
alEffectf (effect, AL_EAXREVERB_ECHO_DEPTH, props->flEchoDepth);
alEffectf (effect, AL_EAXREVERB_MODULATION_TIME, props->flModulationTime);
alEffectf (effect, AL_EAXREVERB_MODULATION_DEPTH, props->flModulationDepth);
alEffectf (effect, AL_EAXREVERB_AIR_ABSORPTION_GAINHF, clampF(mB_to_gain(props->flAirAbsorptionHF), AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF, AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF));
alEffectf (effect, AL_EAXREVERB_HFREFERENCE, props->flHFReference);
alEffectf (effect, AL_EAXREVERB_LFREFERENCE, props->flLFReference);
alEffectf (effect, AL_EAXREVERB_ROOM_ROLLOFF_FACTOR, props->flRoomRolloffFactor);
alEffecti (effect, AL_EAXREVERB_DECAY_HFLIMIT, (props->ulFlags&EAXLISTENERFLAGS_DECAYHFLIMIT) ? AL_TRUE : AL_FALSE);
}
void EFX_Set(ALuint effect, const EAXLISTENERPROPERTIES *props)
{
reAlEffecti(effect, AL_EFFECT_TYPE, AL_EFFECT_REVERB);
alEffecti(effect, AL_EFFECT_TYPE, AL_EFFECT_REVERB);
reAlEffectf(effect, AL_REVERB_DENSITY, clampF(powf(props->flEnvironmentSize, 3.0f) / 16.0f, 0.0f, 1.0f));
reAlEffectf(effect, AL_REVERB_DIFFUSION, props->flEnvironmentDiffusion);
reAlEffectf(effect, AL_REVERB_GAIN, mB_to_gain((float)props->lRoom));
reAlEffectf(effect, AL_REVERB_GAINHF, mB_to_gain((float)props->lRoomHF));
reAlEffectf(effect, AL_REVERB_DECAY_TIME, props->flDecayTime);
reAlEffectf(effect, AL_REVERB_DECAY_HFRATIO, props->flDecayHFRatio);
reAlEffectf(effect, AL_REVERB_REFLECTIONS_GAIN, clampF(mB_to_gain((float)props->lReflections), AL_EAXREVERB_MIN_REFLECTIONS_GAIN, AL_EAXREVERB_MAX_REFLECTIONS_GAIN));
reAlEffectf(effect, AL_REVERB_REFLECTIONS_DELAY, props->flReflectionsDelay);
reAlEffectf(effect, AL_REVERB_LATE_REVERB_GAIN, clampF(mB_to_gain((float)props->lReverb), AL_EAXREVERB_MIN_LATE_REVERB_GAIN, AL_EAXREVERB_MAX_LATE_REVERB_GAIN));
reAlEffectf(effect, AL_REVERB_LATE_REVERB_DELAY, props->flReverbDelay);
reAlEffectf(effect, AL_REVERB_AIR_ABSORPTION_GAINHF, clampF(mB_to_gain(props->flAirAbsorptionHF), AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF, AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF));
reAlEffectf(effect, AL_REVERB_ROOM_ROLLOFF_FACTOR, props->flRoomRolloffFactor);
reAlEffecti(effect, AL_REVERB_DECAY_HFLIMIT, (props->ulFlags&EAXLISTENERFLAGS_DECAYHFLIMIT) ? AL_TRUE : AL_FALSE);
alEffectf(effect, AL_REVERB_DENSITY, clampF(powf(props->flEnvironmentSize, 3.0f) / 16.0f, 0.0f, 1.0f));
alEffectf(effect, AL_REVERB_DIFFUSION, props->flEnvironmentDiffusion);
alEffectf(effect, AL_REVERB_GAIN, mB_to_gain((float)props->lRoom));
alEffectf(effect, AL_REVERB_GAINHF, mB_to_gain((float)props->lRoomHF));
alEffectf(effect, AL_REVERB_DECAY_TIME, props->flDecayTime);
alEffectf(effect, AL_REVERB_DECAY_HFRATIO, props->flDecayHFRatio);
alEffectf(effect, AL_REVERB_REFLECTIONS_GAIN, clampF(mB_to_gain((float)props->lReflections), AL_EAXREVERB_MIN_REFLECTIONS_GAIN, AL_EAXREVERB_MAX_REFLECTIONS_GAIN));
alEffectf(effect, AL_REVERB_REFLECTIONS_DELAY, props->flReflectionsDelay);
alEffectf(effect, AL_REVERB_LATE_REVERB_GAIN, clampF(mB_to_gain((float)props->lReverb), AL_EAXREVERB_MIN_LATE_REVERB_GAIN, AL_EAXREVERB_MAX_LATE_REVERB_GAIN));
alEffectf(effect, AL_REVERB_LATE_REVERB_DELAY, props->flReverbDelay);
alEffectf(effect, AL_REVERB_AIR_ABSORPTION_GAINHF, clampF(mB_to_gain(props->flAirAbsorptionHF), AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF, AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF));
alEffectf(effect, AL_REVERB_ROOM_ROLLOFF_FACTOR, props->flRoomRolloffFactor);
alEffecti(effect, AL_REVERB_DECAY_HFLIMIT, (props->ulFlags&EAXLISTENERFLAGS_DECAYHFLIMIT) ? AL_TRUE : AL_FALSE);
}
void EAX3_SetReverbMix(ALuint filter, float mix)
@ -163,9 +167,9 @@ void EAX3_SetReverbMix(ALuint filter, float mix)
float mb = mbvol;
float mbhf = mbvol;
reAlFilteri(filter, AL_FILTER_TYPE, AL_FILTER_LOWPASS);
reAlFilterf(filter, AL_LOWPASS_GAIN, mB_to_gain(Min(mb, 0.0f)));
reAlFilterf(filter, AL_LOWPASS_GAINHF, mB_to_gain(mbhf));
alFilteri(filter, AL_FILTER_TYPE, AL_FILTER_LOWPASS);
alFilterf(filter, AL_LOWPASS_GAIN, mB_to_gain(Min(mb, 0.0f)));
alFilterf(filter, AL_LOWPASS_GAINHF, mB_to_gain(mbhf));
}
#endif

View File

@ -11,37 +11,37 @@ void EFX_Set(ALuint effect, const EAXLISTENERPROPERTIES *props);
void EAX3_SetReverbMix(ALuint filter, float mix);
void SetEffectsLevel(ALuint uiFilter, float level);
extern LPALGENEFFECTS reAlGenEffects;
extern LPALDELETEEFFECTS reAlDeleteEffects;
extern LPALISEFFECT reAlIsEffect;
extern LPALEFFECTI reAlEffecti;
extern LPALEFFECTIV reAlEffectiv;
extern LPALEFFECTF reAlEffectf;
extern LPALEFFECTFV reAlEffectfv;
extern LPALGETEFFECTI reAlGetEffecti;
extern LPALGETEFFECTIV reAlGetEffectiv;
extern LPALGETEFFECTF reAlGetEffectf;
extern LPALGETEFFECTFV reAlGetEffectfv;
extern LPALGENAUXILIARYEFFECTSLOTS reAlGenAuxiliaryEffectSlots;
extern LPALDELETEAUXILIARYEFFECTSLOTS reAlDeleteAuxiliaryEffectSlots;
extern LPALISAUXILIARYEFFECTSLOT reAlIsAuxiliaryEffectSlot;
extern LPALAUXILIARYEFFECTSLOTI reAlAuxiliaryEffectSloti;
extern LPALAUXILIARYEFFECTSLOTIV reAlAuxiliaryEffectSlotiv;
extern LPALAUXILIARYEFFECTSLOTF reAlAuxiliaryEffectSlotf;
extern LPALAUXILIARYEFFECTSLOTFV reAlAuxiliaryEffectSlotfv;
extern LPALGETAUXILIARYEFFECTSLOTI reAlGetAuxiliaryEffectSloti;
extern LPALGETAUXILIARYEFFECTSLOTIV reAlGetAuxiliaryEffectSlotiv;
extern LPALGETAUXILIARYEFFECTSLOTF reAlGetAuxiliaryEffectSlotf;
extern LPALGETAUXILIARYEFFECTSLOTFV reAlGetAuxiliaryEffectSlotfv;
extern LPALGENFILTERS reAlGenFilters;
extern LPALDELETEFILTERS reAlDeleteFilters;
extern LPALISFILTER reAlIsFilter;
extern LPALFILTERI reAlFilteri;
extern LPALFILTERIV reAlFilteriv;
extern LPALFILTERF reAlFilterf;
extern LPALFILTERFV reAlFilterfv;
extern LPALGETFILTERI reAlGetFilteri;
extern LPALGETFILTERIV reAlGetFilteriv;
extern LPALGETFILTERF reAlGetFilterf;
extern LPALGETFILTERFV reAlGetFilterfv;
extern LPALGENEFFECTS alGenEffects;
extern LPALDELETEEFFECTS alDeleteEffects;
extern LPALISEFFECT alIsEffect;
extern LPALEFFECTI alEffecti;
extern LPALEFFECTIV alEffectiv;
extern LPALEFFECTF alEffectf;
extern LPALEFFECTFV alEffectfv;
extern LPALGETEFFECTI alGetEffecti;
extern LPALGETEFFECTIV alGetEffectiv;
extern LPALGETEFFECTF alGetEffectf;
extern LPALGETEFFECTFV alGetEffectfv;
extern LPALGENAUXILIARYEFFECTSLOTS alGenAuxiliaryEffectSlots;
extern LPALDELETEAUXILIARYEFFECTSLOTS alDeleteAuxiliaryEffectSlots;
extern LPALISAUXILIARYEFFECTSLOT alIsAuxiliaryEffectSlot;
extern LPALAUXILIARYEFFECTSLOTI alAuxiliaryEffectSloti;
extern LPALAUXILIARYEFFECTSLOTIV alAuxiliaryEffectSlotiv;
extern LPALAUXILIARYEFFECTSLOTF alAuxiliaryEffectSlotf;
extern LPALAUXILIARYEFFECTSLOTFV alAuxiliaryEffectSlotfv;
extern LPALGETAUXILIARYEFFECTSLOTI alGetAuxiliaryEffectSloti;
extern LPALGETAUXILIARYEFFECTSLOTIV alGetAuxiliaryEffectSlotiv;
extern LPALGETAUXILIARYEFFECTSLOTF alGetAuxiliaryEffectSlotf;
extern LPALGETAUXILIARYEFFECTSLOTFV alGetAuxiliaryEffectSlotfv;
extern LPALGENFILTERS alGenFilters;
extern LPALDELETEFILTERS alDeleteFilters;
extern LPALISFILTER alIsFilter;
extern LPALFILTERI alFilteri;
extern LPALFILTERIV alFilteriv;
extern LPALFILTERF alFilterf;
extern LPALFILTERFV alFilterfv;
extern LPALGETFILTERI alGetFilteri;
extern LPALGETFILTERIV alGetFilteriv;
extern LPALGETFILTERF alGetFilterf;
extern LPALGETFILTERFV alGetFilterfv;
#endif

View File

@ -107,7 +107,11 @@ enum
#define MAX_STREAMS 2
#ifndef __WIIU__
#define DIGITALRATE 32000
#else
#define DIGITALRATE 44100
#endif
#define DIGITALBITS 16
#define DIGITALCHANNELS 2

View File

@ -229,18 +229,18 @@ release_existing()
if ( IsFXSupported() )
{
if ( reAlIsEffect(ALEffect) )
if ( alIsEffect(ALEffect) )
{
reAlEffecti(ALEffect, AL_EFFECT_TYPE, AL_EFFECT_NULL);
reAlDeleteEffects(1, &ALEffect);
alEffecti(ALEffect, AL_EFFECT_TYPE, AL_EFFECT_NULL);
alDeleteEffects(1, &ALEffect);
ALEffect = AL_EFFECT_NULL;
}
if (reAlIsAuxiliaryEffectSlot(ALEffectSlot))
if (alIsAuxiliaryEffectSlot(ALEffectSlot))
{
reAlAuxiliaryEffectSloti(ALEffectSlot, AL_EFFECTSLOT_EFFECT, AL_EFFECT_NULL);
alAuxiliaryEffectSloti(ALEffectSlot, AL_EFFECTSLOT_EFFECT, AL_EFFECT_NULL);
reAlDeleteAuxiliaryEffectSlots(1, &ALEffectSlot);
alDeleteAuxiliaryEffectSlots(1, &ALEffectSlot);
ALEffectSlot = AL_EFFECTSLOT_NULL;
}
}
@ -325,11 +325,13 @@ set_new_provider(int index)
alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED);
#ifndef __WIIU__
if ( alcIsExtensionPresent(ALDevice, (ALCchar*)ALC_EXT_EFX_NAME) )
{
reAlGenAuxiliaryEffectSlots(1, &ALEffectSlot);
reAlGenEffects(1, &ALEffect);
alGenAuxiliaryEffectSlots(1, &ALEffectSlot);
alGenEffects(1, &ALEffect);
}
#endif
for ( int32 i = 0; i < MAX_STREAMS; i++ )
{
@ -351,7 +353,8 @@ set_new_provider(int index)
usingEAX = 0;
usingEAX3 = 0;
_usingEFX = false;
#ifndef __WIIU__
if ( !strcmp(&providers[index].name[strlen(providers[index].name) - strlen(" EAX3")], " EAX3")
&& alcIsExtensionPresent(ALDevice, (ALCchar*)ALC_EXT_EFX_NAME) )
{
@ -377,6 +380,7 @@ set_new_provider(int index)
DEV("EFX\n");
}
}
#endif
//SampleManager.SetSpeakerConfig(speaker_type);
@ -387,7 +391,7 @@ set_new_provider(int index)
if ( IsFXSupported() )
{
/**/
reAlAuxiliaryEffectSloti(ALEffectSlot, AL_EFFECTSLOT_EFFECT, ALEffect);
alAuxiliaryEffectSloti(ALEffectSlot, AL_EFFECTSLOT_EFFECT, ALEffect);
/**/
for ( int32 i = 0; i < MAXCHANNELS; i++ )
@ -899,6 +903,13 @@ cSampleManager::LoadPedComment(uint32 nComment)
#endif
nPedSlotSfx[nCurrentPedSlot] = nComment;
#ifdef BIGENDIAN
void* data = (void *)(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE*nCurrentPedSlot);
for (int i = 0; i < m_aSamples[nComment].nSize/sizeof(uint16); i++) {
((uint16*)data)[i] = BSWAP16(((uint16*)data)[i]);
}
#endif
alBufferData(pedBuffers[nCurrentPedSlot],
AL_FORMAT_MONO16,
(void *)(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE*nCurrentPedSlot),
@ -1025,7 +1036,7 @@ cSampleManager::SetChannelReverbFlag(uint32 nChannel, uint8 nReverbFlag)
{
if ( IsFXSupported() )
{
reAlAuxiliaryEffectSloti(ALEffectSlot, AL_EFFECTSLOT_EFFECT, ALEffect);
alAuxiliaryEffectSloti(ALEffectSlot, AL_EFFECTSLOT_EFFECT, ALEffect);
if ( nReverbFlag != 0 )
aChannel[nChannel].SetReverbMix(ALEffectSlot, _fEffectsLevel);
@ -1048,18 +1059,27 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
return false;
uintptr addr = nSampleBankMemoryStartAddress[nBank] + m_aSamples[nSfx].nOffset - m_aSamples[BankStartOffset[nBank]].nOffset;
#ifdef BIGENDIAN
for (int i = 0; i < m_aSamples[nSfx].nSize / sizeof(uint16); i++)
((uint16*)addr)[i] = BSWAP16(((uint16*)addr)[i]);
#endif
if ( ALBuffers[nSfx].IsEmpty() )
{
#ifdef BIGENDIAN
void* swapBuf = malloc(m_aSamples[nSfx].nSize);
memcpy(swapBuf, (void*)addr, m_aSamples[nSfx].nSize);
for (int i = 0; i < m_aSamples[nSfx].nSize / sizeof(uint16); i++) {
((uint16*)swapBuf)[i] = BSWAP16(((uint16*)swapBuf)[i]);
}
#else
void* swapBuf = (void *)addr;
#endif
ALuint buf;
alGenBuffers(1, &buf);
alBufferData(buf, AL_FORMAT_MONO16, (void *)addr, m_aSamples[nSfx].nSize, m_aSamples[nSfx].nFrequency);
alBufferData(buf, AL_FORMAT_MONO16, swapBuf, m_aSamples[nSfx].nSize, m_aSamples[nSfx].nFrequency);
ALBuffers[nSfx].Set(buf);
#ifdef BIGENDIAN
free(swapBuf);
#endif
}
ALBuffers[nSfx].Wait();