Commit 681f04c3 authored by Alexandre Julliard's avatar Alexandre Julliard

faudio: Import upstream release 23.07.

parent 959dea0c
...@@ -239,6 +239,14 @@ typedef struct FAudioFilterParameters ...@@ -239,6 +239,14 @@ typedef struct FAudioFilterParameters
float OneOverQ; /* [0, FAUDIO_MAX_FILTER_ONEOVERQ] */ float OneOverQ; /* [0, FAUDIO_MAX_FILTER_ONEOVERQ] */
} FAudioFilterParameters; } FAudioFilterParameters;
typedef struct FAudioFilterParametersEXT
{
FAudioFilterType Type;
float Frequency; /* [0, FAUDIO_MAX_FILTER_FREQUENCY] */
float OneOverQ; /* [0, FAUDIO_MAX_FILTER_ONEOVERQ] */
float WetDryMix; /* [0, 1] */
} FAudioFilterParametersEXT;
typedef struct FAudioBuffer typedef struct FAudioBuffer
{ {
/* Either 0 or FAUDIO_END_OF_STREAM */ /* Either 0 or FAUDIO_END_OF_STREAM */
...@@ -375,6 +383,7 @@ typedef struct FAudioXMA2WaveFormatEx ...@@ -375,6 +383,7 @@ typedef struct FAudioXMA2WaveFormatEx
#define FAUDIO_DEFAULT_FILTER_TYPE FAudioLowPassFilter #define FAUDIO_DEFAULT_FILTER_TYPE FAudioLowPassFilter
#define FAUDIO_DEFAULT_FILTER_FREQUENCY FAUDIO_MAX_FILTER_FREQUENCY #define FAUDIO_DEFAULT_FILTER_FREQUENCY FAUDIO_MAX_FILTER_FREQUENCY
#define FAUDIO_DEFAULT_FILTER_ONEOVERQ 1.0f #define FAUDIO_DEFAULT_FILTER_ONEOVERQ 1.0f
#define FAUDIO_DEFAULT_FILTER_WETDRYMIX_EXT 1.0f
#define FAUDIO_LOG_ERRORS 0x0001 #define FAUDIO_LOG_ERRORS 0x0001
#define FAUDIO_LOG_WARNINGS 0x0002 #define FAUDIO_LOG_WARNINGS 0x0002
...@@ -485,7 +494,7 @@ extern FAudioGUID DATAFORMAT_SUBTYPE_IEEE_FLOAT; ...@@ -485,7 +494,7 @@ extern FAudioGUID DATAFORMAT_SUBTYPE_IEEE_FLOAT;
#define FAUDIO_ABI_VERSION 0 #define FAUDIO_ABI_VERSION 0
#define FAUDIO_MAJOR_VERSION 23 #define FAUDIO_MAJOR_VERSION 23
#define FAUDIO_MINOR_VERSION 3 #define FAUDIO_MINOR_VERSION 7
#define FAUDIO_PATCH_VERSION 0 #define FAUDIO_PATCH_VERSION 0
#define FAUDIO_COMPILED_VERSION ( \ #define FAUDIO_COMPILED_VERSION ( \
...@@ -909,6 +918,58 @@ FAUDIOAPI void FAudioVoice_GetOutputFilterParameters( ...@@ -909,6 +918,58 @@ FAUDIOAPI void FAudioVoice_GetOutputFilterParameters(
FAudioFilterParameters *pParameters FAudioFilterParameters *pParameters
); );
/* Sets the filter variables for a voice.
* This is only valid on voices with the USEFILTER flag.
*
* pParameters: See FAudioFilterParametersEXT for details.
* OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
*
* Returns 0 on success.
*/
FAUDIOAPI uint32_t FAudioVoice_SetFilterParametersEXT(
FAudioVoice* voice,
const FAudioFilterParametersEXT* pParameters,
uint32_t OperationSet
);
/* Requests the filter variables for a voice.
* This is only valid on voices with the USEFILTER flag.
*
* pParameters: See FAudioFilterParametersEXT for details.
*/
FAUDIOAPI void FAudioVoice_GetFilterParametersEXT(
FAudioVoice* voice,
FAudioFilterParametersEXT* pParameters
);
/* Sets the filter variables for a voice's output voice.
* This is only valid on sends with the USEFILTER flag.
*
* pDestinationVoice: An output voice from the voice's send list.
* pParameters: See FAudioFilterParametersEXT for details.
* OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
*
* Returns 0 on success.
*/
FAUDIOAPI uint32_t FAudioVoice_SetOutputFilterParametersEXT(
FAudioVoice* voice,
FAudioVoice* pDestinationVoice,
const FAudioFilterParametersEXT* pParameters,
uint32_t OperationSet
);
/* Requests the filter variables for a voice's output voice.
* This is only valid on sends with the USEFILTER flag.
*
* pDestinationVoice: An output voice from the voice's send list.
* pParameters: See FAudioFilterParametersEXT for details.
*/
FAUDIOAPI void FAudioVoice_GetOutputFilterParametersEXT(
FAudioVoice* voice,
FAudioVoice* pDestinationVoice,
FAudioFilterParametersEXT* pParameters
);
/* Sets the global volume of a voice. /* Sets the global volume of a voice.
* *
* Volume: Amplitude ratio. 1.0f is default, 0.0f is silence. * Volume: Amplitude ratio. 1.0f is default, 0.0f is silence.
......
...@@ -732,6 +732,7 @@ uint32_t FACTAudioEngine_RegisterNotification( ...@@ -732,6 +732,7 @@ uint32_t FACTAudioEngine_RegisterNotification(
/* WaveBanks */ /* WaveBanks */
#define PERSIST_ACTION pEngine->wb_context = pNotificationDescription->pvContext; #define PERSIST_ACTION pEngine->wb_context = pNotificationDescription->pvContext;
else HANDLE_PERSIST(WAVEBANKPREPARED) else HANDLE_PERSIST(WAVEBANKPREPARED)
else HANDLE_PERSIST(WAVEBANKSTREAMING_INVALIDCONTENT)
#undef PERSIST_ACTION #undef PERSIST_ACTION
/* Anything else? */ /* Anything else? */
...@@ -855,6 +856,7 @@ uint32_t FACTAudioEngine_UnRegisterNotification( ...@@ -855,6 +856,7 @@ uint32_t FACTAudioEngine_UnRegisterNotification(
/* WaveBanks */ /* WaveBanks */
#define PERSIST_ACTION pEngine->wb_context = pNotificationDescription->pvContext; #define PERSIST_ACTION pEngine->wb_context = pNotificationDescription->pvContext;
else HANDLE_PERSIST(WAVEBANKPREPARED) else HANDLE_PERSIST(WAVEBANKPREPARED)
else HANDLE_PERSIST(WAVEBANKSTREAMING_INVALIDCONTENT)
#undef PERSIST_ACTION #undef PERSIST_ACTION
/* Anything else? */ /* Anything else? */
......
...@@ -2616,6 +2616,7 @@ uint32_t FACT_INTERNAL_ParseSoundBank( ...@@ -2616,6 +2616,7 @@ uint32_t FACT_INTERNAL_ParseSoundBank(
/* WaveBank Name data */ /* WaveBank Name data */
FAudio_assert((ptr - start) == wavebankNameOffset); FAudio_assert((ptr - start) == wavebankNameOffset);
ptr = start + wavebankNameOffset;
sb->wavebankNames = (char**) pEngine->pMalloc( sb->wavebankNames = (char**) pEngine->pMalloc(
sizeof(char*) * sizeof(char*) *
sb->wavebankCount sb->wavebankCount
...@@ -2818,45 +2819,55 @@ uint32_t FACT_INTERNAL_ParseSoundBank( ...@@ -2818,45 +2819,55 @@ uint32_t FACT_INTERNAL_ParseSoundBank(
/* Simple Cue data */ /* Simple Cue data */
FAudio_assert(cueSimpleCount == 0 || (ptr - start) == cueSimpleOffset); FAudio_assert(cueSimpleCount == 0 || (ptr - start) == cueSimpleOffset);
for (i = 0; i < cueSimpleCount; i += 1, cur += 1) if (cueSimpleCount > 0)
{ {
sb->cues[cur].flags = read_u8(&ptr); ptr = start + cueSimpleOffset;
sb->cues[cur].sbCode = read_u32(&ptr, se);
sb->cues[cur].transitionOffset = 0; for (i = 0; i < cueSimpleCount; i += 1, cur += 1)
sb->cues[cur].instanceLimit = 0xFF; {
sb->cues[cur].fadeInMS = 0; sb->cues[cur].flags = read_u8(&ptr);
sb->cues[cur].fadeOutMS = 0; sb->cues[cur].sbCode = read_u32(&ptr, se);
sb->cues[cur].maxInstanceBehavior = 0; sb->cues[cur].transitionOffset = 0;
sb->cues[cur].instanceCount = 0; sb->cues[cur].instanceLimit = 0xFF;
sb->cues[cur].fadeInMS = 0;
sb->cues[cur].fadeOutMS = 0;
sb->cues[cur].maxInstanceBehavior = 0;
sb->cues[cur].instanceCount = 0;
}
} }
/* Complex Cue data */ /* Complex Cue data */
FAudio_assert(cueComplexCount == 0 || (ptr - start) == cueComplexOffset); FAudio_assert(cueComplexCount == 0 || (ptr - start) == cueComplexOffset);
for (i = 0; i < cueComplexCount; i += 1, cur += 1) if (cueComplexCount > 0)
{ {
sb->cues[cur].flags = read_u8(&ptr); ptr = start + cueComplexOffset;
sb->cues[cur].sbCode = read_u32(&ptr, se);
sb->cues[cur].transitionOffset = read_u32(&ptr, se);
if (sb->cues[cur].transitionOffset == 0xFFFFFFFF)
{
/* FIXME: Why */
sb->cues[cur].transitionOffset = 0;
}
sb->cues[cur].instanceLimit = read_u8(&ptr);
sb->cues[cur].fadeInMS = read_u16(&ptr, se);
sb->cues[cur].fadeOutMS = read_u16(&ptr, se);
sb->cues[cur].maxInstanceBehavior = read_u8(&ptr) >> 3;
sb->cues[cur].instanceCount = 0;
if (!(sb->cues[cur].flags & 0x04)) for (i = 0; i < cueComplexCount; i += 1, cur += 1)
{
/* FIXME: Is this the only way to get this...? */
sb->variationCount += 1;
}
if (sb->cues[cur].transitionOffset > 0)
{ {
/* FIXME: Is this the only way to get this...? */ sb->cues[cur].flags = read_u8(&ptr);
sb->transitionCount += 1; sb->cues[cur].sbCode = read_u32(&ptr, se);
sb->cues[cur].transitionOffset = read_u32(&ptr, se);
if (sb->cues[cur].transitionOffset == 0xFFFFFFFF)
{
/* FIXME: Why */
sb->cues[cur].transitionOffset = 0;
}
sb->cues[cur].instanceLimit = read_u8(&ptr);
sb->cues[cur].fadeInMS = read_u16(&ptr, se);
sb->cues[cur].fadeOutMS = read_u16(&ptr, se);
sb->cues[cur].maxInstanceBehavior = read_u8(&ptr) >> 3;
sb->cues[cur].instanceCount = 0;
if (!(sb->cues[cur].flags & 0x04))
{
/* FIXME: Is this the only way to get this...? */
sb->variationCount += 1;
}
if (sb->cues[cur].transitionOffset > 0)
{
/* FIXME: Is this the only way to get this...? */
sb->transitionCount += 1;
}
} }
} }
...@@ -2864,6 +2875,7 @@ uint32_t FACT_INTERNAL_ParseSoundBank( ...@@ -2864,6 +2875,7 @@ uint32_t FACT_INTERNAL_ParseSoundBank(
if (sb->variationCount > 0) if (sb->variationCount > 0)
{ {
FAudio_assert((ptr - start) == variationOffset); FAudio_assert((ptr - start) == variationOffset);
ptr = start + variationOffset;
sb->variations = (FACTVariationTable*) pEngine->pMalloc( sb->variations = (FACTVariationTable*) pEngine->pMalloc(
sizeof(FACTVariationTable) * sizeof(FACTVariationTable) *
sb->variationCount sb->variationCount
...@@ -2949,6 +2961,7 @@ uint32_t FACT_INTERNAL_ParseSoundBank( ...@@ -2949,6 +2961,7 @@ uint32_t FACT_INTERNAL_ParseSoundBank(
if (sb->transitionCount > 0) if (sb->transitionCount > 0)
{ {
FAudio_assert((ptr - start) == transitionOffset); FAudio_assert((ptr - start) == transitionOffset);
ptr = start + transitionOffset;
sb->transitions = (FACTTransitionTable*) pEngine->pMalloc( sb->transitions = (FACTTransitionTable*) pEngine->pMalloc(
sizeof(FACTTransitionTable) * sizeof(FACTTransitionTable) *
sb->transitionCount sb->transitionCount
...@@ -2996,6 +3009,7 @@ uint32_t FACT_INTERNAL_ParseSoundBank( ...@@ -2996,6 +3009,7 @@ uint32_t FACT_INTERNAL_ParseSoundBank(
if (cueNameIndexOffset != -1) if (cueNameIndexOffset != -1)
{ {
FAudio_assert((ptr - start) == cueNameIndexOffset); FAudio_assert((ptr - start) == cueNameIndexOffset);
ptr = start + cueNameIndexOffset;
ptr += 6 * sb->cueCount; /* FIXME: index as assert value? */ ptr += 6 * sb->cueCount; /* FIXME: index as assert value? */
} }
...@@ -3003,6 +3017,7 @@ uint32_t FACT_INTERNAL_ParseSoundBank( ...@@ -3003,6 +3017,7 @@ uint32_t FACT_INTERNAL_ParseSoundBank(
if (cueNameOffset != -1) if (cueNameOffset != -1)
{ {
FAudio_assert((ptr - start) == cueNameOffset); FAudio_assert((ptr - start) == cueNameOffset);
ptr = start + cueNameOffset;
sb->cueNames = (char**) pEngine->pMalloc( sb->cueNames = (char**) pEngine->pMalloc(
sizeof(char*) * sizeof(char*) *
sb->cueCount sb->cueCount
......
...@@ -111,7 +111,8 @@ typedef enum FACTNoticationsFlags ...@@ -111,7 +111,8 @@ typedef enum FACTNoticationsFlags
NOTIFY_WAVESTOP = 0x00002000, NOTIFY_WAVESTOP = 0x00002000,
NOTIFY_WAVELOOPED = 0x00004000, NOTIFY_WAVELOOPED = 0x00004000,
NOTIFY_WAVEDESTROY = 0x00008000, NOTIFY_WAVEDESTROY = 0x00008000,
NOTIFY_WAVEBANKPREPARED = 0x00010000 NOTIFY_WAVEBANKPREPARED = 0x00010000,
NOTIFY_WAVEBANKSTREAMING_INVALIDCONTENT = 0x00020000
} FACTNoticationsFlags; } FACTNoticationsFlags;
/* Internal SoundBank Types */ /* Internal SoundBank Types */
......
...@@ -278,6 +278,7 @@ uint32_t FAudio_CreateSourceVoice( ...@@ -278,6 +278,7 @@ uint32_t FAudio_CreateSourceVoice(
(*ppSourceVoice)->filter.Type = FAUDIO_DEFAULT_FILTER_TYPE; (*ppSourceVoice)->filter.Type = FAUDIO_DEFAULT_FILTER_TYPE;
(*ppSourceVoice)->filter.Frequency = FAUDIO_DEFAULT_FILTER_FREQUENCY; (*ppSourceVoice)->filter.Frequency = FAUDIO_DEFAULT_FILTER_FREQUENCY;
(*ppSourceVoice)->filter.OneOverQ = FAUDIO_DEFAULT_FILTER_ONEOVERQ; (*ppSourceVoice)->filter.OneOverQ = FAUDIO_DEFAULT_FILTER_ONEOVERQ;
(*ppSourceVoice)->filter.WetDryMix = FAUDIO_DEFAULT_FILTER_WETDRYMIX_EXT;
(*ppSourceVoice)->sendLock = FAudio_PlatformCreateMutex(); (*ppSourceVoice)->sendLock = FAudio_PlatformCreateMutex();
LOG_MUTEX_CREATE(audio, (*ppSourceVoice)->sendLock) LOG_MUTEX_CREATE(audio, (*ppSourceVoice)->sendLock)
(*ppSourceVoice)->effectLock = FAudio_PlatformCreateMutex(); (*ppSourceVoice)->effectLock = FAudio_PlatformCreateMutex();
...@@ -586,6 +587,7 @@ uint32_t FAudio_CreateSubmixVoice( ...@@ -586,6 +587,7 @@ uint32_t FAudio_CreateSubmixVoice(
(*ppSubmixVoice)->filter.Type = FAUDIO_DEFAULT_FILTER_TYPE; (*ppSubmixVoice)->filter.Type = FAUDIO_DEFAULT_FILTER_TYPE;
(*ppSubmixVoice)->filter.Frequency = FAUDIO_DEFAULT_FILTER_FREQUENCY; (*ppSubmixVoice)->filter.Frequency = FAUDIO_DEFAULT_FILTER_FREQUENCY;
(*ppSubmixVoice)->filter.OneOverQ = FAUDIO_DEFAULT_FILTER_ONEOVERQ; (*ppSubmixVoice)->filter.OneOverQ = FAUDIO_DEFAULT_FILTER_ONEOVERQ;
(*ppSubmixVoice)->filter.WetDryMix = FAUDIO_DEFAULT_FILTER_WETDRYMIX_EXT;
(*ppSubmixVoice)->sendLock = FAudio_PlatformCreateMutex(); (*ppSubmixVoice)->sendLock = FAudio_PlatformCreateMutex();
LOG_MUTEX_CREATE(audio, (*ppSubmixVoice)->sendLock) LOG_MUTEX_CREATE(audio, (*ppSubmixVoice)->sendLock)
(*ppSubmixVoice)->effectLock = FAudio_PlatformCreateMutex(); (*ppSubmixVoice)->effectLock = FAudio_PlatformCreateMutex();
...@@ -1296,8 +1298,8 @@ uint32_t FAudioVoice_SetOutputVoices( ...@@ -1296,8 +1298,8 @@ uint32_t FAudioVoice_SetOutputVoices(
/* Allocate the whole send filter array if needed... */ /* Allocate the whole send filter array if needed... */
if (voice->sendFilter == NULL) if (voice->sendFilter == NULL)
{ {
voice->sendFilter = (FAudioFilterParameters*) voice->audio->pMalloc( voice->sendFilter = (FAudioFilterParametersEXT*) voice->audio->pMalloc(
sizeof(FAudioFilterParameters) * pSendList->SendCount sizeof(FAudioFilterParametersEXT) * pSendList->SendCount
); );
} }
if (voice->sendFilterState == NULL) if (voice->sendFilterState == NULL)
...@@ -1315,6 +1317,7 @@ uint32_t FAudioVoice_SetOutputVoices( ...@@ -1315,6 +1317,7 @@ uint32_t FAudioVoice_SetOutputVoices(
voice->sendFilter[i].Type = FAUDIO_DEFAULT_FILTER_TYPE; voice->sendFilter[i].Type = FAUDIO_DEFAULT_FILTER_TYPE;
voice->sendFilter[i].Frequency = FAUDIO_DEFAULT_FILTER_FREQUENCY; voice->sendFilter[i].Frequency = FAUDIO_DEFAULT_FILTER_FREQUENCY;
voice->sendFilter[i].OneOverQ = FAUDIO_DEFAULT_FILTER_ONEOVERQ; voice->sendFilter[i].OneOverQ = FAUDIO_DEFAULT_FILTER_ONEOVERQ;
voice->sendFilter[i].WetDryMix = FAUDIO_DEFAULT_FILTER_WETDRYMIX_EXT;
voice->sendFilterState[i] = (FAudioFilterState*) voice->audio->pMalloc( voice->sendFilterState[i] = (FAudioFilterState*) voice->audio->pMalloc(
sizeof(FAudioFilterState) * outChannels sizeof(FAudioFilterState) * outChannels
); );
...@@ -1640,9 +1643,9 @@ uint32_t FAudioVoice_GetEffectParameters( ...@@ -1640,9 +1643,9 @@ uint32_t FAudioVoice_GetEffectParameters(
return 0; return 0;
} }
uint32_t FAudioVoice_SetFilterParameters( uint32_t FAudioVoice_SetFilterParametersEXT(
FAudioVoice *voice, FAudioVoice *voice,
const FAudioFilterParameters *pParameters, const FAudioFilterParametersEXT *pParameters,
uint32_t OperationSet uint32_t OperationSet
) { ) {
LOG_API_ENTER(voice->audio) LOG_API_ENTER(voice->audio)
...@@ -1678,7 +1681,7 @@ uint32_t FAudioVoice_SetFilterParameters( ...@@ -1678,7 +1681,7 @@ uint32_t FAudioVoice_SetFilterParameters(
FAudio_memcpy( FAudio_memcpy(
&voice->filter, &voice->filter,
pParameters, pParameters,
sizeof(FAudioFilterParameters) sizeof(FAudioFilterParametersEXT)
); );
FAudio_PlatformUnlockMutex(voice->filterLock); FAudio_PlatformUnlockMutex(voice->filterLock);
LOG_MUTEX_UNLOCK(voice->audio, voice->filterLock) LOG_MUTEX_UNLOCK(voice->audio, voice->filterLock)
...@@ -1687,9 +1690,23 @@ uint32_t FAudioVoice_SetFilterParameters( ...@@ -1687,9 +1690,23 @@ uint32_t FAudioVoice_SetFilterParameters(
return 0; return 0;
} }
void FAudioVoice_GetFilterParameters( uint32_t FAudioVoice_SetFilterParameters(
FAudioVoice* voice,
const FAudioFilterParameters* pParameters,
uint32_t OperationSet
) {
FAudioFilterParametersEXT ext_parameters;
ext_parameters.Type = pParameters->Type;
ext_parameters.OneOverQ = pParameters->OneOverQ;
ext_parameters.Frequency = pParameters->Frequency;
ext_parameters.WetDryMix = FAUDIO_DEFAULT_FILTER_WETDRYMIX_EXT;
return FAudioVoice_SetFilterParametersEXT(voice, &ext_parameters, OperationSet);
}
void FAudioVoice_GetFilterParametersEXT(
FAudioVoice *voice, FAudioVoice *voice,
FAudioFilterParameters *pParameters FAudioFilterParametersEXT *pParameters
) { ) {
LOG_API_ENTER(voice->audio) LOG_API_ENTER(voice->audio)
...@@ -1713,17 +1730,34 @@ void FAudioVoice_GetFilterParameters( ...@@ -1713,17 +1730,34 @@ void FAudioVoice_GetFilterParameters(
FAudio_memcpy( FAudio_memcpy(
pParameters, pParameters,
&voice->filter, &voice->filter,
sizeof(FAudioFilterParameters) sizeof(FAudioFilterParametersEXT)
); );
FAudio_PlatformUnlockMutex(voice->filterLock); FAudio_PlatformUnlockMutex(voice->filterLock);
LOG_MUTEX_UNLOCK(voice->audio, voice->filterLock) LOG_MUTEX_UNLOCK(voice->audio, voice->filterLock)
LOG_API_EXIT(voice->audio) LOG_API_EXIT(voice->audio)
} }
uint32_t FAudioVoice_SetOutputFilterParameters( void FAudioVoice_GetFilterParameters(
FAudioVoice* voice,
FAudioFilterParameters* pParameters
) {
FAudioFilterParametersEXT ext_parameters;
ext_parameters.Type = pParameters->Type;
ext_parameters.OneOverQ = pParameters->OneOverQ;
ext_parameters.Frequency = pParameters->Frequency;
ext_parameters.WetDryMix = FAUDIO_DEFAULT_FILTER_WETDRYMIX_EXT;
FAudioVoice_GetFilterParametersEXT(voice, &ext_parameters);
pParameters->Type = ext_parameters.Type;
pParameters->Frequency = ext_parameters.Frequency;
pParameters->OneOverQ = ext_parameters.OneOverQ;
}
uint32_t FAudioVoice_SetOutputFilterParametersEXT(
FAudioVoice *voice, FAudioVoice *voice,
FAudioVoice *pDestinationVoice, FAudioVoice *pDestinationVoice,
const FAudioFilterParameters *pParameters, const FAudioFilterParametersEXT *pParameters,
uint32_t OperationSet uint32_t OperationSet
) { ) {
uint32_t i; uint32_t i;
...@@ -1791,7 +1825,7 @@ uint32_t FAudioVoice_SetOutputFilterParameters( ...@@ -1791,7 +1825,7 @@ uint32_t FAudioVoice_SetOutputFilterParameters(
FAudio_memcpy( FAudio_memcpy(
&voice->sendFilter[i], &voice->sendFilter[i],
pParameters, pParameters,
sizeof(FAudioFilterParameters) sizeof(FAudioFilterParametersEXT)
); );
FAudio_PlatformUnlockMutex(voice->sendLock); FAudio_PlatformUnlockMutex(voice->sendLock);
...@@ -1800,10 +1834,25 @@ uint32_t FAudioVoice_SetOutputFilterParameters( ...@@ -1800,10 +1834,25 @@ uint32_t FAudioVoice_SetOutputFilterParameters(
return 0; return 0;
} }
void FAudioVoice_GetOutputFilterParameters( uint32_t FAudioVoice_SetOutputFilterParameters(
FAudioVoice* voice,
FAudioVoice* pDestinationVoice,
const FAudioFilterParameters* pParameters,
uint32_t OperationSet
) {
FAudioFilterParametersEXT ext_parameters;
ext_parameters.Type = pParameters->Type;
ext_parameters.OneOverQ = pParameters->OneOverQ;
ext_parameters.Frequency = pParameters->Frequency;
ext_parameters.WetDryMix = FAUDIO_DEFAULT_FILTER_WETDRYMIX_EXT;
return FAudioVoice_SetOutputFilterParametersEXT(voice, pDestinationVoice, &ext_parameters, OperationSet);
}
void FAudioVoice_GetOutputFilterParametersEXT(
FAudioVoice *voice, FAudioVoice *voice,
FAudioVoice *pDestinationVoice, FAudioVoice *pDestinationVoice,
FAudioFilterParameters *pParameters FAudioFilterParametersEXT *pParameters
) { ) {
uint32_t i; uint32_t i;
...@@ -1859,7 +1908,7 @@ void FAudioVoice_GetOutputFilterParameters( ...@@ -1859,7 +1908,7 @@ void FAudioVoice_GetOutputFilterParameters(
FAudio_memcpy( FAudio_memcpy(
pParameters, pParameters,
&voice->sendFilter[i], &voice->sendFilter[i],
sizeof(FAudioFilterParameters) sizeof(FAudioFilterParametersEXT)
); );
FAudio_PlatformUnlockMutex(voice->sendLock); FAudio_PlatformUnlockMutex(voice->sendLock);
...@@ -1914,6 +1963,24 @@ uint32_t FAudioVoice_SetVolume( ...@@ -1914,6 +1963,24 @@ uint32_t FAudioVoice_SetVolume(
return 0; return 0;
} }
void FAudioVoice_GetOutputFilterParameters(
FAudioVoice* voice,
FAudioVoice* pDestinationVoice,
FAudioFilterParameters* pParameters
) {
FAudioFilterParametersEXT ext_parameters;
ext_parameters.Type = pParameters->Type;
ext_parameters.OneOverQ = pParameters->OneOverQ;
ext_parameters.Frequency = pParameters->Frequency;
ext_parameters.WetDryMix = FAUDIO_DEFAULT_FILTER_WETDRYMIX_EXT;
FAudioVoice_GetOutputFilterParametersEXT(voice, pDestinationVoice, &ext_parameters);
pParameters->Type = ext_parameters.Type;
pParameters->Frequency = ext_parameters.Frequency;
pParameters->OneOverQ = ext_parameters.OneOverQ;
}
void FAudioVoice_GetVolume( void FAudioVoice_GetVolume(
FAudioVoice *voice, FAudioVoice *voice,
float *pVolume float *pVolume
......
...@@ -598,7 +598,7 @@ static void FAudio_INTERNAL_DecodeBuffers( ...@@ -598,7 +598,7 @@ static void FAudio_INTERNAL_DecodeBuffers(
static inline void FAudio_INTERNAL_FilterVoice( static inline void FAudio_INTERNAL_FilterVoice(
FAudio *audio, FAudio *audio,
const FAudioFilterParameters *filter, const FAudioFilterParametersEXT *filter,
FAudioFilterState *filterState, FAudioFilterState *filterState,
float *samples, float *samples,
uint32_t numSamples, uint32_t numSamples,
...@@ -630,7 +630,7 @@ static inline void FAudio_INTERNAL_FilterVoice( ...@@ -630,7 +630,7 @@ static inline void FAudio_INTERNAL_FilterVoice(
filterState[ci][FAudioHighPassFilter] = samples[j * numChannels + ci] - filterState[ci][FAudioLowPassFilter] - (filter->OneOverQ * filterState[ci][FAudioBandPassFilter]); filterState[ci][FAudioHighPassFilter] = samples[j * numChannels + ci] - filterState[ci][FAudioLowPassFilter] - (filter->OneOverQ * filterState[ci][FAudioBandPassFilter]);
filterState[ci][FAudioBandPassFilter] = (filter->Frequency * filterState[ci][FAudioHighPassFilter]) + filterState[ci][FAudioBandPassFilter]; filterState[ci][FAudioBandPassFilter] = (filter->Frequency * filterState[ci][FAudioHighPassFilter]) + filterState[ci][FAudioBandPassFilter];
filterState[ci][FAudioNotchFilter] = filterState[ci][FAudioHighPassFilter] + filterState[ci][FAudioLowPassFilter]; filterState[ci][FAudioNotchFilter] = filterState[ci][FAudioHighPassFilter] + filterState[ci][FAudioLowPassFilter];
samples[j * numChannels + ci] = filterState[ci][filter->Type]; samples[j * numChannels + ci] = filterState[ci][filter->Type] * filter->WetDryMix + samples[j * numChannels + ci] * (1.0 - filter->WetDryMix);
} }
LOG_FUNC_EXIT(audio) LOG_FUNC_EXIT(audio)
......
...@@ -325,13 +325,13 @@ void FAudio_OPERATIONSET_QueueSetEffectParameters( ...@@ -325,13 +325,13 @@ void FAudio_OPERATIONSET_QueueSetEffectParameters(
); );
void FAudio_OPERATIONSET_QueueSetFilterParameters( void FAudio_OPERATIONSET_QueueSetFilterParameters(
FAudioVoice *voice, FAudioVoice *voice,
const FAudioFilterParameters *pParameters, const FAudioFilterParametersEXT *pParameters,
uint32_t OperationSet uint32_t OperationSet
); );
void FAudio_OPERATIONSET_QueueSetOutputFilterParameters( void FAudio_OPERATIONSET_QueueSetOutputFilterParameters(
FAudioVoice *voice, FAudioVoice *voice,
FAudioVoice *pDestinationVoice, FAudioVoice *pDestinationVoice,
const FAudioFilterParameters *pParameters, const FAudioFilterParametersEXT *pParameters,
uint32_t OperationSet uint32_t OperationSet
); );
void FAudio_OPERATIONSET_QueueSetVolume( void FAudio_OPERATIONSET_QueueSetVolume(
...@@ -435,7 +435,7 @@ struct FAudioVoice ...@@ -435,7 +435,7 @@ struct FAudioVoice
float **sendCoefficients; float **sendCoefficients;
float **mixCoefficients; float **mixCoefficients;
FAudioMixCallback *sendMix; FAudioMixCallback *sendMix;
FAudioFilterParameters *sendFilter; FAudioFilterParametersEXT *sendFilter;
FAudioFilterState **sendFilterState; FAudioFilterState **sendFilterState;
struct struct
{ {
...@@ -447,7 +447,7 @@ struct FAudioVoice ...@@ -447,7 +447,7 @@ struct FAudioVoice
uint8_t *parameterUpdates; uint8_t *parameterUpdates;
uint8_t *inPlaceProcessing; uint8_t *inPlaceProcessing;
} effects; } effects;
FAudioFilterParameters filter; FAudioFilterParametersEXT filter;
FAudioFilterState *filterState; FAudioFilterState *filterState;
FAudioMutex sendLock; FAudioMutex sendLock;
FAudioMutex effectLock; FAudioMutex effectLock;
......
...@@ -70,12 +70,12 @@ struct FAudio_OPERATIONSET_Operation ...@@ -70,12 +70,12 @@ struct FAudio_OPERATIONSET_Operation
} SetEffectParameters; } SetEffectParameters;
struct struct
{ {
FAudioFilterParameters Parameters; FAudioFilterParametersEXT Parameters;
} SetFilterParameters; } SetFilterParameters;
struct struct
{ {
FAudioVoice *pDestinationVoice; FAudioVoice *pDestinationVoice;
FAudioFilterParameters Parameters; FAudioFilterParametersEXT Parameters;
} SetOutputFilterParameters; } SetOutputFilterParameters;
struct struct
{ {
...@@ -169,7 +169,7 @@ static inline void ExecuteOperation(FAudio_OPERATIONSET_Operation *op) ...@@ -169,7 +169,7 @@ static inline void ExecuteOperation(FAudio_OPERATIONSET_Operation *op)
break; break;
case FAUDIOOP_SETFILTERPARAMETERS: case FAUDIOOP_SETFILTERPARAMETERS:
FAudioVoice_SetFilterParameters( FAudioVoice_SetFilterParametersEXT(
op->Voice, op->Voice,
&op->Data.SetFilterParameters.Parameters, &op->Data.SetFilterParameters.Parameters,
FAUDIO_COMMIT_NOW FAUDIO_COMMIT_NOW
...@@ -177,7 +177,7 @@ static inline void ExecuteOperation(FAudio_OPERATIONSET_Operation *op) ...@@ -177,7 +177,7 @@ static inline void ExecuteOperation(FAudio_OPERATIONSET_Operation *op)
break; break;
case FAUDIOOP_SETOUTPUTFILTERPARAMETERS: case FAUDIOOP_SETOUTPUTFILTERPARAMETERS:
FAudioVoice_SetOutputFilterParameters( FAudioVoice_SetOutputFilterParametersEXT(
op->Voice, op->Voice,
op->Data.SetOutputFilterParameters.pDestinationVoice, op->Data.SetOutputFilterParameters.pDestinationVoice,
&op->Data.SetOutputFilterParameters.Parameters, &op->Data.SetOutputFilterParameters.Parameters,
...@@ -472,7 +472,7 @@ void FAudio_OPERATIONSET_QueueSetEffectParameters( ...@@ -472,7 +472,7 @@ void FAudio_OPERATIONSET_QueueSetEffectParameters(
void FAudio_OPERATIONSET_QueueSetFilterParameters( void FAudio_OPERATIONSET_QueueSetFilterParameters(
FAudioVoice *voice, FAudioVoice *voice,
const FAudioFilterParameters *pParameters, const FAudioFilterParametersEXT *pParameters,
uint32_t OperationSet uint32_t OperationSet
) { ) {
FAudio_OPERATIONSET_Operation *op; FAudio_OPERATIONSET_Operation *op;
...@@ -489,7 +489,7 @@ void FAudio_OPERATIONSET_QueueSetFilterParameters( ...@@ -489,7 +489,7 @@ void FAudio_OPERATIONSET_QueueSetFilterParameters(
FAudio_memcpy( FAudio_memcpy(
&op->Data.SetFilterParameters.Parameters, &op->Data.SetFilterParameters.Parameters,
pParameters, pParameters,
sizeof(FAudioFilterParameters) sizeof(FAudioFilterParametersEXT)
); );
FAudio_PlatformUnlockMutex(voice->audio->operationLock); FAudio_PlatformUnlockMutex(voice->audio->operationLock);
...@@ -499,7 +499,7 @@ void FAudio_OPERATIONSET_QueueSetFilterParameters( ...@@ -499,7 +499,7 @@ void FAudio_OPERATIONSET_QueueSetFilterParameters(
void FAudio_OPERATIONSET_QueueSetOutputFilterParameters( void FAudio_OPERATIONSET_QueueSetOutputFilterParameters(
FAudioVoice *voice, FAudioVoice *voice,
FAudioVoice *pDestinationVoice, FAudioVoice *pDestinationVoice,
const FAudioFilterParameters *pParameters, const FAudioFilterParametersEXT *pParameters,
uint32_t OperationSet uint32_t OperationSet
) { ) {
FAudio_OPERATIONSET_Operation *op; FAudio_OPERATIONSET_Operation *op;
...@@ -517,7 +517,7 @@ void FAudio_OPERATIONSET_QueueSetOutputFilterParameters( ...@@ -517,7 +517,7 @@ void FAudio_OPERATIONSET_QueueSetOutputFilterParameters(
FAudio_memcpy( FAudio_memcpy(
&op->Data.SetOutputFilterParameters.Parameters, &op->Data.SetOutputFilterParameters.Parameters,
pParameters, pParameters,
sizeof(FAudioFilterParameters) sizeof(FAudioFilterParametersEXT)
); );
FAudio_PlatformUnlockMutex(voice->audio->operationLock); FAudio_PlatformUnlockMutex(voice->audio->operationLock);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment