Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/xaudio2_7/FAudio/F3DAudio.h | 262 ++++++ dlls/xaudio2_7/FAudio/FACT.h | 814 ++++++++++++++++++ dlls/xaudio2_7/FAudio/FACT3D.h | 127 +++ dlls/xaudio2_7/FAudio/FAPO.h | 207 +++++ dlls/xaudio2_7/FAudio/FAPOBase.h | 264 ++++++ dlls/xaudio2_7/FAudio/FAPOFX.h | 178 ++++ dlls/xaudio2_7/FAudio/FAudio.h | 1322 ++++++++++++++++++++++++++++++ dlls/xaudio2_7/FAudio/FAudioFX.h | 308 +++++++ 8 files changed, 3482 insertions(+) create mode 100644 dlls/xaudio2_7/FAudio/F3DAudio.h create mode 100644 dlls/xaudio2_7/FAudio/FACT.h create mode 100644 dlls/xaudio2_7/FAudio/FACT3D.h create mode 100644 dlls/xaudio2_7/FAudio/FAPO.h create mode 100644 dlls/xaudio2_7/FAudio/FAPOBase.h create mode 100644 dlls/xaudio2_7/FAudio/FAPOFX.h create mode 100644 dlls/xaudio2_7/FAudio/FAudio.h create mode 100644 dlls/xaudio2_7/FAudio/FAudioFX.h
diff --git a/dlls/xaudio2_7/FAudio/F3DAudio.h b/dlls/xaudio2_7/FAudio/F3DAudio.h new file mode 100644 index 00000000000..5fbb618243c --- /dev/null +++ b/dlls/xaudio2_7/FAudio/F3DAudio.h @@ -0,0 +1,262 @@ +/* FAudio - XAudio Reimplementation for FNA + * + * Copyright (c) 2011-2021 Ethan Lee, Luigi Auriemma, and the MonoGame Team + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee flibitijibibo@flibitijibibo.com + * + */ + +/* This file has no documentation since the MSDN docs are still perfectly fine: + * https://docs.microsoft.com/en-us/windows/desktop/api/x3daudio/ + */ + +#ifndef F3DAUDIO_H +#define F3DAUDIO_H + +#ifdef _WIN32 +#define F3DAUDIOAPI __declspec(dllexport) +#else +#define F3DAUDIOAPI +#endif + +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Constants */ + +#ifndef _SPEAKER_POSITIONS_ +#define SPEAKER_FRONT_LEFT 0x00000001 +#define SPEAKER_FRONT_RIGHT 0x00000002 +#define SPEAKER_FRONT_CENTER 0x00000004 +#define SPEAKER_LOW_FREQUENCY 0x00000008 +#define SPEAKER_BACK_LEFT 0x00000010 +#define SPEAKER_BACK_RIGHT 0x00000020 +#define SPEAKER_FRONT_LEFT_OF_CENTER 0x00000040 +#define SPEAKER_FRONT_RIGHT_OF_CENTER 0x00000080 +#define SPEAKER_BACK_CENTER 0x00000100 +#define SPEAKER_SIDE_LEFT 0x00000200 +#define SPEAKER_SIDE_RIGHT 0x00000400 +#define SPEAKER_TOP_CENTER 0x00000800 +#define SPEAKER_TOP_FRONT_LEFT 0x00001000 +#define SPEAKER_TOP_FRONT_CENTER 0x00002000 +#define SPEAKER_TOP_FRONT_RIGHT 0x00004000 +#define SPEAKER_TOP_BACK_LEFT 0x00008000 +#define SPEAKER_TOP_BACK_CENTER 0x00010000 +#define SPEAKER_TOP_BACK_RIGHT 0x00020000 +#define _SPEAKER_POSITIONS_ +#endif + +#ifndef SPEAKER_MONO +#define SPEAKER_MONO SPEAKER_FRONT_CENTER +#define SPEAKER_STEREO (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT) +#define SPEAKER_2POINT1 \ + ( SPEAKER_FRONT_LEFT | \ + SPEAKER_FRONT_RIGHT | \ + SPEAKER_LOW_FREQUENCY ) +#define SPEAKER_SURROUND \ + ( SPEAKER_FRONT_LEFT | \ + SPEAKER_FRONT_RIGHT | \ + SPEAKER_FRONT_CENTER | \ + SPEAKER_BACK_CENTER ) +#define SPEAKER_QUAD \ + ( SPEAKER_FRONT_LEFT | \ + SPEAKER_FRONT_RIGHT | \ + SPEAKER_BACK_LEFT | \ + SPEAKER_BACK_RIGHT ) +#define SPEAKER_4POINT1 \ + ( SPEAKER_FRONT_LEFT | \ + SPEAKER_FRONT_RIGHT | \ + SPEAKER_LOW_FREQUENCY | \ + SPEAKER_BACK_LEFT | \ + SPEAKER_BACK_RIGHT ) +#define SPEAKER_5POINT1 \ + ( SPEAKER_FRONT_LEFT | \ + SPEAKER_FRONT_RIGHT | \ + SPEAKER_FRONT_CENTER | \ + SPEAKER_LOW_FREQUENCY | \ + SPEAKER_BACK_LEFT | \ + SPEAKER_BACK_RIGHT ) +#define SPEAKER_7POINT1 \ + ( SPEAKER_FRONT_LEFT | \ + SPEAKER_FRONT_RIGHT | \ + SPEAKER_FRONT_CENTER | \ + SPEAKER_LOW_FREQUENCY | \ + SPEAKER_BACK_LEFT | \ + SPEAKER_BACK_RIGHT | \ + SPEAKER_FRONT_LEFT_OF_CENTER | \ + SPEAKER_FRONT_RIGHT_OF_CENTER ) +#define SPEAKER_5POINT1_SURROUND \ + ( SPEAKER_FRONT_LEFT | \ + SPEAKER_FRONT_RIGHT | \ + SPEAKER_FRONT_CENTER | \ + SPEAKER_LOW_FREQUENCY | \ + SPEAKER_SIDE_LEFT | \ + SPEAKER_SIDE_RIGHT ) +#define SPEAKER_7POINT1_SURROUND \ + ( SPEAKER_FRONT_LEFT | \ + SPEAKER_FRONT_RIGHT | \ + SPEAKER_FRONT_CENTER | \ + SPEAKER_LOW_FREQUENCY | \ + SPEAKER_BACK_LEFT | \ + SPEAKER_BACK_RIGHT | \ + SPEAKER_SIDE_LEFT | \ + SPEAKER_SIDE_RIGHT ) +#define SPEAKER_XBOX SPEAKER_5POINT1 +#endif + +#define F3DAUDIO_PI 3.141592654f +#define F3DAUDIO_2PI 6.283185307f + +#define F3DAUDIO_CALCULATE_MATRIX 0x00000001 +#define F3DAUDIO_CALCULATE_DELAY 0x00000002 +#define F3DAUDIO_CALCULATE_LPF_DIRECT 0x00000004 +#define F3DAUDIO_CALCULATE_LPF_REVERB 0x00000008 +#define F3DAUDIO_CALCULATE_REVERB 0x00000010 +#define F3DAUDIO_CALCULATE_DOPPLER 0x00000020 +#define F3DAUDIO_CALCULATE_EMITTER_ANGLE 0x00000040 +#define F3DAUDIO_CALCULATE_ZEROCENTER 0x00010000 +#define F3DAUDIO_CALCULATE_REDIRECT_TO_LFE 0x00020000 + +/* Type Declarations */ + +#define F3DAUDIO_HANDLE_BYTESIZE 20 +typedef uint8_t F3DAUDIO_HANDLE[F3DAUDIO_HANDLE_BYTESIZE]; + +/* Structures */ + +#pragma pack(push, 1) + +typedef struct F3DAUDIO_VECTOR +{ + float x; + float y; + float z; +} F3DAUDIO_VECTOR; + +typedef struct F3DAUDIO_DISTANCE_CURVE_POINT +{ + float Distance; + float DSPSetting; +} F3DAUDIO_DISTANCE_CURVE_POINT; + +typedef struct F3DAUDIO_DISTANCE_CURVE +{ + F3DAUDIO_DISTANCE_CURVE_POINT *pPoints; + uint32_t PointCount; +} F3DAUDIO_DISTANCE_CURVE; + +typedef struct F3DAUDIO_CONE +{ + float InnerAngle; + float OuterAngle; + float InnerVolume; + float OuterVolume; + float InnerLPF; + float OuterLPF; + float InnerReverb; + float OuterReverb; +} F3DAUDIO_CONE; + +typedef struct F3DAUDIO_LISTENER +{ + F3DAUDIO_VECTOR OrientFront; + F3DAUDIO_VECTOR OrientTop; + F3DAUDIO_VECTOR Position; + F3DAUDIO_VECTOR Velocity; + F3DAUDIO_CONE *pCone; +} F3DAUDIO_LISTENER; + +typedef struct F3DAUDIO_EMITTER +{ + F3DAUDIO_CONE *pCone; + F3DAUDIO_VECTOR OrientFront; + F3DAUDIO_VECTOR OrientTop; + F3DAUDIO_VECTOR Position; + F3DAUDIO_VECTOR Velocity; + float InnerRadius; + float InnerRadiusAngle; + uint32_t ChannelCount; + float ChannelRadius; + float *pChannelAzimuths; + F3DAUDIO_DISTANCE_CURVE *pVolumeCurve; + F3DAUDIO_DISTANCE_CURVE *pLFECurve; + F3DAUDIO_DISTANCE_CURVE *pLPFDirectCurve; + F3DAUDIO_DISTANCE_CURVE *pLPFReverbCurve; + F3DAUDIO_DISTANCE_CURVE *pReverbCurve; + float CurveDistanceScaler; + float DopplerScaler; +} F3DAUDIO_EMITTER; + +#ifndef F3DAUDIO_DSP_SETTINGS_DECL +#define F3DAUDIO_DSP_SETTINGS_DECL +typedef struct F3DAUDIO_DSP_SETTINGS F3DAUDIO_DSP_SETTINGS; +#endif /* F3DAUDIO_DSP_SETTINGS_DECL */ + +struct F3DAUDIO_DSP_SETTINGS +{ + float *pMatrixCoefficients; + float *pDelayTimes; + uint32_t SrcChannelCount; + uint32_t DstChannelCount; + float LPFDirectCoefficient; + float LPFReverbCoefficient; + float ReverbLevel; + float DopplerFactor; + float EmitterToListenerAngle; + float EmitterToListenerDistance; + float EmitterVelocityComponent; + float ListenerVelocityComponent; +}; + +#pragma pack(pop) + +/* Functions */ + +F3DAUDIOAPI void F3DAudioInitialize( + uint32_t SpeakerChannelMask, + float SpeedOfSound, + F3DAUDIO_HANDLE Instance +); + +F3DAUDIOAPI uint32_t F3DAudioInitialize8( + uint32_t SpeakerChannelMask, + float SpeedOfSound, + F3DAUDIO_HANDLE Instance +); + +F3DAUDIOAPI void F3DAudioCalculate( + const F3DAUDIO_HANDLE Instance, + const F3DAUDIO_LISTENER *pListener, + const F3DAUDIO_EMITTER *pEmitter, + uint32_t Flags, + F3DAUDIO_DSP_SETTINGS *pDSPSettings +); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* F3DAUDIO_H */ + +/* vim: set noexpandtab shiftwidth=8 tabstop=8: */ diff --git a/dlls/xaudio2_7/FAudio/FACT.h b/dlls/xaudio2_7/FAudio/FACT.h new file mode 100644 index 00000000000..579b7168812 --- /dev/null +++ b/dlls/xaudio2_7/FAudio/FACT.h @@ -0,0 +1,814 @@ +/* FAudio - XAudio Reimplementation for FNA + * + * Copyright (c) 2011-2021 Ethan Lee, Luigi Auriemma, and the MonoGame Team + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee flibitijibibo@flibitijibibo.com + * + */ + +/* This file has no documentation since you are expected to already know how + * XACT works if you are still using these APIs! + */ + +#ifndef FACT_H +#define FACT_H + +#include "FAudio.h" + +#define FACTAPI FAUDIOAPI +#ifdef _WIN32 +#define FACTCALL __stdcall +#else +#define FACTCALL +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Type Declarations */ + +typedef struct FACTAudioEngine FACTAudioEngine; +typedef struct FACTSoundBank FACTSoundBank; +typedef struct FACTWaveBank FACTWaveBank; +typedef struct FACTWave FACTWave; +typedef struct FACTCue FACTCue; +typedef struct FACTNotification FACTNotification; + +typedef struct FACTRendererDetails +{ + int16_t rendererID[0xFF]; /* Win32 wchar_t */ + int16_t displayName[0xFF]; /* Win32 wchar_t */ + int32_t defaultDevice; +} FACTRendererDetails; + +typedef struct FACTOverlapped +{ + void *Internal; /* ULONG_PTR */ + void *InternalHigh; /* ULONG_PTR */ + FAUDIONAMELESS union + { + FAUDIONAMELESS struct + { + uint32_t Offset; + uint32_t OffsetHigh; + }; + void *Pointer; + }; + void *hEvent; +} FACTOverlapped; + +typedef int32_t (FACTCALL * FACTReadFileCallback)( + void *hFile, + void *buffer, + uint32_t nNumberOfBytesToRead, + uint32_t *lpNumberOfBytesRead, + FACTOverlapped *lpOverlapped +); + +typedef int32_t (FACTCALL * FACTGetOverlappedResultCallback)( + void *hFile, + FACTOverlapped *lpOverlapped, + uint32_t *lpNumberOfBytesTransferred, + int32_t bWait +); + +typedef struct FACTFileIOCallbacks +{ + FACTReadFileCallback readFileCallback; + FACTGetOverlappedResultCallback getOverlappedResultCallback; +} FACTFileIOCallbacks; + +typedef void (FACTCALL * FACTNotificationCallback)( + const FACTNotification *pNotification +); + +/* FIXME: ABI bug! This should be pack(1) explicitly. Do not memcpy this! */ +typedef struct FACTRuntimeParameters +{ + uint32_t lookAheadTime; + void *pGlobalSettingsBuffer; + uint32_t globalSettingsBufferSize; + uint32_t globalSettingsFlags; + uint32_t globalSettingsAllocAttributes; + FACTFileIOCallbacks fileIOCallbacks; + FACTNotificationCallback fnNotificationCallback; + int16_t *pRendererID; /* Win32 wchar_t* */ + FAudio *pXAudio2; + FAudioMasteringVoice *pMasteringVoice; +} FACTRuntimeParameters; + +typedef struct FACTStreamingParameters +{ + void *file; + uint32_t offset; + uint32_t flags; + uint16_t packetSize; /* Measured in DVD sectors, or 2048 bytes */ +} FACTStreamingParameters; + +#define FACT_WAVEBANK_TYPE_BUFFER 0x00000000 +#define FACT_WAVEBANK_TYPE_STREAMING 0x00000001 +#define FACT_WAVEBANK_TYPE_MASK 0x00000001 + +#define FACT_WAVEBANK_FLAGS_ENTRYNAMES 0x00010000 +#define FACT_WAVEBANK_FLAGS_COMPACT 0x00020000 +#define FACT_WAVEBANK_FLAGS_SYNC_DISABLED 0x00040000 +#define FACT_WAVEBANK_FLAGS_SEEKTABLES 0x00080000 +#define FACT_WAVEBANK_FLAGS_MASK 0x000F0000 + +typedef enum FACTWaveBankSegIdx +{ + FACT_WAVEBANK_SEGIDX_BANKDATA = 0, + FACT_WAVEBANK_SEGIDX_ENTRYMETADATA, + FACT_WAVEBANK_SEGIDX_SEEKTABLES, + FACT_WAVEBANK_SEGIDX_ENTRYNAMES, + FACT_WAVEBANK_SEGIDX_ENTRYWAVEDATA, + FACT_WAVEBANK_SEGIDX_COUNT +} FACTWaveBankSegIdx; + +#pragma pack(push, 1) + +typedef struct FACTWaveBankRegion +{ + uint32_t dwOffset; + uint32_t dwLength; +} FACTWaveBankRegion; + +typedef struct FACTWaveBankSampleRegion +{ + uint32_t dwStartSample; + uint32_t dwTotalSamples; +} FACTWaveBankSampleRegion; + +typedef struct FACTWaveBankHeader +{ + uint32_t dwSignature; + uint32_t dwVersion; + uint32_t dwHeaderVersion; + FACTWaveBankRegion Segments[FACT_WAVEBANK_SEGIDX_COUNT]; +} FACTWaveBankHeader; + +typedef union FACTWaveBankMiniWaveFormat +{ + FAUDIONAMELESS struct + { + uint32_t wFormatTag : 2; + uint32_t nChannels : 3; + uint32_t nSamplesPerSec : 18; + uint32_t wBlockAlign : 8; + uint32_t wBitsPerSample : 1; + }; + uint32_t dwValue; +} FACTWaveBankMiniWaveFormat; + +typedef struct FACTWaveBankEntry +{ + FAUDIONAMELESS union + { + FAUDIONAMELESS struct + { + uint32_t dwFlags : 4; + uint32_t Duration : 28; + }; + uint32_t dwFlagsAndDuration; + }; + FACTWaveBankMiniWaveFormat Format; + FACTWaveBankRegion PlayRegion; + FACTWaveBankSampleRegion LoopRegion; +} FACTWaveBankEntry; + +typedef struct FACTWaveBankEntryCompact +{ + uint32_t dwOffset : 21; + uint32_t dwLengthDeviation : 11; +} FACTWaveBankEntryCompact; + +typedef struct FACTWaveBankData +{ + uint32_t dwFlags; + uint32_t dwEntryCount; + char szBankName[64]; + uint32_t dwEntryMetaDataElementSize; + uint32_t dwEntryNameElementSize; + uint32_t dwAlignment; + FACTWaveBankMiniWaveFormat CompactFormat; + uint64_t BuildTime; +} FACTWaveBankData; + +#pragma pack(pop) + +typedef struct FACTWaveProperties +{ + char friendlyName[64]; + FACTWaveBankMiniWaveFormat format; + uint32_t durationInSamples; + FACTWaveBankSampleRegion loopRegion; + int32_t streaming; +} FACTWaveProperties; + +typedef struct FACTWaveInstanceProperties +{ + FACTWaveProperties properties; + int32_t backgroundMusic; +} FACTWaveInstanceProperties; + +typedef struct FACTCueProperties +{ + char friendlyName[0xFF]; + int32_t interactive; + uint16_t iaVariableIndex; + uint16_t numVariations; + uint8_t maxInstances; + uint8_t currentInstances; +} FACTCueProperties; + +typedef struct FACTTrackProperties +{ + uint32_t duration; + uint16_t numVariations; + uint8_t numChannels; + uint16_t waveVariation; + uint8_t loopCount; +} FACTTrackProperties; + +typedef struct FACTVariationProperties +{ + uint16_t index; + uint8_t weight; + float iaVariableMin; + float iaVariableMax; + int32_t linger; +} FACTVariationProperties; + +typedef struct FACTSoundProperties +{ + uint16_t category; + uint8_t priority; + int16_t pitch; + float volume; + uint16_t numTracks; + FACTTrackProperties arrTrackProperties[1]; +} FACTSoundProperties; + +typedef struct FACTSoundVariationProperties +{ + FACTVariationProperties variationProperties; + FACTSoundProperties soundProperties; +} FACTSoundVariationProperties; + +typedef struct FACTCueInstanceProperties +{ + uint32_t allocAttributes; + FACTCueProperties cueProperties; + FACTSoundVariationProperties activeVariationProperties; +} FACTCueInstanceProperties; + +#pragma pack(push, 1) + +typedef struct FACTNotificationDescription +{ + uint8_t type; + uint8_t flags; + FACTSoundBank *pSoundBank; + FACTWaveBank *pWaveBank; + FACTCue *pCue; + FACTWave *pWave; + uint16_t cueIndex; + uint16_t waveIndex; + void* pvContext; +} FACTNotificationDescription; + +typedef struct FACTNotificationCue +{ + uint16_t cueIndex; + FACTSoundBank *pSoundBank; + FACTCue *pCue; +} FACTNotificationCue; + +typedef struct FACTNotificationMarker +{ + uint16_t cueIndex; + FACTSoundBank *pSoundBank; + FACTCue *pCue; + uint32_t marker; +} FACTNotificationMarker; + +typedef struct FACTNotificationSoundBank +{ + FACTSoundBank *pSoundBank; +} FACTNotificationSoundBank; + +typedef struct FACTNotificationWaveBank +{ + FACTWaveBank *pWaveBank; +} FACTNotificationWaveBank; + +typedef struct FACTNotificationVariable +{ + uint16_t cueIndex; + FACTSoundBank *pSoundBank; + FACTCue *pCue; + uint16_t variableIndex; + float variableValue; + int32_t local; +} FACTNotificationVariable; + +typedef struct FACTNotificationGUI +{ + uint32_t reserved; +} FACTNotificationGUI; + +typedef struct FACTNotificationWave +{ + FACTWaveBank *pWaveBank; + uint16_t waveIndex; + uint16_t cueIndex; + FACTSoundBank *pSoundBank; + FACTCue *pCue; + FACTWave *pWave; +} FACTNotificationWave; + +struct FACTNotification +{ + uint8_t type; + int32_t timeStamp; + void *pvContext; + FAUDIONAMELESS union + { + FACTNotificationCue cue; + FACTNotificationMarker marker; + FACTNotificationSoundBank soundBank; + FACTNotificationWaveBank waveBank; + FACTNotificationVariable variable; + FACTNotificationGUI gui; + FACTNotificationWave wave; + }; +}; + +#pragma pack(pop) + +/* Constants */ + +#define FACT_CONTENT_VERSION 46 + +static const uint32_t FACT_FLAG_MANAGEDATA = 0x00000001; + +static const uint32_t FACT_FLAG_STOP_RELEASE = 0x00000000; +static const uint32_t FACT_FLAG_STOP_IMMEDIATE = 0x00000001; + +static const uint32_t FACT_FLAG_BACKGROUND_MUSIC = 0x00000002; +static const uint32_t FACT_FLAG_UNITS_MS = 0x00000004; +static const uint32_t FACT_FLAG_UNITS_SAMPLES = 0x00000008; + +static const uint32_t FACT_STATE_CREATED = 0x00000001; +static const uint32_t FACT_STATE_PREPARING = 0x00000002; +static const uint32_t FACT_STATE_PREPARED = 0x00000004; +static const uint32_t FACT_STATE_PLAYING = 0x00000008; +static const uint32_t FACT_STATE_STOPPING = 0x00000010; +static const uint32_t FACT_STATE_STOPPED = 0x00000020; +static const uint32_t FACT_STATE_PAUSED = 0x00000040; +static const uint32_t FACT_STATE_INUSE = 0x00000080; +static const uint32_t FACT_STATE_PREPAREFAILED = 0x80000000; + +static const int16_t FACTPITCH_MIN = -1200; +static const int16_t FACTPITCH_MAX = 1200; +static const int16_t FACTPITCH_MIN_TOTAL = -2400; +static const int16_t FACTPITCH_MAX_TOTAL = 2400; + +static const float FACTVOLUME_MIN = 0.0f; +static const float FACTVOLUME_MAX = 16777216.0f; + +static const uint16_t FACTINDEX_INVALID = 0xFFFF; +static const uint16_t FACTVARIABLEINDEX_INVALID = 0xFFFF; +static const uint16_t FACTCATEGORY_INVALID = 0xFFFF; + +static const uint8_t FACTNOTIFICATIONTYPE_CUEPREPARED = 1; +static const uint8_t FACTNOTIFICATIONTYPE_CUEPLAY = 2; +static const uint8_t FACTNOTIFICATIONTYPE_CUESTOP = 3; +static const uint8_t FACTNOTIFICATIONTYPE_CUEDESTROYED = 4; +static const uint8_t FACTNOTIFICATIONTYPE_MARKER = 5; +static const uint8_t FACTNOTIFICATIONTYPE_SOUNDBANKDESTROYED = 6; +static const uint8_t FACTNOTIFICATIONTYPE_WAVEBANKDESTROYED = 7; +static const uint8_t FACTNOTIFICATIONTYPE_LOCALVARIABLECHANGED = 8; +static const uint8_t FACTNOTIFICATIONTYPE_GLOBALVARIABLECHANGED = 9; +static const uint8_t FACTNOTIFICATIONTYPE_GUICONNECTED = 10; +static const uint8_t FACTNOTIFICATIONTYPE_GUIDISCONNECTED = 11; +static const uint8_t FACTNOTIFICATIONTYPE_WAVEPREPARED = 12; +static const uint8_t FACTNOTIFICATIONTYPE_WAVEPLAY = 13; +static const uint8_t FACTNOTIFICATIONTYPE_WAVESTOP = 14; +static const uint8_t FACTNOTIFICATIONTYPE_WAVELOOPED = 15; +static const uint8_t FACTNOTIFICATIONTYPE_WAVEDESTROYED = 16; +static const uint8_t FACTNOTIFICATIONTYPE_WAVEBANKPREPARED = 17; +static const uint8_t FACTNOTIFICATIONTYPE_WAVEBANKSTREAMING_INVALIDCONTENT = 18; + +static const uint8_t FACT_FLAG_NOTIFICATION_PERSIST = 0x01; + +#define FACT_ENGINE_LOOKAHEAD_DEFAULT 250 + +#define FACT_MAX_WMA_AVG_BYTES_PER_SEC_ENTRIES 7 +static const uint32_t aWMAAvgBytesPerSec[] = +{ + 12000, + 24000, + 4000, + 6000, + 8000, + 20000, + 2500 +}; + +#define FACT_MAX_WMA_BLOCK_ALIGN_ENTRIES 17 +static const uint32_t aWMABlockAlign[] = +{ + 929, + 1487, + 1280, + 2230, + 8917, + 8192, + 4459, + 5945, + 2304, + 1536, + 1485, + 1008, + 2731, + 4096, + 6827, + 5462, + 1280 +}; + +/* AudioEngine Interface */ + +FACTAPI uint32_t FACTCreateEngine( + uint32_t dwCreationFlags, + FACTAudioEngine **ppEngine +); + +/* See "extensions/CustomAllocatorEXT.txt" for more details. */ +FACTAPI uint32_t FACTCreateEngineWithCustomAllocatorEXT( + uint32_t dwCreationFlags, + FACTAudioEngine **ppEngine, + FAudioMallocFunc customMalloc, + FAudioFreeFunc customFree, + FAudioReallocFunc customRealloc +); + +FACTAPI uint32_t FACTAudioEngine_AddRef(FACTAudioEngine *pEngine); + +FACTAPI uint32_t FACTAudioEngine_Release(FACTAudioEngine *pEngine); + +/* FIXME: QueryInterface? Or just ignore COM garbage... -flibit */ + +FACTAPI uint32_t FACTAudioEngine_GetRendererCount( + FACTAudioEngine *pEngine, + uint16_t *pnRendererCount +); + +FACTAPI uint32_t FACTAudioEngine_GetRendererDetails( + FACTAudioEngine *pEngine, + uint16_t nRendererIndex, + FACTRendererDetails *pRendererDetails +); + +FACTAPI uint32_t FACTAudioEngine_GetFinalMixFormat( + FACTAudioEngine *pEngine, + FAudioWaveFormatExtensible *pFinalMixFormat +); + +FACTAPI uint32_t FACTAudioEngine_Initialize( + FACTAudioEngine *pEngine, + const FACTRuntimeParameters *pParams +); + +FACTAPI uint32_t FACTAudioEngine_ShutDown(FACTAudioEngine *pEngine); + +FACTAPI uint32_t FACTAudioEngine_DoWork(FACTAudioEngine *pEngine); + +FACTAPI uint32_t FACTAudioEngine_CreateSoundBank( + FACTAudioEngine *pEngine, + const void *pvBuffer, + uint32_t dwSize, + uint32_t dwFlags, + uint32_t dwAllocAttributes, + FACTSoundBank **ppSoundBank +); + +FACTAPI uint32_t FACTAudioEngine_CreateInMemoryWaveBank( + FACTAudioEngine *pEngine, + const void *pvBuffer, + uint32_t dwSize, + uint32_t dwFlags, + uint32_t dwAllocAttributes, + FACTWaveBank **ppWaveBank +); + +FACTAPI uint32_t FACTAudioEngine_CreateStreamingWaveBank( + FACTAudioEngine *pEngine, + const FACTStreamingParameters *pParms, + FACTWaveBank **ppWaveBank +); + +FACTAPI uint32_t FACTAudioEngine_PrepareWave( + FACTAudioEngine *pEngine, + uint32_t dwFlags, + const char *szWavePath, + uint32_t wStreamingPacketSize, + uint32_t dwAlignment, + uint32_t dwPlayOffset, + uint8_t nLoopCount, + FACTWave **ppWave +); + +FACTAPI uint32_t FACTAudioEngine_PrepareInMemoryWave( + FACTAudioEngine *pEngine, + uint32_t dwFlags, + FACTWaveBankEntry entry, + uint32_t *pdwSeekTable, /* Optional! */ + uint8_t *pbWaveData, + uint32_t dwPlayOffset, + uint8_t nLoopCount, + FACTWave **ppWave +); + +FACTAPI uint32_t FACTAudioEngine_PrepareStreamingWave( + FACTAudioEngine *pEngine, + uint32_t dwFlags, + FACTWaveBankEntry entry, + FACTStreamingParameters streamingParams, + uint32_t dwAlignment, + uint32_t *pdwSeekTable, /* Optional! */ + uint8_t *pbWaveData, /* ABI bug, do not use! */ + uint32_t dwPlayOffset, + uint8_t nLoopCount, + FACTWave **ppWave +); + +FACTAPI uint32_t FACTAudioEngine_RegisterNotification( + FACTAudioEngine *pEngine, + const FACTNotificationDescription *pNotificationDescription +); + +FACTAPI uint32_t FACTAudioEngine_UnRegisterNotification( + FACTAudioEngine *pEngine, + const FACTNotificationDescription *pNotificationDescription +); + +FACTAPI uint16_t FACTAudioEngine_GetCategory( + FACTAudioEngine *pEngine, + const char *szFriendlyName +); + +FACTAPI uint32_t FACTAudioEngine_Stop( + FACTAudioEngine *pEngine, + uint16_t nCategory, + uint32_t dwFlags +); + +FACTAPI uint32_t FACTAudioEngine_SetVolume( + FACTAudioEngine *pEngine, + uint16_t nCategory, + float volume +); + +FACTAPI uint32_t FACTAudioEngine_Pause( + FACTAudioEngine *pEngine, + uint16_t nCategory, + int32_t fPause +); + +FACTAPI uint16_t FACTAudioEngine_GetGlobalVariableIndex( + FACTAudioEngine *pEngine, + const char *szFriendlyName +); + +FACTAPI uint32_t FACTAudioEngine_SetGlobalVariable( + FACTAudioEngine *pEngine, + uint16_t nIndex, + float nValue +); + +FACTAPI uint32_t FACTAudioEngine_GetGlobalVariable( + FACTAudioEngine *pEngine, + uint16_t nIndex, + float *pnValue +); + +/* SoundBank Interface */ + +FACTAPI uint16_t FACTSoundBank_GetCueIndex( + FACTSoundBank *pSoundBank, + const char *szFriendlyName +); + +FACTAPI uint32_t FACTSoundBank_GetNumCues( + FACTSoundBank *pSoundBank, + uint16_t *pnNumCues +); + +FACTAPI uint32_t FACTSoundBank_GetCueProperties( + FACTSoundBank *pSoundBank, + uint16_t nCueIndex, + FACTCueProperties *pProperties +); + +FACTAPI uint32_t FACTSoundBank_Prepare( + FACTSoundBank *pSoundBank, + uint16_t nCueIndex, + uint32_t dwFlags, + int32_t timeOffset, + FACTCue** ppCue +); + +FACTAPI uint32_t FACTSoundBank_Play( + FACTSoundBank *pSoundBank, + uint16_t nCueIndex, + uint32_t dwFlags, + int32_t timeOffset, + FACTCue** ppCue /* Optional! */ +); + +#ifndef F3DAUDIO_DSP_SETTINGS_DECL +#define F3DAUDIO_DSP_SETTINGS_DECL +typedef struct F3DAUDIO_DSP_SETTINGS F3DAUDIO_DSP_SETTINGS; +#endif /* F3DAUDIO_DSP_SETTINGS_DECL */ + +FACTAPI uint32_t FACTSoundBank_Play3D( + FACTSoundBank *pSoundBank, + uint16_t nCueIndex, + uint32_t dwFlags, + int32_t timeOffset, + F3DAUDIO_DSP_SETTINGS *pDSPSettings, + FACTCue** ppCue /* Optional! */ +); + +FACTAPI uint32_t FACTSoundBank_Stop( + FACTSoundBank *pSoundBank, + uint16_t nCueIndex, + uint32_t dwFlags +); + +FACTAPI uint32_t FACTSoundBank_Destroy(FACTSoundBank *pSoundBank); + +FACTAPI uint32_t FACTSoundBank_GetState( + FACTSoundBank *pSoundBank, + uint32_t *pdwState +); + +/* WaveBank Interface */ + +FACTAPI uint32_t FACTWaveBank_Destroy(FACTWaveBank *pWaveBank); + +FACTAPI uint32_t FACTWaveBank_GetState( + FACTWaveBank *pWaveBank, + uint32_t *pdwState +); + +FACTAPI uint32_t FACTWaveBank_GetNumWaves( + FACTWaveBank *pWaveBank, + uint16_t *pnNumWaves +); + +FACTAPI uint16_t FACTWaveBank_GetWaveIndex( + FACTWaveBank *pWaveBank, + const char *szFriendlyName +); + +FACTAPI uint32_t FACTWaveBank_GetWaveProperties( + FACTWaveBank *pWaveBank, + uint16_t nWaveIndex, + FACTWaveProperties *pWaveProperties +); + +FACTAPI uint32_t FACTWaveBank_Prepare( + FACTWaveBank *pWaveBank, + uint16_t nWaveIndex, + uint32_t dwFlags, + uint32_t dwPlayOffset, + uint8_t nLoopCount, + FACTWave **ppWave +); + +FACTAPI uint32_t FACTWaveBank_Play( + FACTWaveBank *pWaveBank, + uint16_t nWaveIndex, + uint32_t dwFlags, + uint32_t dwPlayOffset, + uint8_t nLoopCount, + FACTWave **ppWave +); + +FACTAPI uint32_t FACTWaveBank_Stop( + FACTWaveBank *pWaveBank, + uint16_t nWaveIndex, + uint32_t dwFlags +); + +/* Wave Interface */ + +FACTAPI uint32_t FACTWave_Destroy(FACTWave *pWave); + +FACTAPI uint32_t FACTWave_Play(FACTWave *pWave); + +FACTAPI uint32_t FACTWave_Stop(FACTWave *pWave, uint32_t dwFlags); + +FACTAPI uint32_t FACTWave_Pause(FACTWave *pWave, int32_t fPause); + +FACTAPI uint32_t FACTWave_GetState(FACTWave *pWave, uint32_t *pdwState); + +FACTAPI uint32_t FACTWave_SetPitch(FACTWave *pWave, int16_t pitch); + +FACTAPI uint32_t FACTWave_SetVolume(FACTWave *pWave, float volume); + +FACTAPI uint32_t FACTWave_SetMatrixCoefficients( + FACTWave *pWave, + uint32_t uSrcChannelCount, + uint32_t uDstChannelCount, + float *pMatrixCoefficients +); + +FACTAPI uint32_t FACTWave_GetProperties( + FACTWave *pWave, + FACTWaveInstanceProperties *pProperties +); + +/* Cue Interface */ + +FACTAPI uint32_t FACTCue_Destroy(FACTCue *pCue); + +FACTAPI uint32_t FACTCue_Play(FACTCue *pCue); + +FACTAPI uint32_t FACTCue_Stop(FACTCue *pCue, uint32_t dwFlags); + +FACTAPI uint32_t FACTCue_GetState(FACTCue *pCue, uint32_t *pdwState); + +FACTAPI uint32_t FACTCue_SetMatrixCoefficients( + FACTCue *pCue, + uint32_t uSrcChannelCount, + uint32_t uDstChannelCount, + float *pMatrixCoefficients +); + +FACTAPI uint16_t FACTCue_GetVariableIndex( + FACTCue *pCue, + const char *szFriendlyName +); + +FACTAPI uint32_t FACTCue_SetVariable( + FACTCue *pCue, + uint16_t nIndex, + float nValue +); + +FACTAPI uint32_t FACTCue_GetVariable( + FACTCue *pCue, + uint16_t nIndex, + float *nValue +); + +FACTAPI uint32_t FACTCue_Pause(FACTCue *pCue, int32_t fPause); + +FACTAPI uint32_t FACTCue_GetProperties( + FACTCue *pCue, + FACTCueInstanceProperties **ppProperties +); + +FACTAPI uint32_t FACTCue_SetOutputVoices( + FACTCue *pCue, + const FAudioVoiceSends *pSendList /* Optional! */ +); + +FACTAPI uint32_t FACTCue_SetOutputVoiceMatrix( + FACTCue *pCue, + const FAudioVoice *pDestinationVoice, /* Optional! */ + uint32_t SourceChannels, + uint32_t DestinationChannels, + const float *pLevelMatrix /* SourceChannels * DestinationChannels */ +); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* FACT_H */ + +/* vim: set noexpandtab shiftwidth=8 tabstop=8: */ diff --git a/dlls/xaudio2_7/FAudio/FACT3D.h b/dlls/xaudio2_7/FAudio/FACT3D.h new file mode 100644 index 00000000000..6ac02a82986 --- /dev/null +++ b/dlls/xaudio2_7/FAudio/FACT3D.h @@ -0,0 +1,127 @@ +/* FAudio - XAudio Reimplementation for FNA + * + * Copyright (c) 2011-2021 Ethan Lee, Luigi Auriemma, and the MonoGame Team + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee flibitijibibo@flibitijibibo.com + * + */ + +/* This file has no documentation since you are expected to already know how + * XACT works if you are still using these APIs! + */ + +#ifndef FACT3D_H +#define FACT3D_H + +#include "F3DAudio.h" +#include "FACT.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Constants */ + +#define LEFT_AZIMUTH (3.0f * F3DAUDIO_PI / 2.0f) +#define RIGHT_AZIMUTH (F3DAUDIO_PI / 2.0f) +#define FRONT_LEFT_AZIMUTH (7.0f * F3DAUDIO_PI / 4.0f) +#define FRONT_RIGHT_AZIMUTH (F3DAUDIO_PI / 4.0f) +#define FRONT_CENTER_AZIMUTH 0.0f +#define LOW_FREQUENCY_AZIMUTH F3DAUDIO_2PI +#define BACK_LEFT_AZIMUTH (5.0f * F3DAUDIO_PI / 4.0f) +#define BACK_RIGHT_AZIMUTH (3.0f * F3DAUDIO_PI / 4.0f) +#define BACK_CENTER_AZIMUTH F3DAUDIO_PI +#define FRONT_LEFT_OF_CENTER_AZIMUTH (15.0f * F3DAUDIO_PI / 8.0f) +#define FRONT_RIGHT_OF_CENTER_AZIMUTH (F3DAUDIO_PI / 8.0f) + +static const float aStereoLayout[] = +{ + LEFT_AZIMUTH, + RIGHT_AZIMUTH +}; +static const float a2Point1Layout[] = +{ + LEFT_AZIMUTH, + RIGHT_AZIMUTH, + LOW_FREQUENCY_AZIMUTH +}; +static const float aQuadLayout[] = +{ + FRONT_LEFT_AZIMUTH, + FRONT_RIGHT_AZIMUTH, + BACK_LEFT_AZIMUTH, + BACK_RIGHT_AZIMUTH +}; +static const float a4Point1Layout[] = +{ + FRONT_LEFT_AZIMUTH, + FRONT_RIGHT_AZIMUTH, + LOW_FREQUENCY_AZIMUTH, + BACK_LEFT_AZIMUTH, + BACK_RIGHT_AZIMUTH +}; +static const float a5Point1Layout[] = +{ + FRONT_LEFT_AZIMUTH, + FRONT_RIGHT_AZIMUTH, + FRONT_CENTER_AZIMUTH, + LOW_FREQUENCY_AZIMUTH, + BACK_LEFT_AZIMUTH, + BACK_RIGHT_AZIMUTH +}; +static const float a7Point1Layout[] = +{ + FRONT_LEFT_AZIMUTH, + FRONT_RIGHT_AZIMUTH, + FRONT_CENTER_AZIMUTH, + LOW_FREQUENCY_AZIMUTH, + BACK_LEFT_AZIMUTH, + BACK_RIGHT_AZIMUTH, + LEFT_AZIMUTH, + RIGHT_AZIMUTH +}; + +/* Functions */ + +FACTAPI uint32_t FACT3DInitialize( + FACTAudioEngine *pEngine, + F3DAUDIO_HANDLE F3DInstance +); + +FACTAPI uint32_t FACT3DCalculate( + F3DAUDIO_HANDLE F3DInstance, + const F3DAUDIO_LISTENER *pListener, + F3DAUDIO_EMITTER *pEmitter, + F3DAUDIO_DSP_SETTINGS *pDSPSettings +); + +FACTAPI uint32_t FACT3DApply( + F3DAUDIO_DSP_SETTINGS *pDSPSettings, + FACTCue *pCue +); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* FACT3D_H */ + +/* vim: set noexpandtab shiftwidth=8 tabstop=8: */ diff --git a/dlls/xaudio2_7/FAudio/FAPO.h b/dlls/xaudio2_7/FAudio/FAPO.h new file mode 100644 index 00000000000..0609770047f --- /dev/null +++ b/dlls/xaudio2_7/FAudio/FAPO.h @@ -0,0 +1,207 @@ +/* FAudio - XAudio Reimplementation for FNA + * + * Copyright (c) 2011-2021 Ethan Lee, Luigi Auriemma, and the MonoGame Team + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee flibitijibibo@flibitijibibo.com + * + */ + +/* This file has no documentation since the MSDN docs are still perfectly fine: + * https://docs.microsoft.com/en-us/windows/desktop/api/xapo/ + * + * Of course, the APIs aren't exactly the same since XAPO is super dependent on + * C++. Instead, we use a struct full of functions to mimic a vtable. + * + * The only serious difference is that our FAPO (yes, really) always has the + * Get/SetParameters function pointers, for simplicity. You can ignore these if + * your effect does not have parameters, as they will never get called unless + * it is explicitly requested by the application. + */ + +#ifndef FAPO_H +#define FAPO_H + +#include "FAudio.h" + +#define FAPOAPI FAUDIOAPI +#define FAPOCALL FAUDIOCALL + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Enumerations */ + +typedef enum FAPOBufferFlags +{ + FAPO_BUFFER_SILENT, + FAPO_BUFFER_VALID +} FAPOBufferFlags; + +/* Structures */ + +#pragma pack(push, 1) + +typedef struct FAPORegistrationProperties +{ + FAudioGUID clsid; + int16_t FriendlyName[256]; /* Win32 wchar_t */ + int16_t CopyrightInfo[256]; /* Win32 wchar_t */ + uint32_t MajorVersion; + uint32_t MinorVersion; + uint32_t Flags; + uint32_t MinInputBufferCount; + uint32_t MaxInputBufferCount; + uint32_t MinOutputBufferCount; + uint32_t MaxOutputBufferCount; +} FAPORegistrationProperties; + +typedef struct FAPOLockForProcessBufferParameters +{ + const FAudioWaveFormatEx *pFormat; + uint32_t MaxFrameCount; +} FAPOLockForProcessBufferParameters; + +typedef struct FAPOProcessBufferParameters +{ + void* pBuffer; + FAPOBufferFlags BufferFlags; + uint32_t ValidFrameCount; +} FAPOProcessBufferParameters; + +#pragma pack(pop) + +/* Constants */ + +#define FAPO_MIN_CHANNELS 1 +#define FAPO_MAX_CHANNELS 64 + +#define FAPO_MIN_FRAMERATE 1000 +#define FAPO_MAX_FRAMERATE 200000 + +#define FAPO_REGISTRATION_STRING_LENGTH 256 + +#define FAPO_FLAG_CHANNELS_MUST_MATCH 0x00000001 +#define FAPO_FLAG_FRAMERATE_MUST_MATCH 0x00000002 +#define FAPO_FLAG_BITSPERSAMPLE_MUST_MATCH 0x00000004 +#define FAPO_FLAG_BUFFERCOUNT_MUST_MATCH 0x00000008 +#define FAPO_FLAG_INPLACE_REQUIRED 0x00000020 +#define FAPO_FLAG_INPLACE_SUPPORTED 0x00000010 + +/* FAPO Interface */ + +#ifndef FAPO_DECL +#define FAPO_DECL +typedef struct FAPO FAPO; +#endif /* FAPO_DECL */ + +typedef int32_t (FAPOCALL * AddRefFunc)( + void *fapo +); +typedef int32_t (FAPOCALL * ReleaseFunc)( + void *fapo +); +typedef uint32_t (FAPOCALL * GetRegistrationPropertiesFunc)( + void* fapo, + FAPORegistrationProperties **ppRegistrationProperties +); +typedef uint32_t (FAPOCALL * IsInputFormatSupportedFunc)( + void* fapo, + const FAudioWaveFormatEx *pOutputFormat, + const FAudioWaveFormatEx *pRequestedInputFormat, + FAudioWaveFormatEx **ppSupportedInputFormat +); +typedef uint32_t (FAPOCALL * IsOutputFormatSupportedFunc)( + void* fapo, + const FAudioWaveFormatEx *pInputFormat, + const FAudioWaveFormatEx *pRequestedOutputFormat, + FAudioWaveFormatEx **ppSupportedOutputFormat +); +typedef uint32_t (FAPOCALL * InitializeFunc)( + void* fapo, + const void* pData, + uint32_t DataByteSize +); +typedef void (FAPOCALL * ResetFunc)( + void* fapo +); +typedef uint32_t (FAPOCALL * LockForProcessFunc)( + void* fapo, + uint32_t InputLockedParameterCount, + const FAPOLockForProcessBufferParameters *pInputLockedParameters, + uint32_t OutputLockedParameterCount, + const FAPOLockForProcessBufferParameters *pOutputLockedParameters +); +typedef void (FAPOCALL * UnlockForProcessFunc)( + void* fapo +); +typedef void (FAPOCALL * ProcessFunc)( + void* fapo, + uint32_t InputProcessParameterCount, + const FAPOProcessBufferParameters* pInputProcessParameters, + uint32_t OutputProcessParameterCount, + FAPOProcessBufferParameters* pOutputProcessParameters, + int32_t IsEnabled +); +typedef uint32_t (FAPOCALL * CalcInputFramesFunc)( + void* fapo, + uint32_t OutputFrameCount +); +typedef uint32_t (FAPOCALL * CalcOutputFramesFunc)( + void* fapo, + uint32_t InputFrameCount +); +typedef void (FAPOCALL * SetParametersFunc)( + void* fapo, + const void* pParameters, + uint32_t ParameterByteSize +); +typedef void (FAPOCALL * GetParametersFunc)( + void* fapo, + void* pParameters, + uint32_t ParameterByteSize +); + +struct FAPO +{ + AddRefFunc AddRef; + ReleaseFunc Release; + GetRegistrationPropertiesFunc GetRegistrationProperties; + IsInputFormatSupportedFunc IsInputFormatSupported; + IsOutputFormatSupportedFunc IsOutputFormatSupported; + InitializeFunc Initialize; + ResetFunc Reset; + LockForProcessFunc LockForProcess; + UnlockForProcessFunc UnlockForProcess; + ProcessFunc Process; + CalcInputFramesFunc CalcInputFrames; + CalcOutputFramesFunc CalcOutputFrames; + SetParametersFunc SetParameters; + GetParametersFunc GetParameters; +}; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* FAPO_H */ + +/* vim: set noexpandtab shiftwidth=8 tabstop=8: */ diff --git a/dlls/xaudio2_7/FAudio/FAPOBase.h b/dlls/xaudio2_7/FAudio/FAPOBase.h new file mode 100644 index 00000000000..c2fcdd2981c --- /dev/null +++ b/dlls/xaudio2_7/FAudio/FAPOBase.h @@ -0,0 +1,264 @@ +/* FAudio - XAudio Reimplementation for FNA + * + * Copyright (c) 2011-2021 Ethan Lee, Luigi Auriemma, and the MonoGame Team + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee flibitijibibo@flibitijibibo.com + * + */ + +/* This file has no documentation since the MSDN docs are still perfectly fine: + * https://docs.microsoft.com/en-us/windows/desktop/api/xapobase/ + * + * Of course, the APIs aren't exactly the same since XAPO is super dependent on + * C++. Instead, we use a struct full of functions to mimic a vtable. + * + * To mimic the CXAPOParametersBase experience, initialize the object like this: + * + * extern FAPORegistrationProperties MyFAPOProperties; + * extern int32_t producer; + * typedef struct MyFAPOParams + * { + * uint32_t something; + * } MyFAPOParams; + * typedef struct MyFAPO + * { + * FAPOBase base; + * uint32_t somethingElse; + * } MyFAPO; + * void MyFAPO_Free(void* fapo) + * { + * MyFAPO *mine = (MyFAPO*) fapo; + * mine->base.pFree(mine->base.m_pParameterBlocks); + * mine->base.pFree(fapo); + * } + * + * MyFAPO *result = (MyFAPO*) SDL_malloc(sizeof(MyFAPO)); + * uint8_t *params = (uint8_t*) SDL_malloc(sizeof(MyFAPOParams) * 3); + * CreateFAPOBase( + * &result->base, + * &MyFAPOProperties, + * params, + * sizeof(MyFAPOParams), + * producer + * ); + * result->base.base.Initialize = (InitializeFunc) MyFAPO_Initialize; + * result->base.base.Process = (ProcessFunc) MyFAPO_Process; + * result->base.Destructor = MyFAPO_Free; + */ + +#ifndef FAPOBASE_H +#define FAPOBASE_H + +#include "FAPO.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Constants */ + +#define FAPOBASE_DEFAULT_FORMAT_TAG FAUDIO_FORMAT_IEEE_FLOAT +#define FAPOBASE_DEFAULT_FORMAT_MIN_CHANNELS FAPO_MIN_CHANNELS +#define FAPOBASE_DEFAULT_FORMAT_MAX_CHANNELS FAPO_MAX_CHANNELS +#define FAPOBASE_DEFAULT_FORMAT_MIN_FRAMERATE FAPO_MIN_FRAMERATE +#define FAPOBASE_DEFAULT_FORMAT_MAX_FRAMERATE FAPO_MAX_FRAMERATE +#define FAPOBASE_DEFAULT_FORMAT_BITSPERSAMPLE 32 + +#define FAPOBASE_DEFAULT_FLAG ( \ + FAPO_FLAG_CHANNELS_MUST_MATCH | \ + FAPO_FLAG_FRAMERATE_MUST_MATCH | \ + FAPO_FLAG_BITSPERSAMPLE_MUST_MATCH | \ + FAPO_FLAG_BUFFERCOUNT_MUST_MATCH | \ + FAPO_FLAG_INPLACE_SUPPORTED \ +) + +#define FAPOBASE_DEFAULT_BUFFER_COUNT 1 + +/* FAPOBase Interface */ + +typedef struct FAPOBase FAPOBase; + +typedef void (FAPOCALL * OnSetParametersFunc)( + FAPOBase *fapo, + const void* parameters, + uint32_t parametersSize +); + +#pragma pack(push, 8) +struct FAPOBase +{ + /* Base Classes/Interfaces */ + FAPO base; + void (FAPOCALL *Destructor)(void*); + + /* Public Virtual Functions */ + OnSetParametersFunc OnSetParameters; + + /* Private Variables */ + const FAPORegistrationProperties *m_pRegistrationProperties; + void* m_pfnMatrixMixFunction; + float *m_pfl32MatrixCoefficients; + uint32_t m_nSrcFormatType; + uint8_t m_fIsScalarMatrix; + uint8_t m_fIsLocked; + uint8_t *m_pParameterBlocks; + uint8_t *m_pCurrentParameters; + uint8_t *m_pCurrentParametersInternal; + uint32_t m_uCurrentParametersIndex; + uint32_t m_uParameterBlockByteSize; + uint8_t m_fNewerResultsReady; + uint8_t m_fProducer; + + /* Protected Variables */ + int32_t m_lReferenceCount; /* LONG */ + + /* Allocator callbacks, NOT part of XAPOBase spec! */ + FAudioMallocFunc pMalloc; + FAudioFreeFunc pFree; + FAudioReallocFunc pRealloc; +}; +#pragma pack(pop) + +FAPOAPI void CreateFAPOBase( + FAPOBase *fapo, + const FAPORegistrationProperties *pRegistrationProperties, + uint8_t *pParameterBlocks, + uint32_t uParameterBlockByteSize, + uint8_t fProducer +); + +/* See "extensions/CustomAllocatorEXT.txt" for more information. */ +FAPOAPI void CreateFAPOBaseWithCustomAllocatorEXT( + FAPOBase *fapo, + const FAPORegistrationProperties *pRegistrationProperties, + uint8_t *pParameterBlocks, + uint32_t uParameterBlockByteSize, + uint8_t fProducer, + FAudioMallocFunc customMalloc, + FAudioFreeFunc customFree, + FAudioReallocFunc customRealloc +); + +FAPOAPI int32_t FAPOBase_AddRef(FAPOBase *fapo); + +FAPOAPI int32_t FAPOBase_Release(FAPOBase *fapo); + +FAPOAPI uint32_t FAPOBase_GetRegistrationProperties( + FAPOBase *fapo, + FAPORegistrationProperties **ppRegistrationProperties +); + +FAPOAPI uint32_t FAPOBase_IsInputFormatSupported( + FAPOBase *fapo, + const FAudioWaveFormatEx *pOutputFormat, + const FAudioWaveFormatEx *pRequestedInputFormat, + FAudioWaveFormatEx **ppSupportedInputFormat +); + +FAPOAPI uint32_t FAPOBase_IsOutputFormatSupported( + FAPOBase *fapo, + const FAudioWaveFormatEx *pInputFormat, + const FAudioWaveFormatEx *pRequestedOutputFormat, + FAudioWaveFormatEx **ppSupportedOutputFormat +); + +FAPOAPI uint32_t FAPOBase_Initialize( + FAPOBase *fapo, + const void* pData, + uint32_t DataByteSize +); + +FAPOAPI void FAPOBase_Reset(FAPOBase *fapo); + +FAPOAPI uint32_t FAPOBase_LockForProcess( + FAPOBase *fapo, + uint32_t InputLockedParameterCount, + const FAPOLockForProcessBufferParameters *pInputLockedParameters, + uint32_t OutputLockedParameterCount, + const FAPOLockForProcessBufferParameters *pOutputLockedParameters +); + +FAPOAPI void FAPOBase_UnlockForProcess(FAPOBase *fapo); + +FAPOAPI uint32_t FAPOBase_CalcInputFrames( + FAPOBase *fapo, + uint32_t OutputFrameCount +); + +FAPOAPI uint32_t FAPOBase_CalcOutputFrames( + FAPOBase *fapo, + uint32_t InputFrameCount +); + +FAPOAPI uint32_t FAPOBase_ValidateFormatDefault( + FAPOBase *fapo, + FAudioWaveFormatEx *pFormat, + uint8_t fOverwrite +); + +FAPOAPI uint32_t FAPOBase_ValidateFormatPair( + FAPOBase *fapo, + const FAudioWaveFormatEx *pSupportedFormat, + FAudioWaveFormatEx *pRequestedFormat, + uint8_t fOverwrite +); + +FAPOAPI void FAPOBase_ProcessThru( + FAPOBase *fapo, + void* pInputBuffer, + float *pOutputBuffer, + uint32_t FrameCount, + uint16_t InputChannelCount, + uint16_t OutputChannelCount, + uint8_t MixWithOutput +); + +FAPOAPI void FAPOBase_SetParameters( + FAPOBase *fapo, + const void* pParameters, + uint32_t ParameterByteSize +); + +FAPOAPI void FAPOBase_GetParameters( + FAPOBase *fapo, + void* pParameters, + uint32_t ParameterByteSize +); + +FAPOAPI void FAPOBase_OnSetParameters( + FAPOBase *fapo, + const void* parameters, + uint32_t parametersSize +); + +FAPOAPI uint8_t FAPOBase_ParametersChanged(FAPOBase *fapo); + +FAPOAPI uint8_t* FAPOBase_BeginProcess(FAPOBase *fapo); + +FAPOAPI void FAPOBase_EndProcess(FAPOBase *fapo); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* FAPOBASE_H */ + +/* vim: set noexpandtab shiftwidth=8 tabstop=8: */ diff --git a/dlls/xaudio2_7/FAudio/FAPOFX.h b/dlls/xaudio2_7/FAudio/FAPOFX.h new file mode 100644 index 00000000000..5aae441b2cc --- /dev/null +++ b/dlls/xaudio2_7/FAudio/FAPOFX.h @@ -0,0 +1,178 @@ +/* FAudio - XAudio Reimplementation for FNA + * + * Copyright (c) 2011-2021 Ethan Lee, Luigi Auriemma, and the MonoGame Team + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee flibitijibibo@flibitijibibo.com + * + */ + +#ifndef FAPOFX_H +#define FAPOFX_H + +#include "FAPO.h" + +#define FAPOFXAPI FAUDIOAPI + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* GUIDs */ + +/* "Legacy" GUIDs are from XAPOFX <= 1.5. They were removed in XAudio 2.8 and later. */ +extern const FAudioGUID FAPOFX_CLSID_FXEQ, FAPOFX_CLSID_FXEQ_LEGACY; +extern const FAudioGUID FAPOFX_CLSID_FXMasteringLimiter, FAPOFX_CLSID_FXMasteringLimiter_LEGACY; +extern const FAudioGUID FAPOFX_CLSID_FXReverb, FAPOFX_CLSID_FXReverb_LEGACY; +extern const FAudioGUID FAPOFX_CLSID_FXEcho, FAPOFX_CLSID_FXEcho_LEGACY; + +/* Structures */ + +#pragma pack(push, 1) + +/* See FAPOFXEQ_* constants below. + * FrequencyCenter is in Hz, Gain is amplitude ratio, Bandwidth is Q factor. + */ +typedef struct FAPOFXEQParameters +{ + float FrequencyCenter0; + float Gain0; + float Bandwidth0; + float FrequencyCenter1; + float Gain1; + float Bandwidth1; + float FrequencyCenter2; + float Gain2; + float Bandwidth2; + float FrequencyCenter3; + float Gain3; + float Bandwidth3; +} FAPOFXEQParameters; + +/* See FAPOFXMASTERINGLIMITER_* constants below. */ +typedef struct FAPOFXMasteringLimiterParameters +{ + uint32_t Release; /* In milliseconds */ + uint32_t Loudness; /* In... uh, MSDN doesn't actually say what. */ +} FAPOFXMasteringLimiterParameters; + +/* See FAPOFXREVERB_* constants below. + * Both parameters are arbitrary and should be treated subjectively. + */ +typedef struct FAPOFXReverbParameters +{ + float Diffusion; + float RoomSize; +} FAPOFXReverbParameters; + +/* See FAPOFXECHO_* constants below. */ +typedef struct FAPOFXEchoParameters +{ + float WetDryMix; /* Percentage of processed signal vs original */ + float Feedback; /* Percentage to feed back into input */ + float Delay; /* In milliseconds */ +} FAPOFXEchoParameters; + +#pragma pack(pop) + +/* Constants */ + +#define FAPOFXEQ_MIN_FRAMERATE 22000 +#define FAPOFXEQ_MAX_FRAMERATE 48000 + +#define FAPOFXEQ_MIN_FREQUENCY_CENTER 20.0f +#define FAPOFXEQ_MAX_FREQUENCY_CENTER 20000.0f +#define FAPOFXEQ_DEFAULT_FREQUENCY_CENTER_0 100.0f +#define FAPOFXEQ_DEFAULT_FREQUENCY_CENTER_1 800.0f +#define FAPOFXEQ_DEFAULT_FREQUENCY_CENTER_2 2000.0f +#define FAPOFXEQ_DEFAULT_FREQUENCY_CENTER_3 10000.0f + +#define FAPOFXEQ_MIN_GAIN 0.126f +#define FAPOFXEQ_MAX_GAIN 7.94f +#define FAPOFXEQ_DEFAULT_GAIN 1.0f + +#define FAPOFXEQ_MIN_BANDWIDTH 0.1f +#define FAPOFXEQ_MAX_BANDWIDTH 2.0f +#define FAPOFXEQ_DEFAULT_BANDWIDTH 1.0f + +#define FAPOFXMASTERINGLIMITER_MIN_RELEASE 1 +#define FAPOFXMASTERINGLIMITER_MAX_RELEASE 20 +#define FAPOFXMASTERINGLIMITER_DEFAULT_RELEASE 6 + +#define FAPOFXMASTERINGLIMITER_MIN_LOUDNESS 1 +#define FAPOFXMASTERINGLIMITER_MAX_LOUDNESS 1800 +#define FAPOFXMASTERINGLIMITER_DEFAULT_LOUDNESS 1000 + +#define FAPOFXREVERB_MIN_DIFFUSION 0.0f +#define FAPOFXREVERB_MAX_DIFFUSION 1.0f +#define FAPOFXREVERB_DEFAULT_DIFFUSION 0.9f + +#define FAPOFXREVERB_MIN_ROOMSIZE 0.0001f +#define FAPOFXREVERB_MAX_ROOMSIZE 1.0f +#define FAPOFXREVERB_DEFAULT_ROOMSIZE 0.6f + +#define FAPOFXECHO_MIN_WETDRYMIX 0.0f +#define FAPOFXECHO_MAX_WETDRYMIX 1.0f +#define FAPOFXECHO_DEFAULT_WETDRYMIX 0.5f + +#define FAPOFXECHO_MIN_FEEDBACK 0.0f +#define FAPOFXECHO_MAX_FEEDBACK 1.0f +#define FAPOFXECHO_DEFAULT_FEEDBACK 0.5f + +#define FAPOFXECHO_MIN_DELAY 1.0f +#define FAPOFXECHO_MAX_DELAY 2000.0f +#define FAPOFXECHO_DEFAULT_DELAY 500.0f + +/* Functions */ + +/* Creates an effect from the pre-made FAPOFX effect library. + * + * clsid: A reference to one of the FAPOFX_CLSID_* GUIDs + * pEffect: Filled with the resulting FAPO object + * pInitData: Starting parameters, pass NULL to use the default values + * InitDataByteSize: Parameter struct size, pass 0 if pInitData is NULL + * + * Returns 0 on success. + */ +FAPOFXAPI uint32_t FAPOFX_CreateFX( + const FAudioGUID *clsid, + FAPO **pEffect, + const void *pInitData, + uint32_t InitDataByteSize +); + +/* See "extensions/CustomAllocatorEXT.txt" for more details. */ +FAPOFXAPI uint32_t FAPOFX_CreateFXWithCustomAllocatorEXT( + const FAudioGUID *clsid, + FAPO **pEffect, + const void *pInitData, + uint32_t InitDataByteSize, + FAudioMallocFunc customMalloc, + FAudioFreeFunc customFree, + FAudioReallocFunc customRealloc +); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* FAPOFX_H */ + +/* vim: set noexpandtab shiftwidth=8 tabstop=8: */ diff --git a/dlls/xaudio2_7/FAudio/FAudio.h b/dlls/xaudio2_7/FAudio/FAudio.h new file mode 100644 index 00000000000..96f07d892f2 --- /dev/null +++ b/dlls/xaudio2_7/FAudio/FAudio.h @@ -0,0 +1,1322 @@ +/* FAudio - XAudio Reimplementation for FNA + * + * Copyright (c) 2011-2021 Ethan Lee, Luigi Auriemma, and the MonoGame Team + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee flibitijibibo@flibitijibibo.com + * + */ + +#ifndef FAUDIO_H +#define FAUDIO_H + +#ifdef _WIN32 +#define FAUDIOAPI __declspec(dllexport) +#define FAUDIOCALL __cdecl +#else +#define FAUDIOAPI +#define FAUDIOCALL +#endif + +#ifdef _MSC_VER +#define FAUDIODEPRECATED(msg) __declspec(deprecated(msg)) +#else +#define FAUDIODEPRECATED(msg) __attribute__((deprecated(msg))) +#endif + +/* -Wpedantic nameless union/struct silencing */ +#ifndef FAUDIONAMELESS +#ifdef __GNUC__ +#define FAUDIONAMELESS __extension__ +#else +#define FAUDIONAMELESS +#endif /* __GNUC__ */ +#endif /* FAUDIONAMELESS */ + +#include <stdint.h> +#include <stddef.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Type Declarations */ + +typedef struct FAudio FAudio; +typedef struct FAudioVoice FAudioVoice; +typedef FAudioVoice FAudioSourceVoice; +typedef FAudioVoice FAudioSubmixVoice; +typedef FAudioVoice FAudioMasteringVoice; +typedef struct FAudioEngineCallback FAudioEngineCallback; +typedef struct FAudioVoiceCallback FAudioVoiceCallback; + +/* Enumerations */ + +typedef enum FAudioDeviceRole +{ + FAudioNotDefaultDevice = 0x0, + FAudioDefaultConsoleDevice = 0x1, + FAudioDefaultMultimediaDevice = 0x2, + FAudioDefaultCommunicationsDevice = 0x4, + FAudioDefaultGameDevice = 0x8, + FAudioGlobalDefaultDevice = 0xF, + FAudioInvalidDeviceRole = ~FAudioGlobalDefaultDevice +} FAudioDeviceRole; + +typedef enum FAudioFilterType +{ + FAudioLowPassFilter, + FAudioBandPassFilter, + FAudioHighPassFilter, + FAudioNotchFilter +} FAudioFilterType; + +typedef enum FAudioStreamCategory +{ + FAudioStreamCategory_Other, + FAudioStreamCategory_ForegroundOnlyMedia, + FAudioStreamCategory_BackgroundCapableMedia, + FAudioStreamCategory_Communications, + FAudioStreamCategory_Alerts, + FAudioStreamCategory_SoundEffects, + FAudioStreamCategory_GameEffects, + FAudioStreamCategory_GameMedia, + FAudioStreamCategory_GameChat, + FAudioStreamCategory_Speech, + FAudioStreamCategory_Movie, + FAudioStreamCategory_Media +} FAudioStreamCategory; + +/* FIXME: The original enum violates ISO C and is platform specific anyway... */ +typedef uint32_t FAudioProcessor; +#define FAUDIO_DEFAULT_PROCESSOR 0xFFFFFFFF + +/* Structures */ + +#pragma pack(push, 1) + +typedef struct FAudioGUID +{ + uint32_t Data1; + uint16_t Data2; + uint16_t Data3; + uint8_t Data4[8]; +} FAudioGUID; + +/* See MSDN: + * https://msdn.microsoft.com/en-us/library/windows/desktop/dd390970%28v=vs.85%... + */ +typedef struct FAudioWaveFormatEx +{ + uint16_t wFormatTag; + uint16_t nChannels; + uint32_t nSamplesPerSec; + uint32_t nAvgBytesPerSec; + uint16_t nBlockAlign; + uint16_t wBitsPerSample; + uint16_t cbSize; +} FAudioWaveFormatEx; + +/* See MSDN: + * https://msdn.microsoft.com/en-us/library/windows/desktop/dd390971(v=vs.85).a... + */ +typedef struct FAudioWaveFormatExtensible +{ + FAudioWaveFormatEx Format; + union + { + uint16_t wValidBitsPerSample; + uint16_t wSamplesPerBlock; + uint16_t wReserved; + } Samples; + uint32_t dwChannelMask; + FAudioGUID SubFormat; +} FAudioWaveFormatExtensible; + +typedef struct FAudioADPCMCoefSet +{ + int16_t iCoef1; + int16_t iCoef2; +} FAudioADPCMCoefSet; + +typedef struct FAudioADPCMWaveFormat +{ + FAudioWaveFormatEx wfx; + uint16_t wSamplesPerBlock; + uint16_t wNumCoef; + + /* MSVC warns on empty arrays in structs */ + #ifdef _MSC_VER + #pragma warning(push) + #pragma warning(disable: 4200) + #endif + + FAudioADPCMCoefSet aCoef[]; + /* MSADPCM has 7 coefficient pairs: + * { + * { 256, 0 }, + * { 512, -256 }, + * { 0, 0 }, + * { 192, 64 }, + * { 240, 0 }, + * { 460, -208 }, + * { 392, -232 } + * } + */ + + #ifdef _MSC_VER + #pragma warning(pop) + #endif +} FAudioADPCMWaveFormat; + +typedef struct FAudioDeviceDetails +{ + int16_t DeviceID[256]; /* Win32 wchar_t */ + int16_t DisplayName[256]; /* Win32 wchar_t */ + FAudioDeviceRole Role; + FAudioWaveFormatExtensible OutputFormat; +} FAudioDeviceDetails; + +typedef struct FAudioVoiceDetails +{ + uint32_t CreationFlags; + uint32_t ActiveFlags; + uint32_t InputChannels; + uint32_t InputSampleRate; +} FAudioVoiceDetails; + +typedef struct FAudioSendDescriptor +{ + uint32_t Flags; /* 0 or FAUDIO_SEND_USEFILTER */ + FAudioVoice *pOutputVoice; +} FAudioSendDescriptor; + +typedef struct FAudioVoiceSends +{ + uint32_t SendCount; + FAudioSendDescriptor *pSends; +} FAudioVoiceSends; + +#ifndef FAPO_DECL +#define FAPO_DECL +typedef struct FAPO FAPO; +#endif /* FAPO_DECL */ + +typedef struct FAudioEffectDescriptor +{ + FAPO *pEffect; + int32_t InitialState; /* 1 - Enabled, 0 - Disabled */ + uint32_t OutputChannels; +} FAudioEffectDescriptor; + +typedef struct FAudioEffectChain +{ + uint32_t EffectCount; + FAudioEffectDescriptor *pEffectDescriptors; +} FAudioEffectChain; + +typedef struct FAudioFilterParameters +{ + FAudioFilterType Type; + float Frequency; /* [0, FAUDIO_MAX_FILTER_FREQUENCY] */ + float OneOverQ; /* [0, FAUDIO_MAX_FILTER_ONEOVERQ] */ +} FAudioFilterParameters; + +typedef struct FAudioBuffer +{ + /* Either 0 or FAUDIO_END_OF_STREAM */ + uint32_t Flags; + /* Pointer to wave data, memory block size. + * Note that pAudioData is not copied; FAudio reads directly from your + * pointer! This pointer must be valid until FAudio has finished using + * it, at which point an OnBufferEnd callback will be generated. + */ + uint32_t AudioBytes; + const uint8_t *pAudioData; + /* Play region, in sample frames. */ + uint32_t PlayBegin; + uint32_t PlayLength; + /* Loop region, in sample frames. + * This can be used to loop a subregion of the wave instead of looping + * the whole thing, i.e. if you have an intro/outro you can set these + * to loop the middle sections instead. If you don't need this, set both + * values to 0. + */ + uint32_t LoopBegin; + uint32_t LoopLength; + /* [0, FAUDIO_LOOP_INFINITE] */ + uint32_t LoopCount; + /* This is sent to callbacks as pBufferContext */ + void *pContext; +} FAudioBuffer; + +typedef struct FAudioBufferWMA +{ + const uint32_t *pDecodedPacketCumulativeBytes; + uint32_t PacketCount; +} FAudioBufferWMA; + +typedef struct FAudioVoiceState +{ + void *pCurrentBufferContext; + uint32_t BuffersQueued; + uint64_t SamplesPlayed; +} FAudioVoiceState; + +typedef struct FAudioPerformanceData +{ + uint64_t AudioCyclesSinceLastQuery; + uint64_t TotalCyclesSinceLastQuery; + uint32_t MinimumCyclesPerQuantum; + uint32_t MaximumCyclesPerQuantum; + uint32_t MemoryUsageInBytes; + uint32_t CurrentLatencyInSamples; + uint32_t GlitchesSinceEngineStarted; + uint32_t ActiveSourceVoiceCount; + uint32_t TotalSourceVoiceCount; + uint32_t ActiveSubmixVoiceCount; + uint32_t ActiveResamplerCount; + uint32_t ActiveMatrixMixCount; + uint32_t ActiveXmaSourceVoices; + uint32_t ActiveXmaStreams; +} FAudioPerformanceData; + +typedef struct FAudioDebugConfiguration +{ + /* See FAUDIO_LOG_* */ + uint32_t TraceMask; + uint32_t BreakMask; + /* 0 or 1 */ + int32_t LogThreadID; + int32_t LogFileline; + int32_t LogFunctionName; + int32_t LogTiming; +} FAudioDebugConfiguration; + +#pragma pack(pop) + +/* This ISN'T packed. Strictly speaking it wouldn't have mattered anyway but eh. + * See https://github.com/microsoft/DirectXTK/issues/256 + */ +typedef struct FAudioXMA2WaveFormatEx +{ + FAudioWaveFormatEx wfx; + uint16_t wNumStreams; + uint32_t dwChannelMask; + uint32_t dwSamplesEncoded; + uint32_t dwBytesPerBlock; + uint32_t dwPlayBegin; + uint32_t dwPlayLength; + uint32_t dwLoopBegin; + uint32_t dwLoopLength; + uint8_t bLoopCount; + uint8_t bEncoderVersion; + uint16_t wBlockCount; +} FAudioXMA2WaveFormat; + +/* Constants */ + +#define FAUDIO_E_OUT_OF_MEMORY 0x8007000e +#define FAUDIO_E_INVALID_ARG 0x80070057 +#define FAUDIO_E_UNSUPPORTED_FORMAT 0x88890008 +#define FAUDIO_E_INVALID_CALL 0x88960001 +#define FAUDIO_E_DEVICE_INVALIDATED 0x88960004 +#define FAPO_E_FORMAT_UNSUPPORTED 0x88970001 + +#define FAUDIO_MAX_BUFFER_BYTES 0x80000000 +#define FAUDIO_MAX_QUEUED_BUFFERS 64 +#define FAUDIO_MAX_AUDIO_CHANNELS 64 +#define FAUDIO_MIN_SAMPLE_RATE 1000 +#define FAUDIO_MAX_SAMPLE_RATE 200000 +#define FAUDIO_MAX_VOLUME_LEVEL 16777216.0f +#define FAUDIO_MIN_FREQ_RATIO (1.0f / 1024.0f) +#define FAUDIO_MAX_FREQ_RATIO 1024.0f +#define FAUDIO_DEFAULT_FREQ_RATIO 2.0f +#define FAUDIO_MAX_FILTER_ONEOVERQ 1.5f +#define FAUDIO_MAX_FILTER_FREQUENCY 1.0f +#define FAUDIO_MAX_LOOP_COUNT 254 + +#define FAUDIO_COMMIT_NOW 0 +#define FAUDIO_COMMIT_ALL 0 +#define FAUDIO_INVALID_OPSET (uint32_t) (-1) +#define FAUDIO_NO_LOOP_REGION 0 +#define FAUDIO_LOOP_INFINITE 255 +#define FAUDIO_DEFAULT_CHANNELS 0 +#define FAUDIO_DEFAULT_SAMPLERATE 0 + +#define FAUDIO_DEBUG_ENGINE 0x0001 +#define FAUDIO_VOICE_NOPITCH 0x0002 +#define FAUDIO_VOICE_NOSRC 0x0004 +#define FAUDIO_VOICE_USEFILTER 0x0008 +#define FAUDIO_VOICE_MUSIC 0x0010 +#define FAUDIO_PLAY_TAILS 0x0020 +#define FAUDIO_END_OF_STREAM 0x0040 +#define FAUDIO_SEND_USEFILTER 0x0080 +#define FAUDIO_VOICE_NOSAMPLESPLAYED 0x0100 +#define FAUDIO_1024_QUANTUM 0x8000 + +#define FAUDIO_DEFAULT_FILTER_TYPE FAudioLowPassFilter +#define FAUDIO_DEFAULT_FILTER_FREQUENCY FAUDIO_MAX_FILTER_FREQUENCY +#define FAUDIO_DEFAULT_FILTER_ONEOVERQ 1.0f + +#define FAUDIO_LOG_ERRORS 0x0001 +#define FAUDIO_LOG_WARNINGS 0x0002 +#define FAUDIO_LOG_INFO 0x0004 +#define FAUDIO_LOG_DETAIL 0x0008 +#define FAUDIO_LOG_API_CALLS 0x0010 +#define FAUDIO_LOG_FUNC_CALLS 0x0020 +#define FAUDIO_LOG_TIMING 0x0040 +#define FAUDIO_LOG_LOCKS 0x0080 +#define FAUDIO_LOG_MEMORY 0x0100 +#define FAUDIO_LOG_STREAMING 0x1000 + +#ifndef _SPEAKER_POSITIONS_ +#define SPEAKER_FRONT_LEFT 0x00000001 +#define SPEAKER_FRONT_RIGHT 0x00000002 +#define SPEAKER_FRONT_CENTER 0x00000004 +#define SPEAKER_LOW_FREQUENCY 0x00000008 +#define SPEAKER_BACK_LEFT 0x00000010 +#define SPEAKER_BACK_RIGHT 0x00000020 +#define SPEAKER_FRONT_LEFT_OF_CENTER 0x00000040 +#define SPEAKER_FRONT_RIGHT_OF_CENTER 0x00000080 +#define SPEAKER_BACK_CENTER 0x00000100 +#define SPEAKER_SIDE_LEFT 0x00000200 +#define SPEAKER_SIDE_RIGHT 0x00000400 +#define SPEAKER_TOP_CENTER 0x00000800 +#define SPEAKER_TOP_FRONT_LEFT 0x00001000 +#define SPEAKER_TOP_FRONT_CENTER 0x00002000 +#define SPEAKER_TOP_FRONT_RIGHT 0x00004000 +#define SPEAKER_TOP_BACK_LEFT 0x00008000 +#define SPEAKER_TOP_BACK_CENTER 0x00010000 +#define SPEAKER_TOP_BACK_RIGHT 0x00020000 +#define _SPEAKER_POSITIONS_ +#endif + +#ifndef SPEAKER_MONO +#define SPEAKER_MONO SPEAKER_FRONT_CENTER +#define SPEAKER_STEREO (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT) +#define SPEAKER_2POINT1 \ + ( SPEAKER_FRONT_LEFT | \ + SPEAKER_FRONT_RIGHT | \ + SPEAKER_LOW_FREQUENCY ) +#define SPEAKER_SURROUND \ + ( SPEAKER_FRONT_LEFT | \ + SPEAKER_FRONT_RIGHT | \ + SPEAKER_FRONT_CENTER | \ + SPEAKER_BACK_CENTER ) +#define SPEAKER_QUAD \ + ( SPEAKER_FRONT_LEFT | \ + SPEAKER_FRONT_RIGHT | \ + SPEAKER_BACK_LEFT | \ + SPEAKER_BACK_RIGHT ) +#define SPEAKER_4POINT1 \ + ( SPEAKER_FRONT_LEFT | \ + SPEAKER_FRONT_RIGHT | \ + SPEAKER_LOW_FREQUENCY | \ + SPEAKER_BACK_LEFT | \ + SPEAKER_BACK_RIGHT ) +#define SPEAKER_5POINT1 \ + ( SPEAKER_FRONT_LEFT | \ + SPEAKER_FRONT_RIGHT | \ + SPEAKER_FRONT_CENTER | \ + SPEAKER_LOW_FREQUENCY | \ + SPEAKER_BACK_LEFT | \ + SPEAKER_BACK_RIGHT ) +#define SPEAKER_7POINT1 \ + ( SPEAKER_FRONT_LEFT | \ + SPEAKER_FRONT_RIGHT | \ + SPEAKER_FRONT_CENTER | \ + SPEAKER_LOW_FREQUENCY | \ + SPEAKER_BACK_LEFT | \ + SPEAKER_BACK_RIGHT | \ + SPEAKER_FRONT_LEFT_OF_CENTER | \ + SPEAKER_FRONT_RIGHT_OF_CENTER ) +#define SPEAKER_5POINT1_SURROUND \ + ( SPEAKER_FRONT_LEFT | \ + SPEAKER_FRONT_RIGHT | \ + SPEAKER_FRONT_CENTER | \ + SPEAKER_LOW_FREQUENCY | \ + SPEAKER_SIDE_LEFT | \ + SPEAKER_SIDE_RIGHT ) +#define SPEAKER_7POINT1_SURROUND \ + ( SPEAKER_FRONT_LEFT | \ + SPEAKER_FRONT_RIGHT | \ + SPEAKER_FRONT_CENTER | \ + SPEAKER_LOW_FREQUENCY | \ + SPEAKER_BACK_LEFT | \ + SPEAKER_BACK_RIGHT | \ + SPEAKER_SIDE_LEFT | \ + SPEAKER_SIDE_RIGHT ) +#define SPEAKER_XBOX SPEAKER_5POINT1 +#endif + +#define FAUDIO_FORMAT_PCM 1 +#define FAUDIO_FORMAT_MSADPCM 2 +#define FAUDIO_FORMAT_IEEE_FLOAT 3 +#define FAUDIO_FORMAT_WMAUDIO2 0x0161 +#define FAUDIO_FORMAT_WMAUDIO3 0x0162 +#define FAUDIO_FORMAT_WMAUDIO_LOSSLESS 0x0163 +#define FAUDIO_FORMAT_XMAUDIO2 0x0166 +#define FAUDIO_FORMAT_EXTENSIBLE 0xFFFE + +extern FAudioGUID DATAFORMAT_SUBTYPE_PCM; +extern FAudioGUID DATAFORMAT_SUBTYPE_IEEE_FLOAT; + +/* FAudio Version API */ + +#define FAUDIO_TARGET_VERSION 8 /* Targeting compatibility with XAudio 2.8 */ + +#define FAUDIO_ABI_VERSION 0 +#define FAUDIO_MAJOR_VERSION 21 +#define FAUDIO_MINOR_VERSION 6 +#define FAUDIO_PATCH_VERSION 0 + +#define FAUDIO_COMPILED_VERSION ( \ + (FAUDIO_ABI_VERSION * 100 * 100 * 100) + \ + (FAUDIO_MAJOR_VERSION * 100 * 100) + \ + (FAUDIO_MINOR_VERSION * 100) + \ + (FAUDIO_PATCH_VERSION) \ +) + +FAUDIOAPI uint32_t FAudioLinkedVersion(void); + +/* FAudio Interface */ + +/* This should be your first FAudio call. + * + * ppFAudio: Filled with the FAudio core context. + * Flags: Can be 0 or FAUDIO_DEBUG_ENGINE. + * XAudio2Processor: Set this to FAUDIO_DEFAULT_PROCESSOR. + * + * Returns 0 on success. + */ +FAUDIOAPI uint32_t FAudioCreate( + FAudio **ppFAudio, + uint32_t Flags, + FAudioProcessor XAudio2Processor +); + +/* See "extensions/COMConstructEXT.txt" for more details */ +FAUDIOAPI uint32_t FAudioCOMConstructEXT(FAudio **ppFAudio, uint8_t version); + +/* Increments a reference counter. When counter is 0, audio is freed. + * Returns the reference count after incrementing. + */ +FAUDIOAPI uint32_t FAudio_AddRef(FAudio *audio); + +/* Decrements a reference counter. When counter is 0, audio is freed. + * Returns the reference count after decrementing. + */ +FAUDIOAPI uint32_t FAudio_Release(FAudio *audio); + +/* Queries the number of sound devices available for use. + * + * pCount: Filled with the number of available sound devices. + * + * Returns 0 on success. + */ +FAUDIOAPI uint32_t FAudio_GetDeviceCount(FAudio *audio, uint32_t *pCount); + +/* Gets basic information about a sound device. + * + * Index: Can be between 0 and the result of GetDeviceCount. + * pDeviceDetails: Filled with the device information. + * + * Returns 0 on success. + */ +FAUDIOAPI uint32_t FAudio_GetDeviceDetails( + FAudio *audio, + uint32_t Index, + FAudioDeviceDetails *pDeviceDetails +); + +/* You don't actually have to call this, unless you're using the COM APIs. + * See the FAudioCreate API for parameter information. + */ +FAUDIOAPI uint32_t FAudio_Initialize( + FAudio *audio, + uint32_t Flags, + FAudioProcessor XAudio2Processor +); + +/* Register a new set of engine callbacks. + * There is no limit to the number of sets, but expect performance to degrade + * if you have a whole bunch of these. You most likely only need one. + * + * pCallback: The completely-initialized FAudioEngineCallback structure. + * + * Returns 0 on success. + */ +FAUDIOAPI uint32_t FAudio_RegisterForCallbacks( + FAudio *audio, + FAudioEngineCallback *pCallback +); + +/* Remove an active set of engine callbacks. + * This checks the pointer value, NOT the callback values! + * + * pCallback: An FAudioEngineCallback structure previously sent to Register. + * + * Returns 0 on success. + */ +FAUDIOAPI void FAudio_UnregisterForCallbacks( + FAudio *audio, + FAudioEngineCallback *pCallback +); + +/* Creates a "source" voice, used to play back wavedata. + * + * ppSourceVoice: Filled with the source voice pointer. + * pSourceFormat: The input wavedata format, see the documentation for + * FAudioWaveFormatEx. + * Flags: Can be 0 or a mix of the following FAUDIO_VOICE_* flags: + * NOPITCH/NOSRC: Resampling is disabled. If you set this, + * the source format sample rate MUST match + * the output voices' input sample rates. + * Also, SetFrequencyRatio will fail. + * USEFILTER: Enables the use of SetFilterParameters. + * MUSIC: Unsupported. + * MaxFrequencyRatio: AKA your max pitch. This allows us to optimize the size + * of the decode/resample cache sizes. For example, if you + * only expect to raise pitch by a single octave, you can + * set this value to 2.0f. 2.0f is the default value. + * Bounds: [FAUDIO_MIN_FREQ_RATIO, FAUDIO_MAX_FREQ_RATIO]. + * pCallback: Voice callbacks, see FAudioVoiceCallback documentation. + * pSendList: List of output voices. If NULL, defaults to master. + * All output voices must have the same sample rate! + * pEffectChain: List of FAPO effects. This value can be NULL. + * + * Returns 0 on success. + */ +FAUDIOAPI uint32_t FAudio_CreateSourceVoice( + FAudio *audio, + FAudioSourceVoice **ppSourceVoice, + const FAudioWaveFormatEx *pSourceFormat, + uint32_t Flags, + float MaxFrequencyRatio, + FAudioVoiceCallback *pCallback, + const FAudioVoiceSends *pSendList, + const FAudioEffectChain *pEffectChain +); + +/* Creates a "submix" voice, used to mix/process input voices. + * The typical use case for this is to perform CPU-intensive tasks on large + * groups of voices all at once. Examples include resampling and FAPO effects. + * + * ppSubmixVoice: Filled with the submix voice pointer. + * InputChannels: Input voices will convert to this channel count. + * InputSampleRate: Input voices will convert to this sample rate. + * Flags: Can be 0 or FAUDIO_VOICE_USEFILTER. + * ProcessingStage: If you have multiple submixes that depend on a specific + * order of processing, you can sort them by setting this + * value to prioritize them. For example, submixes with + * stage 0 will process first, then stage 1, 2, and so on. + * pSendList: List of output voices. If NULL, defaults to master. + * All output voices must have the same sample rate! + * pEffectChain: List of FAPO effects. This value can be NULL. + * + * Returns 0 on success. + */ +FAUDIOAPI uint32_t FAudio_CreateSubmixVoice( + FAudio *audio, + FAudioSubmixVoice **ppSubmixVoice, + uint32_t InputChannels, + uint32_t InputSampleRate, + uint32_t Flags, + uint32_t ProcessingStage, + const FAudioVoiceSends *pSendList, + const FAudioEffectChain *pEffectChain +); + +/* This should be your second FAudio call, unless you care about which device + * you want to use. In that case, see GetDeviceDetails. + * + * ppMasteringVoice: Filled with the mastering voice pointer. + * InputChannels: Device channel count. Can be FAUDIO_DEFAULT_CHANNELS. + * InputSampleRate: Device sample rate. Can be FAUDIO_DEFAULT_SAMPLERATE. + * Flags: This value must be 0. + * DeviceIndex: 0 for the default device. See GetDeviceCount. + * pEffectChain: List of FAPO effects. This value can be NULL. + * + * Returns 0 on success. + */ +FAUDIOAPI uint32_t FAudio_CreateMasteringVoice( + FAudio *audio, + FAudioMasteringVoice **ppMasteringVoice, + uint32_t InputChannels, + uint32_t InputSampleRate, + uint32_t Flags, + uint32_t DeviceIndex, + const FAudioEffectChain *pEffectChain +); + +/* This is the XAudio 2.8+ version of CreateMasteringVoice. + * Right now this doesn't do anything. Don't use this function. + */ +FAUDIOAPI uint32_t FAudio_CreateMasteringVoice8( + FAudio *audio, + FAudioMasteringVoice **ppMasteringVoice, + uint32_t InputChannels, + uint32_t InputSampleRate, + uint32_t Flags, + uint16_t *szDeviceId, + const FAudioEffectChain *pEffectChain, + FAudioStreamCategory StreamCategory +); + +/* Starts the engine, begins processing the audio graph. + * Returns 0 on success. + */ +FAUDIOAPI uint32_t FAudio_StartEngine(FAudio *audio); + +/* Stops the engine and halts all processing. + * The audio device will continue to run, but will produce silence. + * The graph will be frozen until you call StartEngine, where it will then + * resume all processing exactly as it would have had this never been called. + */ +FAUDIOAPI void FAudio_StopEngine(FAudio *audio); + +/* Flushes a batch of FAudio calls compiled with a given "OperationSet" tag. + * This function is based on IXAudio2::CommitChanges from the XAudio2 spec. + * This is useful for pushing calls that need to be done perfectly in sync. For + * example, if you want to play two separate sources at the exact same time, you + * can call FAudioSourceVoice_Start with an OperationSet value of your choice, + * then call CommitChanges with that same value to start the sources together. + * + * OperationSet: Either a value known by you or FAUDIO_COMMIT_ALL + * + * Returns 0 on success. + */ +FAUDIOAPI uint32_t FAudio_CommitOperationSet( + FAudio *audio, + uint32_t OperationSet +); + +/* DO NOT USE THIS FUNCTION OR I SWEAR TO GOD */ +FAUDIODEPRECATED("This function will break your program! Use FAudio_CommitOperationSet instead!") +FAUDIOAPI uint32_t FAudio_CommitChanges(FAudio *audio); + +/* Requests various bits of performance information from the engine. + * + * pPerfData: Filled with the data. See FAudioPerformanceData for details. + */ +FAUDIOAPI void FAudio_GetPerformanceData( + FAudio *audio, + FAudioPerformanceData *pPerfData +); + +/* When using a Debug binary, this lets you configure what information gets + * logged to output. Be careful, this can spit out a LOT of text. + * + * pDebugConfiguration: See FAudioDebugConfiguration for details. + * pReserved: Set this to NULL. + */ +FAUDIOAPI void FAudio_SetDebugConfiguration( + FAudio *audio, + FAudioDebugConfiguration *pDebugConfiguration, + void* pReserved +); + +/* Requests the values that determine's the engine's update size. + * For example, a 48KHz engine with a 1024-sample update period would return + * 1024 for the numerator and 48000 for the denominator. With this information, + * you can determine the precise update size in milliseconds. + * + * quantumNumerator - The engine's update size, in sample frames. + * quantumDenominator - The engine's sample rate, in Hz + */ +FAUDIOAPI void FAudio_GetProcessingQuantum( + FAudio *audio, + uint32_t *quantumNumerator, + uint32_t *quantumDenominator +); + +/* FAudioVoice Interface */ + +/* Requests basic information about a voice. + * + * pVoiceDetails: See FAudioVoiceDetails for details. + */ +FAUDIOAPI void FAudioVoice_GetVoiceDetails( + FAudioVoice *voice, + FAudioVoiceDetails *pVoiceDetails +); + +/* Change the output voices for this voice. + * This function is invalid for mastering voices. + * + * pSendList: List of output voices. If NULL, defaults to master. + * All output voices must have the same sample rate! + * + * Returns 0 on success. + */ +FAUDIOAPI uint32_t FAudioVoice_SetOutputVoices( + FAudioVoice *voice, + const FAudioVoiceSends *pSendList +); + +/* Change/Remove the effect chain for this voice. + * + * pEffectChain: List of FAPO effects. This value can be NULL. + * Note that the final channel counts for this chain MUST + * match the input/output channel count that was + * determined at voice creation time! + * + * Returns 0 on success. + */ +FAUDIOAPI uint32_t FAudioVoice_SetEffectChain( + FAudioVoice *voice, + const FAudioEffectChain *pEffectChain +); + +/* Enables an effect in the effect chain. + * + * EffectIndex: The index of the effect (based on the chain order). + * OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW. + * + * Returns 0 on success. + */ +FAUDIOAPI uint32_t FAudioVoice_EnableEffect( + FAudioVoice *voice, + uint32_t EffectIndex, + uint32_t OperationSet +); + +/* Disables an effect in the effect chain. + * + * EffectIndex: The index of the effect (based on the chain order). + * OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW. + * + * Returns 0 on success. + */ +FAUDIOAPI uint32_t FAudioVoice_DisableEffect( + FAudioVoice *voice, + uint32_t EffectIndex, + uint32_t OperationSet +); + +/* Queries the enabled/disabled state of an effect in the effect chain. + * + * EffectIndex: The index of the effect (based on the chain order). + * pEnabled: Filled with either 1 (Enabled) or 0 (Disabled). + * + * Returns 0 on success. + */ +FAUDIOAPI void FAudioVoice_GetEffectState( + FAudioVoice *voice, + uint32_t EffectIndex, + int32_t *pEnabled +); + +/* Submits a block of memory to be sent to FAPO::SetParameters. + * + * EffectIndex: The index of the effect (based on the chain order). + * pParameters: The values to be copied and submitted to the FAPO. + * ParametersByteSize: This should match what the FAPO expects! + * OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW. + * + * Returns 0 on success. + */ +FAUDIOAPI uint32_t FAudioVoice_SetEffectParameters( + FAudioVoice *voice, + uint32_t EffectIndex, + const void *pParameters, + uint32_t ParametersByteSize, + uint32_t OperationSet +); + +/* Requests the latest parameters from FAPO::GetParameters. + * + * EffectIndex: The index of the effect (based on the chain order). + * pParameters: Filled with the latest parameter values from the FAPO. + * ParametersByteSize: This should match what the FAPO expects! + * + * Returns 0 on success. + */ +FAUDIOAPI uint32_t FAudioVoice_GetEffectParameters( + FAudioVoice *voice, + uint32_t EffectIndex, + void *pParameters, + uint32_t ParametersByteSize +); + +/* Sets the filter variables for a voice. + * This is only valid on voices with the USEFILTER flag. + * + * pParameters: See FAudioFilterParameters for details. + * OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW. + * + * Returns 0 on success. + */ +FAUDIOAPI uint32_t FAudioVoice_SetFilterParameters( + FAudioVoice *voice, + const FAudioFilterParameters *pParameters, + uint32_t OperationSet +); + +/* Requests the filter variables for a voice. + * This is only valid on voices with the USEFILTER flag. + * + * pParameters: See FAudioFilterParameters for details. + */ +FAUDIOAPI void FAudioVoice_GetFilterParameters( + FAudioVoice *voice, + FAudioFilterParameters *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 FAudioFilterParameters for details. + * OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW. + * + * Returns 0 on success. + */ +FAUDIOAPI uint32_t FAudioVoice_SetOutputFilterParameters( + FAudioVoice *voice, + FAudioVoice *pDestinationVoice, + const FAudioFilterParameters *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 FAudioFilterParameters for details. + */ +FAUDIOAPI void FAudioVoice_GetOutputFilterParameters( + FAudioVoice *voice, + FAudioVoice *pDestinationVoice, + FAudioFilterParameters *pParameters +); + +/* Sets the global volume of a voice. + * + * Volume: Amplitude ratio. 1.0f is default, 0.0f is silence. + * Note that you can actually set volume < 0.0f! + * Bounds: [-FAUDIO_MAX_VOLUME_LEVEL, FAUDIO_MAX_VOLUME_LEVEL] + * OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW. + * + * Returns 0 on success. + */ +FAUDIOAPI uint32_t FAudioVoice_SetVolume( + FAudioVoice *voice, + float Volume, + uint32_t OperationSet +); + +/* Requests the global volume of a voice. + * + * pVolume: Filled with the current voice amplitude ratio. + */ +FAUDIOAPI void FAudioVoice_GetVolume( + FAudioVoice *voice, + float *pVolume +); + +/* Sets the per-channel volumes of a voice. + * + * Channels: Must match the channel count of this voice! + * pVolumes: Amplitude ratios for each channel. Same as SetVolume. + * OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW. + * + * Returns 0 on success. + */ +FAUDIOAPI uint32_t FAudioVoice_SetChannelVolumes( + FAudioVoice *voice, + uint32_t Channels, + const float *pVolumes, + uint32_t OperationSet +); + +/* Requests the per-channel volumes of a voice. + * + * Channels: Must match the channel count of this voice! + * pVolumes: Filled with the current channel amplitude ratios. + */ +FAUDIOAPI void FAudioVoice_GetChannelVolumes( + FAudioVoice *voice, + uint32_t Channels, + float *pVolumes +); + +/* Sets the volumes of a send's output channels. The matrix is based on the + * voice's input channels. For example, the default matrix for a 2-channel + * source and a 2-channel output voice is as follows: + * [0] = 1.0f; <- Left input, left output + * [1] = 0.0f; <- Right input, left output + * [2] = 0.0f; <- Left input, right output + * [3] = 1.0f; <- Right input, right output + * This is typically only used for panning or 3D sound (via F3DAudio). + * + * pDestinationVoice: An output voice from the voice's send list. + * SourceChannels: Must match the voice's input channel count! + * DestinationChannels: Must match the destination's input channel count! + * pLevelMatrix: A float[SourceChannels * DestinationChannels]. + * OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW. + * + * Returns 0 on success. + */ +FAUDIOAPI uint32_t FAudioVoice_SetOutputMatrix( + FAudioVoice *voice, + FAudioVoice *pDestinationVoice, + uint32_t SourceChannels, + uint32_t DestinationChannels, + const float *pLevelMatrix, + uint32_t OperationSet +); + +/* Gets the volumes of a send's output channels. See SetOutputMatrix. + * + * pDestinationVoice: An output voice from the voice's send list. + * SourceChannels: Must match the voice's input channel count! + * DestinationChannels: Must match the voice's output channel count! + * pLevelMatrix: A float[SourceChannels * DestinationChannels]. + */ +FAUDIOAPI void FAudioVoice_GetOutputMatrix( + FAudioVoice *voice, + FAudioVoice *pDestinationVoice, + uint32_t SourceChannels, + uint32_t DestinationChannels, + float *pLevelMatrix +); + +/* Removes this voice from the audio graph and frees memory. */ +FAUDIOAPI void FAudioVoice_DestroyVoice(FAudioVoice *voice); + +/* FAudioSourceVoice Interface */ + +/* Starts processing for a source voice. + * + * Flags: Must be 0. + * OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW. + * + * Returns 0 on success. + */ +FAUDIOAPI uint32_t FAudioSourceVoice_Start( + FAudioSourceVoice *voice, + uint32_t Flags, + uint32_t OperationSet +); + +/* Pauses processing for a source voice. Yes, I said pausing. + * If you want to _actually_ stop, call FlushSourceBuffers next. + * + * Flags: Can be 0 or FAUDIO_PLAY_TAILS, which allows effects to + * keep emitting output even after processing has stopped. + * OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW. + * + * Returns 0 on success. + */ +FAUDIOAPI uint32_t FAudioSourceVoice_Stop( + FAudioSourceVoice *voice, + uint32_t Flags, + uint32_t OperationSet +); + +/* Submits a block of wavedata for the source to process. + * + * pBuffer: See FAudioBuffer for details. + * pBufferWMA: See FAudioBufferWMA for details. (Also, don't use WMA.) + * + * Returns 0 on success. + */ +FAUDIOAPI uint32_t FAudioSourceVoice_SubmitSourceBuffer( + FAudioSourceVoice *voice, + const FAudioBuffer *pBuffer, + const FAudioBufferWMA *pBufferWMA +); + +/* Removes all buffers from a source, with a minor exception. + * If the voice is still playing, the active buffer is left alone. + * All buffers that are removed will spawn an OnBufferEnd callback. + * + * Returns 0 on success. + */ +FAUDIOAPI uint32_t FAudioSourceVoice_FlushSourceBuffers( + FAudioSourceVoice *voice +); + +/* Takes the last buffer currently queued and sets the END_OF_STREAM flag. + * + * Returns 0 on success. + */ +FAUDIOAPI uint32_t FAudioSourceVoice_Discontinuity( + FAudioSourceVoice *voice +); + +/* Sets the loop count of the active buffer to 0. + * + * OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW. + * + * Returns 0 on success. + */ +FAUDIOAPI uint32_t FAudioSourceVoice_ExitLoop( + FAudioSourceVoice *voice, + uint32_t OperationSet +); + +/* Requests the state and some basic statistics for this source. + * + * pVoiceState: See FAudioVoiceState for details. + * Flags: Can be 0 or FAUDIO_VOICE_NOSAMPLESPLAYED. + */ +FAUDIOAPI void FAudioSourceVoice_GetState( + FAudioSourceVoice *voice, + FAudioVoiceState *pVoiceState, + uint32_t Flags +); + +/* Sets the frequency ratio (fancy phrase for pitch) of this source. + * + * Ratio: The frequency ratio, must be <= MaxFrequencyRatio. + * OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW. + * + * Returns 0 on success. + */ +FAUDIOAPI uint32_t FAudioSourceVoice_SetFrequencyRatio( + FAudioSourceVoice *voice, + float Ratio, + uint32_t OperationSet +); + +/* Requests the frequency ratio (fancy phrase for pitch) of this source. + * + * pRatio: Filled with the frequency ratio. + */ +FAUDIOAPI void FAudioSourceVoice_GetFrequencyRatio( + FAudioSourceVoice *voice, + float *pRatio +); + +/* Resets the core sample rate of this source. + * You probably don't want this, it's more likely you want SetFrequencyRatio. + * This is used to recycle voices without having to constantly reallocate them. + * For example, if you have wavedata that's all float32 mono, but the sample + * rates are different, you can take a source that was being used for a 48KHz + * wave and call this so it can be used for a 44.1KHz wave. + * + * NewSourceSampleRate: The new sample rate for this source. + * + * Returns 0 on success. + */ +FAUDIOAPI uint32_t FAudioSourceVoice_SetSourceSampleRate( + FAudioSourceVoice *voice, + uint32_t NewSourceSampleRate +); + +/* FAudioMasteringVoice Interface */ + +/* Requests the channel mask for the mastering voice. + * This is typically used with F3DAudioInitialize, but you may find it + * interesting if you want to see the user's basic speaker layout. + * + * pChannelMask: Filled with the channel mask. + * + * Returns 0 on success. + */ +FAUDIOAPI uint32_t FAudioMasteringVoice_GetChannelMask( + FAudioMasteringVoice *voice, + uint32_t *pChannelMask +); + +/* FAudioEngineCallback Interface */ + +/* If something horrible happens, this will be called. + * + * Error: The error code that spawned this callback. + */ +typedef void (FAUDIOCALL * OnCriticalErrorFunc)( + FAudioEngineCallback *callback, + uint32_t Error +); + +/* This is called at the end of a processing update. */ +typedef void (FAUDIOCALL * OnProcessingPassEndFunc)( + FAudioEngineCallback *callback +); + +/* This is called at the beginning of a processing update. */ +typedef void (FAUDIOCALL * OnProcessingPassStartFunc)( + FAudioEngineCallback *callback +); + +struct FAudioEngineCallback +{ + OnCriticalErrorFunc OnCriticalError; + OnProcessingPassEndFunc OnProcessingPassEnd; + OnProcessingPassStartFunc OnProcessingPassStart; +}; + +/* FAudioVoiceCallback Interface */ + +/* When a buffer is no longer in use, this is called. + * + * pBufferContext: The pContext for the FAudioBuffer in question. + */ +typedef void (FAUDIOCALL * OnBufferEndFunc)( + FAudioVoiceCallback *callback, + void *pBufferContext +); + +/* When a buffer is now being used, this is called. + * + * pBufferContext: The pContext for the FAudioBuffer in question. + */ +typedef void (FAUDIOCALL * OnBufferStartFunc)( + FAudioVoiceCallback *callback, + void *pBufferContext +); + +/* When a buffer completes a loop, this is called. + * + * pBufferContext: The pContext for the FAudioBuffer in question. + */ +typedef void (FAUDIOCALL * OnLoopEndFunc)( + FAudioVoiceCallback *callback, + void *pBufferContext +); + +/* When a buffer that has the END_OF_STREAM flag is finished, this is called. */ +typedef void (FAUDIOCALL * OnStreamEndFunc)( + FAudioVoiceCallback *callback +); + +/* If something horrible happens to a voice, this is called. + * + * pBufferContext: The pContext for the FAudioBuffer in question. + * Error: The error code that spawned this callback. + */ +typedef void (FAUDIOCALL * OnVoiceErrorFunc)( + FAudioVoiceCallback *callback, + void *pBufferContext, + uint32_t Error +); + +/* When this voice is done being processed, this is called. */ +typedef void (FAUDIOCALL * OnVoiceProcessingPassEndFunc)( + FAudioVoiceCallback *callback +); + +/* When a voice is about to start being processed, this is called. + * + * BytesRequested: The number of bytes needed from the application to + * complete a full update. For example, if we need 512 + * frames for a whole update, and the voice is a float32 + * stereo source, BytesRequired will be 4096. + */ +typedef void (FAUDIOCALL * OnVoiceProcessingPassStartFunc)( + FAudioVoiceCallback *callback, + uint32_t BytesRequired +); + +struct FAudioVoiceCallback +{ + OnBufferEndFunc OnBufferEnd; + OnBufferStartFunc OnBufferStart; + OnLoopEndFunc OnLoopEnd; + OnStreamEndFunc OnStreamEnd; + OnVoiceErrorFunc OnVoiceError; + OnVoiceProcessingPassEndFunc OnVoiceProcessingPassEnd; + OnVoiceProcessingPassStartFunc OnVoiceProcessingPassStart; +}; + +/* FAudio Custom Allocator API + * See "extensions/CustomAllocatorEXT.txt" for more information. + */ + +typedef void* (FAUDIOCALL * FAudioMallocFunc)(size_t size); +typedef void (FAUDIOCALL * FAudioFreeFunc)(void* ptr); +typedef void* (FAUDIOCALL * FAudioReallocFunc)(void* ptr, size_t size); + +FAUDIOAPI uint32_t FAudioCreateWithCustomAllocatorEXT( + FAudio **ppFAudio, + uint32_t Flags, + FAudioProcessor XAudio2Processor, + FAudioMallocFunc customMalloc, + FAudioFreeFunc customFree, + FAudioReallocFunc customRealloc +); +FAUDIOAPI uint32_t FAudioCOMConstructWithCustomAllocatorEXT( + FAudio **ppFAudio, + uint8_t version, + FAudioMallocFunc customMalloc, + FAudioFreeFunc customFree, + FAudioReallocFunc customRealloc +); + +/* FAudio Engine Procedure API + * See "extensions/EngineProcedureEXT.txt" for more information. + */ +typedef void (FAUDIOCALL *FAudioEngineCallEXT)(FAudio *audio, float *output); +typedef void (FAUDIOCALL *FAudioEngineProcedureEXT)(FAudioEngineCallEXT defaultEngineProc, FAudio *audio, float *output, void *user); + +FAUDIOAPI void FAudio_SetEngineProcedureEXT( + FAudio *audio, + FAudioEngineProcedureEXT clientEngineProc, + void *user +); + + +/* FAudio I/O API */ + +#define FAUDIO_SEEK_SET 0 +#define FAUDIO_SEEK_CUR 1 +#define FAUDIO_SEEK_END 2 +#define FAUDIO_EOF -1 + +typedef size_t (FAUDIOCALL * FAudio_readfunc)( + void *data, + void *dst, + size_t size, + size_t count +); +typedef int64_t (FAUDIOCALL * FAudio_seekfunc)( + void *data, + int64_t offset, + int whence +); +typedef int (FAUDIOCALL * FAudio_closefunc)( + void *data +); + +typedef struct FAudioIOStream +{ + void *data; + FAudio_readfunc read; + FAudio_seekfunc seek; + FAudio_closefunc close; + void *lock; +} FAudioIOStream; + +FAUDIOAPI FAudioIOStream* FAudio_fopen(const char *path); +FAUDIOAPI FAudioIOStream* FAudio_memopen(void *mem, int len); +FAUDIOAPI uint8_t* FAudio_memptr(FAudioIOStream *io, size_t offset); +FAUDIOAPI void FAudio_close(FAudioIOStream *io); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* FAUDIO_H */ + +/* vim: set noexpandtab shiftwidth=8 tabstop=8: */ diff --git a/dlls/xaudio2_7/FAudio/FAudioFX.h b/dlls/xaudio2_7/FAudio/FAudioFX.h new file mode 100644 index 00000000000..22052d33e87 --- /dev/null +++ b/dlls/xaudio2_7/FAudio/FAudioFX.h @@ -0,0 +1,308 @@ +/* FAudio - XAudio Reimplementation for FNA + * + * Copyright (c) 2011-2021 Ethan Lee, Luigi Auriemma, and the MonoGame Team + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee flibitijibibo@flibitijibibo.com + * + */ + +/* This file has no documentation since the MSDN docs are still perfectly fine: + * https://docs.microsoft.com/en-us/windows/desktop/api/xaudio2fx/ + * + * Note, however, that FAudio's Reverb implementation does NOT support the new + * parameters for XAudio 2.9's 7.1 Reverb effect! + */ + +#ifndef FAUDIOFX_H +#define FAUDIOFX_H + +#include "FAudio.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* GUIDs */ + +extern const FAudioGUID FAudioFX_CLSID_AudioVolumeMeter; +extern const FAudioGUID FAudioFX_CLSID_AudioReverb; + +/* Structures */ + +#pragma pack(push, 1) + +typedef struct FAudioFXVolumeMeterLevels +{ + float *pPeakLevels; + float *pRMSLevels; + uint32_t ChannelCount; +} FAudioFXVolumeMeterLevels; + +typedef struct FAudioFXReverbParameters +{ + float WetDryMix; + uint32_t ReflectionsDelay; + uint8_t ReverbDelay; + uint8_t RearDelay; + uint8_t PositionLeft; + uint8_t PositionRight; + uint8_t PositionMatrixLeft; + uint8_t PositionMatrixRight; + uint8_t EarlyDiffusion; + uint8_t LateDiffusion; + uint8_t LowEQGain; + uint8_t LowEQCutoff; + uint8_t HighEQGain; + uint8_t HighEQCutoff; + float RoomFilterFreq; + float RoomFilterMain; + float RoomFilterHF; + float ReflectionsGain; + float ReverbGain; + float DecayTime; + float Density; + float RoomSize; +} FAudioFXReverbParameters; + +typedef struct FAudioFXReverbParameters9 +{ + float WetDryMix; + uint32_t ReflectionsDelay; + uint8_t ReverbDelay; + uint8_t RearDelay; + uint8_t SideDelay; + uint8_t PositionLeft; + uint8_t PositionRight; + uint8_t PositionMatrixLeft; + uint8_t PositionMatrixRight; + uint8_t EarlyDiffusion; + uint8_t LateDiffusion; + uint8_t LowEQGain; + uint8_t LowEQCutoff; + uint8_t HighEQGain; + uint8_t HighEQCutoff; + float RoomFilterFreq; + float RoomFilterMain; + float RoomFilterHF; + float ReflectionsGain; + float ReverbGain; + float DecayTime; + float Density; + float RoomSize; +} FAudioFXReverbParameters9; + +typedef struct FAudioFXReverbI3DL2Parameters +{ + float WetDryMix; + int32_t Room; + int32_t RoomHF; + float RoomRolloffFactor; + float DecayTime; + float DecayHFRatio; + int32_t Reflections; + float ReflectionsDelay; + int32_t Reverb; + float ReverbDelay; + float Diffusion; + float Density; + float HFReference; +} FAudioFXReverbI3DL2Parameters; + +#pragma pack(pop) + +/* Constants */ + +#define FAUDIOFX_DEBUG 1 + +#define FAUDIOFX_REVERB_MIN_FRAMERATE 20000 +#define FAUDIOFX_REVERB_MAX_FRAMERATE 48000 + +#define FAUDIOFX_REVERB_MIN_WET_DRY_MIX 0.0f +#define FAUDIOFX_REVERB_MIN_REFLECTIONS_DELAY 0 +#define FAUDIOFX_REVERB_MIN_REVERB_DELAY 0 +#define FAUDIOFX_REVERB_MIN_REAR_DELAY 0 +#define FAUDIOFX_REVERB_MIN_7POINT1_SIDE_DELAY 0 +#define FAUDIOFX_REVERB_MIN_7POINT1_REAR_DELAY 0 +#define FAUDIOFX_REVERB_MIN_POSITION 0 +#define FAUDIOFX_REVERB_MIN_DIFFUSION 0 +#define FAUDIOFX_REVERB_MIN_LOW_EQ_GAIN 0 +#define FAUDIOFX_REVERB_MIN_LOW_EQ_CUTOFF 0 +#define FAUDIOFX_REVERB_MIN_HIGH_EQ_GAIN 0 +#define FAUDIOFX_REVERB_MIN_HIGH_EQ_CUTOFF 0 +#define FAUDIOFX_REVERB_MIN_ROOM_FILTER_FREQ 20.0f +#define FAUDIOFX_REVERB_MIN_ROOM_FILTER_MAIN -100.0f +#define FAUDIOFX_REVERB_MIN_ROOM_FILTER_HF -100.0f +#define FAUDIOFX_REVERB_MIN_REFLECTIONS_GAIN -100.0f +#define FAUDIOFX_REVERB_MIN_REVERB_GAIN -100.0f +#define FAUDIOFX_REVERB_MIN_DECAY_TIME 0.1f +#define FAUDIOFX_REVERB_MIN_DENSITY 0.0f +#define FAUDIOFX_REVERB_MIN_ROOM_SIZE 0.0f + +#define FAUDIOFX_REVERB_MAX_WET_DRY_MIX 100.0f +#define FAUDIOFX_REVERB_MAX_REFLECTIONS_DELAY 300 +#define FAUDIOFX_REVERB_MAX_REVERB_DELAY 85 +#define FAUDIOFX_REVERB_MAX_REAR_DELAY 5 +#define FAUDIOFX_REVERB_MAX_7POINT1_SIDE_DELAY 5 +#define FAUDIOFX_REVERB_MAX_7POINT1_REAR_DELAY 20 +#define FAUDIOFX_REVERB_MAX_POSITION 30 +#define FAUDIOFX_REVERB_MAX_DIFFUSION 15 +#define FAUDIOFX_REVERB_MAX_LOW_EQ_GAIN 12 +#define FAUDIOFX_REVERB_MAX_LOW_EQ_CUTOFF 9 +#define FAUDIOFX_REVERB_MAX_HIGH_EQ_GAIN 8 +#define FAUDIOFX_REVERB_MAX_HIGH_EQ_CUTOFF 14 +#define FAUDIOFX_REVERB_MAX_ROOM_FILTER_FREQ 20000.0f +#define FAUDIOFX_REVERB_MAX_ROOM_FILTER_MAIN 0.0f +#define FAUDIOFX_REVERB_MAX_ROOM_FILTER_HF 0.0f +#define FAUDIOFX_REVERB_MAX_REFLECTIONS_GAIN 20.0f +#define FAUDIOFX_REVERB_MAX_REVERB_GAIN 20.0f +#define FAUDIOFX_REVERB_MAX_DENSITY 100.0f +#define FAUDIOFX_REVERB_MAX_ROOM_SIZE 100.0f + +#define FAUDIOFX_REVERB_DEFAULT_WET_DRY_MIX 100.0f +#define FAUDIOFX_REVERB_DEFAULT_REFLECTIONS_DELAY 5 +#define FAUDIOFX_REVERB_DEFAULT_REVERB_DELAY 5 +#define FAUDIOFX_REVERB_DEFAULT_REAR_DELAY 5 +#define FAUDIOFX_REVERB_DEFAULT_7POINT1_SIDE_DELAY 5 +#define FAUDIOFX_REVERB_DEFAULT_7POINT1_REAR_DELAY 20 +#define FAUDIOFX_REVERB_DEFAULT_POSITION 6 +#define FAUDIOFX_REVERB_DEFAULT_POSITION_MATRIX 27 +#define FAUDIOFX_REVERB_DEFAULT_EARLY_DIFFUSION 8 +#define FAUDIOFX_REVERB_DEFAULT_LATE_DIFFUSION 8 +#define FAUDIOFX_REVERB_DEFAULT_LOW_EQ_GAIN 8 +#define FAUDIOFX_REVERB_DEFAULT_LOW_EQ_CUTOFF 4 +#define FAUDIOFX_REVERB_DEFAULT_HIGH_EQ_GAIN 8 +#define FAUDIOFX_REVERB_DEFAULT_HIGH_EQ_CUTOFF 4 +#define FAUDIOFX_REVERB_DEFAULT_ROOM_FILTER_FREQ 5000.0f +#define FAUDIOFX_REVERB_DEFAULT_ROOM_FILTER_MAIN 0.0f +#define FAUDIOFX_REVERB_DEFAULT_ROOM_FILTER_HF 0.0f +#define FAUDIOFX_REVERB_DEFAULT_REFLECTIONS_GAIN 0.0f +#define FAUDIOFX_REVERB_DEFAULT_REVERB_GAIN 0.0f +#define FAUDIOFX_REVERB_DEFAULT_DECAY_TIME 1.0f +#define FAUDIOFX_REVERB_DEFAULT_DENSITY 100.0f +#define FAUDIOFX_REVERB_DEFAULT_ROOM_SIZE 100.0f + +#define FAUDIOFX_I3DL2_PRESET_DEFAULT \ + {100,-10000, 0,0.0f, 1.00f,0.50f,-10000,0.020f,-10000,0.040f,100.0f,100.0f,5000.0f} +#define FAUDIOFX_I3DL2_PRESET_GENERIC \ + {100, -1000, -100,0.0f, 1.49f,0.83f, -2602,0.007f, 200,0.011f,100.0f,100.0f,5000.0f} +#define FAUDIOFX_I3DL2_PRESET_PADDEDCELL \ + {100, -1000,-6000,0.0f, 0.17f,0.10f, -1204,0.001f, 207,0.002f,100.0f,100.0f,5000.0f} +#define FAUDIOFX_I3DL2_PRESET_ROOM \ + {100, -1000, -454,0.0f, 0.40f,0.83f, -1646,0.002f, 53,0.003f,100.0f,100.0f,5000.0f} +#define FAUDIOFX_I3DL2_PRESET_BATHROOM \ + {100, -1000,-1200,0.0f, 1.49f,0.54f, -370,0.007f, 1030,0.011f,100.0f, 60.0f,5000.0f} +#define FAUDIOFX_I3DL2_PRESET_LIVINGROOM \ + {100, -1000,-6000,0.0f, 0.50f,0.10f, -1376,0.003f, -1104,0.004f,100.0f,100.0f,5000.0f} +#define FAUDIOFX_I3DL2_PRESET_STONEROOM \ + {100, -1000, -300,0.0f, 2.31f,0.64f, -711,0.012f, 83,0.017f,100.0f,100.0f,5000.0f} +#define FAUDIOFX_I3DL2_PRESET_AUDITORIUM \ + {100, -1000, -476,0.0f, 4.32f,0.59f, -789,0.020f, -289,0.030f,100.0f,100.0f,5000.0f} +#define FAUDIOFX_I3DL2_PRESET_CONCERTHALL \ + {100, -1000, -500,0.0f, 3.92f,0.70f, -1230,0.020f, -2,0.029f,100.0f,100.0f,5000.0f} +#define FAUDIOFX_I3DL2_PRESET_CAVE \ + {100, -1000, 0,0.0f, 2.91f,1.30f, -602,0.015f, -302,0.022f,100.0f,100.0f,5000.0f} +#define FAUDIOFX_I3DL2_PRESET_ARENA \ + {100, -1000, -698,0.0f, 7.24f,0.33f, -1166,0.020f, 16,0.030f,100.0f,100.0f,5000.0f} +#define FAUDIOFX_I3DL2_PRESET_HANGAR \ + {100, -1000,-1000,0.0f,10.05f,0.23f, -602,0.020f, 198,0.030f,100.0f,100.0f,5000.0f} +#define FAUDIOFX_I3DL2_PRESET_CARPETEDHALLWAY \ + {100, -1000,-4000,0.0f, 0.30f,0.10f, -1831,0.002f, -1630,0.030f,100.0f,100.0f,5000.0f} +#define FAUDIOFX_I3DL2_PRESET_HALLWAY \ + {100, -1000, -300,0.0f, 1.49f,0.59f, -1219,0.007f, 441,0.011f,100.0f,100.0f,5000.0f} +#define FAUDIOFX_I3DL2_PRESET_STONECORRIDOR \ + {100, -1000, -237,0.0f, 2.70f,0.79f, -1214,0.013f, 395,0.020f,100.0f,100.0f,5000.0f} +#define FAUDIOFX_I3DL2_PRESET_ALLEY \ + {100, -1000, -270,0.0f, 1.49f,0.86f, -1204,0.007f, -4,0.011f,100.0f,100.0f,5000.0f} +#define FAUDIOFX_I3DL2_PRESET_FOREST \ + {100, -1000,-3300,0.0f, 1.49f,0.54f, -2560,0.162f, -613,0.088f, 79.0f,100.0f,5000.0f} +#define FAUDIOFX_I3DL2_PRESET_CITY \ + {100, -1000, -800,0.0f, 1.49f,0.67f, -2273,0.007f, -2217,0.011f, 50.0f,100.0f,5000.0f} +#define FAUDIOFX_I3DL2_PRESET_MOUNTAINS \ + {100, -1000,-2500,0.0f, 1.49f,0.21f, -2780,0.300f, -2014,0.100f, 27.0f,100.0f,5000.0f} +#define FAUDIOFX_I3DL2_PRESET_QUARRY \ + {100, -1000,-1000,0.0f, 1.49f,0.83f,-10000,0.061f, 500,0.025f,100.0f,100.0f,5000.0f} +#define FAUDIOFX_I3DL2_PRESET_PLAIN \ + {100, -1000,-2000,0.0f, 1.49f,0.50f, -2466,0.179f, -2514,0.100f, 21.0f,100.0f,5000.0f} +#define FAUDIOFX_I3DL2_PRESET_PARKINGLOT \ + {100, -1000, 0,0.0f, 1.65f,1.50f, -1363,0.008f, -1153,0.012f,100.0f,100.0f,5000.0f} +#define FAUDIOFX_I3DL2_PRESET_SEWERPIPE \ + {100, -1000,-1000,0.0f, 2.81f,0.14f, 429,0.014f, 648,0.021f, 80.0f, 60.0f,5000.0f} +#define FAUDIOFX_I3DL2_PRESET_UNDERWATER \ + {100, -1000,-4000,0.0f, 1.49f,0.10f, -449,0.007f, 1700,0.011f,100.0f,100.0f,5000.0f} +#define FAUDIOFX_I3DL2_PRESET_SMALLROOM \ + {100, -1000, -600,0.0f, 1.10f,0.83f, -400,0.005f, 500,0.010f,100.0f,100.0f,5000.0f} +#define FAUDIOFX_I3DL2_PRESET_MEDIUMROOM \ + {100, -1000, -600,0.0f, 1.30f,0.83f, -1000,0.010f, -200,0.020f,100.0f,100.0f,5000.0f} +#define FAUDIOFX_I3DL2_PRESET_LARGEROOM \ + {100, -1000, -600,0.0f, 1.50f,0.83f, -1600,0.020f, -1000,0.040f,100.0f,100.0f,5000.0f} +#define FAUDIOFX_I3DL2_PRESET_MEDIUMHALL \ + {100, -1000, -600,0.0f, 1.80f,0.70f, -1300,0.015f, -800,0.030f,100.0f,100.0f,5000.0f} +#define FAUDIOFX_I3DL2_PRESET_LARGEHALL \ + {100, -1000, -600,0.0f, 1.80f,0.70f, -2000,0.030f, -1400,0.060f,100.0f,100.0f,5000.0f} +#define FAUDIOFX_I3DL2_PRESET_PLATE \ + {100, -1000, -200,0.0f, 1.30f,0.90f, 0,0.002f, 0,0.010f,100.0f, 75.0f,5000.0f} + +/* Functions */ + +FAUDIOAPI uint32_t FAudioCreateVolumeMeter(FAPO** ppApo, uint32_t Flags); +FAUDIOAPI uint32_t FAudioCreateReverb(FAPO** ppApo, uint32_t Flags); +FAUDIOAPI uint32_t FAudioCreateReverb9(FAPO** ppApo, uint32_t Flags); + +/* See "extensions/CustomAllocatorEXT.txt" for more information. */ +FAUDIOAPI uint32_t FAudioCreateVolumeMeterWithCustomAllocatorEXT( + FAPO** ppApo, + uint32_t Flags, + FAudioMallocFunc customMalloc, + FAudioFreeFunc customFree, + FAudioReallocFunc customRealloc +); +FAUDIOAPI uint32_t FAudioCreateReverbWithCustomAllocatorEXT( + FAPO** ppApo, + uint32_t Flags, + FAudioMallocFunc customMalloc, + FAudioFreeFunc customFree, + FAudioReallocFunc customRealloc +); +FAUDIOAPI uint32_t FAudioCreateReverb9WithCustomAllocatorEXT( + FAPO** ppApo, + uint32_t Flags, + FAudioMallocFunc customMalloc, + FAudioFreeFunc customFree, + FAudioReallocFunc customRealloc +); + +FAUDIOAPI void ReverbConvertI3DL2ToNative( + const FAudioFXReverbI3DL2Parameters *pI3DL2, + FAudioFXReverbParameters *pNative +); +FAUDIOAPI void ReverbConvertI3DL2ToNative9( + const FAudioFXReverbI3DL2Parameters *pI3DL2, + FAudioFXReverbParameters9 *pNative, + int32_t sevenDotOneReverb +); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* FAUDIOFX_H */ + +/* vim: set noexpandtab shiftwidth=8 tabstop=8: */