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
float OneOverQ; /* [0, FAUDIO_MAX_FILTER_ONEOVERQ] */
} 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
{
/* Either 0 or FAUDIO_END_OF_STREAM */
......@@ -375,6 +383,7 @@ typedef struct FAudioXMA2WaveFormatEx
#define FAUDIO_DEFAULT_FILTER_TYPE FAudioLowPassFilter
#define FAUDIO_DEFAULT_FILTER_FREQUENCY FAUDIO_MAX_FILTER_FREQUENCY
#define FAUDIO_DEFAULT_FILTER_ONEOVERQ 1.0f
#define FAUDIO_DEFAULT_FILTER_WETDRYMIX_EXT 1.0f
#define FAUDIO_LOG_ERRORS 0x0001
#define FAUDIO_LOG_WARNINGS 0x0002
......@@ -485,7 +494,7 @@ extern FAudioGUID DATAFORMAT_SUBTYPE_IEEE_FLOAT;
#define FAUDIO_ABI_VERSION 0
#define FAUDIO_MAJOR_VERSION 23
#define FAUDIO_MINOR_VERSION 3
#define FAUDIO_MINOR_VERSION 7
#define FAUDIO_PATCH_VERSION 0
#define FAUDIO_COMPILED_VERSION ( \
......@@ -909,6 +918,58 @@ FAUDIOAPI void FAudioVoice_GetOutputFilterParameters(
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.
*
* Volume: Amplitude ratio. 1.0f is default, 0.0f is silence.
......
......@@ -732,6 +732,7 @@ uint32_t FACTAudioEngine_RegisterNotification(
/* WaveBanks */
#define PERSIST_ACTION pEngine->wb_context = pNotificationDescription->pvContext;
else HANDLE_PERSIST(WAVEBANKPREPARED)
else HANDLE_PERSIST(WAVEBANKSTREAMING_INVALIDCONTENT)
#undef PERSIST_ACTION
/* Anything else? */
......@@ -855,6 +856,7 @@ uint32_t FACTAudioEngine_UnRegisterNotification(
/* WaveBanks */
#define PERSIST_ACTION pEngine->wb_context = pNotificationDescription->pvContext;
else HANDLE_PERSIST(WAVEBANKPREPARED)
else HANDLE_PERSIST(WAVEBANKSTREAMING_INVALIDCONTENT)
#undef PERSIST_ACTION
/* Anything else? */
......
......@@ -2616,6 +2616,7 @@ uint32_t FACT_INTERNAL_ParseSoundBank(
/* WaveBank Name data */
FAudio_assert((ptr - start) == wavebankNameOffset);
ptr = start + wavebankNameOffset;
sb->wavebankNames = (char**) pEngine->pMalloc(
sizeof(char*) *
sb->wavebankCount
......@@ -2818,6 +2819,10 @@ uint32_t FACT_INTERNAL_ParseSoundBank(
/* Simple Cue data */
FAudio_assert(cueSimpleCount == 0 || (ptr - start) == cueSimpleOffset);
if (cueSimpleCount > 0)
{
ptr = start + cueSimpleOffset;
for (i = 0; i < cueSimpleCount; i += 1, cur += 1)
{
sb->cues[cur].flags = read_u8(&ptr);
......@@ -2829,9 +2834,14 @@ uint32_t FACT_INTERNAL_ParseSoundBank(
sb->cues[cur].maxInstanceBehavior = 0;
sb->cues[cur].instanceCount = 0;
}
}
/* Complex Cue data */
FAudio_assert(cueComplexCount == 0 || (ptr - start) == cueComplexOffset);
if (cueComplexCount > 0)
{
ptr = start + cueComplexOffset;
for (i = 0; i < cueComplexCount; i += 1, cur += 1)
{
sb->cues[cur].flags = read_u8(&ptr);
......@@ -2859,11 +2869,13 @@ uint32_t FACT_INTERNAL_ParseSoundBank(
sb->transitionCount += 1;
}
}
}
/* Variation data */
if (sb->variationCount > 0)
{
FAudio_assert((ptr - start) == variationOffset);
ptr = start + variationOffset;
sb->variations = (FACTVariationTable*) pEngine->pMalloc(
sizeof(FACTVariationTable) *
sb->variationCount
......@@ -2949,6 +2961,7 @@ uint32_t FACT_INTERNAL_ParseSoundBank(
if (sb->transitionCount > 0)
{
FAudio_assert((ptr - start) == transitionOffset);
ptr = start + transitionOffset;
sb->transitions = (FACTTransitionTable*) pEngine->pMalloc(
sizeof(FACTTransitionTable) *
sb->transitionCount
......@@ -2996,6 +3009,7 @@ uint32_t FACT_INTERNAL_ParseSoundBank(
if (cueNameIndexOffset != -1)
{
FAudio_assert((ptr - start) == cueNameIndexOffset);
ptr = start + cueNameIndexOffset;
ptr += 6 * sb->cueCount; /* FIXME: index as assert value? */
}
......@@ -3003,6 +3017,7 @@ uint32_t FACT_INTERNAL_ParseSoundBank(
if (cueNameOffset != -1)
{
FAudio_assert((ptr - start) == cueNameOffset);
ptr = start + cueNameOffset;
sb->cueNames = (char**) pEngine->pMalloc(
sizeof(char*) *
sb->cueCount
......
......@@ -111,7 +111,8 @@ typedef enum FACTNoticationsFlags
NOTIFY_WAVESTOP = 0x00002000,
NOTIFY_WAVELOOPED = 0x00004000,
NOTIFY_WAVEDESTROY = 0x00008000,
NOTIFY_WAVEBANKPREPARED = 0x00010000
NOTIFY_WAVEBANKPREPARED = 0x00010000,
NOTIFY_WAVEBANKSTREAMING_INVALIDCONTENT = 0x00020000
} FACTNoticationsFlags;
/* Internal SoundBank Types */
......
......@@ -278,6 +278,7 @@ uint32_t FAudio_CreateSourceVoice(
(*ppSourceVoice)->filter.Type = FAUDIO_DEFAULT_FILTER_TYPE;
(*ppSourceVoice)->filter.Frequency = FAUDIO_DEFAULT_FILTER_FREQUENCY;
(*ppSourceVoice)->filter.OneOverQ = FAUDIO_DEFAULT_FILTER_ONEOVERQ;
(*ppSourceVoice)->filter.WetDryMix = FAUDIO_DEFAULT_FILTER_WETDRYMIX_EXT;
(*ppSourceVoice)->sendLock = FAudio_PlatformCreateMutex();
LOG_MUTEX_CREATE(audio, (*ppSourceVoice)->sendLock)
(*ppSourceVoice)->effectLock = FAudio_PlatformCreateMutex();
......@@ -586,6 +587,7 @@ uint32_t FAudio_CreateSubmixVoice(
(*ppSubmixVoice)->filter.Type = FAUDIO_DEFAULT_FILTER_TYPE;
(*ppSubmixVoice)->filter.Frequency = FAUDIO_DEFAULT_FILTER_FREQUENCY;
(*ppSubmixVoice)->filter.OneOverQ = FAUDIO_DEFAULT_FILTER_ONEOVERQ;
(*ppSubmixVoice)->filter.WetDryMix = FAUDIO_DEFAULT_FILTER_WETDRYMIX_EXT;
(*ppSubmixVoice)->sendLock = FAudio_PlatformCreateMutex();
LOG_MUTEX_CREATE(audio, (*ppSubmixVoice)->sendLock)
(*ppSubmixVoice)->effectLock = FAudio_PlatformCreateMutex();
......@@ -1296,8 +1298,8 @@ uint32_t FAudioVoice_SetOutputVoices(
/* Allocate the whole send filter array if needed... */
if (voice->sendFilter == NULL)
{
voice->sendFilter = (FAudioFilterParameters*) voice->audio->pMalloc(
sizeof(FAudioFilterParameters) * pSendList->SendCount
voice->sendFilter = (FAudioFilterParametersEXT*) voice->audio->pMalloc(
sizeof(FAudioFilterParametersEXT) * pSendList->SendCount
);
}
if (voice->sendFilterState == NULL)
......@@ -1315,6 +1317,7 @@ uint32_t FAudioVoice_SetOutputVoices(
voice->sendFilter[i].Type = FAUDIO_DEFAULT_FILTER_TYPE;
voice->sendFilter[i].Frequency = FAUDIO_DEFAULT_FILTER_FREQUENCY;
voice->sendFilter[i].OneOverQ = FAUDIO_DEFAULT_FILTER_ONEOVERQ;
voice->sendFilter[i].WetDryMix = FAUDIO_DEFAULT_FILTER_WETDRYMIX_EXT;
voice->sendFilterState[i] = (FAudioFilterState*) voice->audio->pMalloc(
sizeof(FAudioFilterState) * outChannels
);
......@@ -1640,9 +1643,9 @@ uint32_t FAudioVoice_GetEffectParameters(
return 0;
}
uint32_t FAudioVoice_SetFilterParameters(
uint32_t FAudioVoice_SetFilterParametersEXT(
FAudioVoice *voice,
const FAudioFilterParameters *pParameters,
const FAudioFilterParametersEXT *pParameters,
uint32_t OperationSet
) {
LOG_API_ENTER(voice->audio)
......@@ -1678,7 +1681,7 @@ uint32_t FAudioVoice_SetFilterParameters(
FAudio_memcpy(
&voice->filter,
pParameters,
sizeof(FAudioFilterParameters)
sizeof(FAudioFilterParametersEXT)
);
FAudio_PlatformUnlockMutex(voice->filterLock);
LOG_MUTEX_UNLOCK(voice->audio, voice->filterLock)
......@@ -1687,9 +1690,23 @@ uint32_t FAudioVoice_SetFilterParameters(
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,
FAudioFilterParameters *pParameters
FAudioFilterParametersEXT *pParameters
) {
LOG_API_ENTER(voice->audio)
......@@ -1713,17 +1730,34 @@ void FAudioVoice_GetFilterParameters(
FAudio_memcpy(
pParameters,
&voice->filter,
sizeof(FAudioFilterParameters)
sizeof(FAudioFilterParametersEXT)
);
FAudio_PlatformUnlockMutex(voice->filterLock);
LOG_MUTEX_UNLOCK(voice->audio, voice->filterLock)
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 *pDestinationVoice,
const FAudioFilterParameters *pParameters,
const FAudioFilterParametersEXT *pParameters,
uint32_t OperationSet
) {
uint32_t i;
......@@ -1791,7 +1825,7 @@ uint32_t FAudioVoice_SetOutputFilterParameters(
FAudio_memcpy(
&voice->sendFilter[i],
pParameters,
sizeof(FAudioFilterParameters)
sizeof(FAudioFilterParametersEXT)
);
FAudio_PlatformUnlockMutex(voice->sendLock);
......@@ -1800,10 +1834,25 @@ uint32_t FAudioVoice_SetOutputFilterParameters(
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 *pDestinationVoice,
FAudioFilterParameters *pParameters
FAudioFilterParametersEXT *pParameters
) {
uint32_t i;
......@@ -1859,7 +1908,7 @@ void FAudioVoice_GetOutputFilterParameters(
FAudio_memcpy(
pParameters,
&voice->sendFilter[i],
sizeof(FAudioFilterParameters)
sizeof(FAudioFilterParametersEXT)
);
FAudio_PlatformUnlockMutex(voice->sendLock);
......@@ -1914,6 +1963,24 @@ uint32_t FAudioVoice_SetVolume(
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(
FAudioVoice *voice,
float *pVolume
......
......@@ -598,7 +598,7 @@ static void FAudio_INTERNAL_DecodeBuffers(
static inline void FAudio_INTERNAL_FilterVoice(
FAudio *audio,
const FAudioFilterParameters *filter,
const FAudioFilterParametersEXT *filter,
FAudioFilterState *filterState,
float *samples,
uint32_t numSamples,
......@@ -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][FAudioBandPassFilter] = (filter->Frequency * filterState[ci][FAudioHighPassFilter]) + filterState[ci][FAudioBandPassFilter];
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)
......
......@@ -325,13 +325,13 @@ void FAudio_OPERATIONSET_QueueSetEffectParameters(
);
void FAudio_OPERATIONSET_QueueSetFilterParameters(
FAudioVoice *voice,
const FAudioFilterParameters *pParameters,
const FAudioFilterParametersEXT *pParameters,
uint32_t OperationSet
);
void FAudio_OPERATIONSET_QueueSetOutputFilterParameters(
FAudioVoice *voice,
FAudioVoice *pDestinationVoice,
const FAudioFilterParameters *pParameters,
const FAudioFilterParametersEXT *pParameters,
uint32_t OperationSet
);
void FAudio_OPERATIONSET_QueueSetVolume(
......@@ -435,7 +435,7 @@ struct FAudioVoice
float **sendCoefficients;
float **mixCoefficients;
FAudioMixCallback *sendMix;
FAudioFilterParameters *sendFilter;
FAudioFilterParametersEXT *sendFilter;
FAudioFilterState **sendFilterState;
struct
{
......@@ -447,7 +447,7 @@ struct FAudioVoice
uint8_t *parameterUpdates;
uint8_t *inPlaceProcessing;
} effects;
FAudioFilterParameters filter;
FAudioFilterParametersEXT filter;
FAudioFilterState *filterState;
FAudioMutex sendLock;
FAudioMutex effectLock;
......
......@@ -70,12 +70,12 @@ struct FAudio_OPERATIONSET_Operation
} SetEffectParameters;
struct
{
FAudioFilterParameters Parameters;
FAudioFilterParametersEXT Parameters;
} SetFilterParameters;
struct
{
FAudioVoice *pDestinationVoice;
FAudioFilterParameters Parameters;
FAudioFilterParametersEXT Parameters;
} SetOutputFilterParameters;
struct
{
......@@ -169,7 +169,7 @@ static inline void ExecuteOperation(FAudio_OPERATIONSET_Operation *op)
break;
case FAUDIOOP_SETFILTERPARAMETERS:
FAudioVoice_SetFilterParameters(
FAudioVoice_SetFilterParametersEXT(
op->Voice,
&op->Data.SetFilterParameters.Parameters,
FAUDIO_COMMIT_NOW
......@@ -177,7 +177,7 @@ static inline void ExecuteOperation(FAudio_OPERATIONSET_Operation *op)
break;
case FAUDIOOP_SETOUTPUTFILTERPARAMETERS:
FAudioVoice_SetOutputFilterParameters(
FAudioVoice_SetOutputFilterParametersEXT(
op->Voice,
op->Data.SetOutputFilterParameters.pDestinationVoice,
&op->Data.SetOutputFilterParameters.Parameters,
......@@ -472,7 +472,7 @@ void FAudio_OPERATIONSET_QueueSetEffectParameters(
void FAudio_OPERATIONSET_QueueSetFilterParameters(
FAudioVoice *voice,
const FAudioFilterParameters *pParameters,
const FAudioFilterParametersEXT *pParameters,
uint32_t OperationSet
) {
FAudio_OPERATIONSET_Operation *op;
......@@ -489,7 +489,7 @@ void FAudio_OPERATIONSET_QueueSetFilterParameters(
FAudio_memcpy(
&op->Data.SetFilterParameters.Parameters,
pParameters,
sizeof(FAudioFilterParameters)
sizeof(FAudioFilterParametersEXT)
);
FAudio_PlatformUnlockMutex(voice->audio->operationLock);
......@@ -499,7 +499,7 @@ void FAudio_OPERATIONSET_QueueSetFilterParameters(
void FAudio_OPERATIONSET_QueueSetOutputFilterParameters(
FAudioVoice *voice,
FAudioVoice *pDestinationVoice,
const FAudioFilterParameters *pParameters,
const FAudioFilterParametersEXT *pParameters,
uint32_t OperationSet
) {
FAudio_OPERATIONSET_Operation *op;
......@@ -517,7 +517,7 @@ void FAudio_OPERATIONSET_QueueSetOutputFilterParameters(
FAudio_memcpy(
&op->Data.SetOutputFilterParameters.Parameters,
pParameters,
sizeof(FAudioFilterParameters)
sizeof(FAudioFilterParametersEXT)
);
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