Commit 6b457771 authored by Alexandre Julliard's avatar Alexandre Julliard

libs: Import code from upstream FAudio 21.10.

parent 5329da61
......@@ -711,6 +711,8 @@ JPEG_PE_LIBS
JPEG_PE_CFLAGS
GSM_PE_LIBS
GSM_PE_CFLAGS
FAUDIO_PE_LIBS
FAUDIO_PE_CFLAGS
EXCESS_PRECISION_CFLAGS
CROSSDEBUG
DELAYLOADFLAG
......@@ -1780,6 +1782,7 @@ enable_dmoguids
enable_dxerr8
enable_dxerr9
enable_dxguid
enable_faudio
enable_gsm
enable_jpeg
enable_jxr
......@@ -1926,6 +1929,8 @@ CPP
OBJC
OBJCFLAGS
OBJCPP
FAUDIO_PE_CFLAGS
FAUDIO_PE_LIBS
GSM_PE_CFLAGS
GSM_PE_LIBS
JPEG_PE_CFLAGS
......@@ -2708,6 +2713,11 @@ Some influential environment variables:
OBJC Objective C compiler command
OBJCFLAGS Objective C compiler flags
OBJCPP Objective C preprocessor
FAUDIO_PE_CFLAGS
C compiler flags for the PE faudio, overriding the bundled
version
FAUDIO_PE_LIBS
Linker flags for the PE faudio, overriding the bundled version
GSM_PE_CFLAGS
C compiler flags for the PE gsm, overriding the bundled version
GSM_PE_LIBS Linker flags for the PE gsm, overriding the bundled version
......@@ -10680,6 +10690,19 @@ esac
fi
if ${FAUDIO_PE_CFLAGS:+false} :; then :
FAUDIO_PE_CFLAGS="-I\$(top_srcdir)/libs/faudio/include"
else
enable_faudio=no
fi
if ${FAUDIO_PE_LIBS:+false} :; then :
FAUDIO_PE_LIBS="faudio mfplat mfreadwrite mfuuid propsys"
else
enable_faudio=no
fi
$as_echo "$as_me:${as_lineno-$LINENO}: faudio cflags: $FAUDIO_PE_CFLAGS" >&5
$as_echo "$as_me:${as_lineno-$LINENO}: faudio libs: $FAUDIO_PE_LIBS" >&5
if ${GSM_PE_CFLAGS:+false} :; then :
GSM_PE_CFLAGS="-I\$(top_srcdir)/libs/gsm/inc"
else
......@@ -18754,6 +18777,8 @@ QUICKTIME_LIBS = $QUICKTIME_LIBS
CARBON_LIBS = $CARBON_LIBS
METAL_LIBS = $METAL_LIBS
EXCESS_PRECISION_CFLAGS = $EXCESS_PRECISION_CFLAGS
FAUDIO_PE_CFLAGS = $FAUDIO_PE_CFLAGS
FAUDIO_PE_LIBS = $FAUDIO_PE_LIBS
GSM_PE_CFLAGS = $GSM_PE_CFLAGS
GSM_PE_LIBS = $GSM_PE_LIBS
JPEG_PE_CFLAGS = $JPEG_PE_CFLAGS
......@@ -20052,6 +20077,7 @@ wine_fn_config_makefile libs/dmoguids enable_dmoguids
wine_fn_config_makefile libs/dxerr8 enable_dxerr8
wine_fn_config_makefile libs/dxerr9 enable_dxerr9
wine_fn_config_makefile libs/dxguid enable_dxguid
wine_fn_config_makefile libs/faudio enable_faudio
wine_fn_config_makefile libs/gsm enable_gsm
wine_fn_config_makefile libs/jpeg enable_jpeg
wine_fn_config_makefile libs/jxr enable_jxr
......
......@@ -1052,6 +1052,7 @@ WINE_NOTICE_WITH(mingw,[test "x$CROSSTARGET" = "x"],
dnl **** External libraries ****
WINE_EXTLIB_FLAGS(FAUDIO, faudio, "faudio mfplat mfreadwrite mfuuid propsys", "-I\$(top_srcdir)/libs/faudio/include")
WINE_EXTLIB_FLAGS(GSM, gsm, gsm, "-I\$(top_srcdir)/libs/gsm/inc")
WINE_EXTLIB_FLAGS(JPEG, jpeg, jpeg, "-I\$(top_srcdir)/libs/jpeg")
WINE_EXTLIB_FLAGS(JXR, jxr, jxr, "-I\$(top_srcdir)/libs/jxr/jxrgluelib -I\$(top_srcdir)/libs/jxr/image/sys")
......@@ -3670,6 +3671,7 @@ WINE_CONFIG_MAKEFILE(libs/dmoguids)
WINE_CONFIG_MAKEFILE(libs/dxerr8)
WINE_CONFIG_MAKEFILE(libs/dxerr9)
WINE_CONFIG_MAKEFILE(libs/dxguid)
WINE_CONFIG_MAKEFILE(libs/faudio)
WINE_CONFIG_MAKEFILE(libs/gsm)
WINE_CONFIG_MAKEFILE(libs/jpeg)
WINE_CONFIG_MAKEFILE(libs/jxr)
......
/* 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>
*
*/
EXTLIB = libfaudio.a
EXTRAINCL = -I$(srcdir)/include
EXTRADEFS = -DFAUDIO_WIN32_PLATFORM -DHAVE_WMADEC
C_SRCS = \
src/F3DAudio.c \
src/FACT.c \
src/FACT3D.c \
src/FACT_internal.c \
src/FAPOBase.c \
src/FAPOFX.c \
src/FAPOFX_echo.c \
src/FAPOFX_eq.c \
src/FAPOFX_masteringlimiter.c \
src/FAPOFX_reverb.c \
src/FAudio.c \
src/FAudioFX_reverb.c \
src/FAudioFX_volumemeter.c \
src/FAudio_internal.c \
src/FAudio_internal_simd.c \
src/FAudio_operationset.c \
src/FAudio_platform_win32.c
/* 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
#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: */
/* 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: */
/* 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: */
/* 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: */
/* 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: */
/* 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>
*
*/
#include "FACT3D.h"
uint32_t FACT3DInitialize(
FACTAudioEngine *pEngine,
F3DAUDIO_HANDLE F3DInstance
) {
float nSpeedOfSound;
FAudioWaveFormatExtensible wfxFinalMixFormat;
if (pEngine == NULL)
{
return 0;
}
FACTAudioEngine_GetGlobalVariable(
pEngine,
FACTAudioEngine_GetGlobalVariableIndex(
pEngine,
"SpeedOfSound"
),
&nSpeedOfSound
);
FACTAudioEngine_GetFinalMixFormat(
pEngine,
&wfxFinalMixFormat
);
F3DAudioInitialize(
wfxFinalMixFormat.dwChannelMask,
nSpeedOfSound,
F3DInstance
);
return 0;
}
uint32_t FACT3DCalculate(
F3DAUDIO_HANDLE F3DInstance,
const F3DAUDIO_LISTENER *pListener,
F3DAUDIO_EMITTER *pEmitter,
F3DAUDIO_DSP_SETTINGS *pDSPSettings
) {
static F3DAUDIO_DISTANCE_CURVE_POINT DefaultCurvePoints[2] =
{
{ 0.0f, 1.0f },
{ 1.0f, 1.0f }
};
static F3DAUDIO_DISTANCE_CURVE DefaultCurve =
{
(F3DAUDIO_DISTANCE_CURVE_POINT*) &DefaultCurvePoints[0], 2
};
if (pListener == NULL || pEmitter == NULL || pDSPSettings == NULL)
{
return 0;
}
if (pEmitter->ChannelCount > 1 && pEmitter->pChannelAzimuths == NULL)
{
pEmitter->ChannelRadius = 1.0f;
if (pEmitter->ChannelCount == 2)
{
pEmitter->pChannelAzimuths = (float*) &aStereoLayout[0];
}
else if (pEmitter->ChannelCount == 3)
{
pEmitter->pChannelAzimuths = (float*) &a2Point1Layout[0];
}
else if (pEmitter->ChannelCount == 4)
{
pEmitter->pChannelAzimuths = (float*) &aQuadLayout[0];
}
else if (pEmitter->ChannelCount == 5)
{
pEmitter->pChannelAzimuths = (float*) &a4Point1Layout[0];
}
else if (pEmitter->ChannelCount == 6)
{
pEmitter->pChannelAzimuths = (float*) &a5Point1Layout[0];
}
else if (pEmitter->ChannelCount == 8)
{
pEmitter->pChannelAzimuths = (float*) &a7Point1Layout[0];
}
else
{
return 0;
}
}
if (pEmitter->pVolumeCurve == NULL)
{
pEmitter->pVolumeCurve = &DefaultCurve;
}
if (pEmitter->pLFECurve == NULL)
{
pEmitter->pLFECurve = &DefaultCurve;
}
F3DAudioCalculate(
F3DInstance,
pListener,
pEmitter,
(
F3DAUDIO_CALCULATE_MATRIX |
F3DAUDIO_CALCULATE_DOPPLER |
F3DAUDIO_CALCULATE_EMITTER_ANGLE
),
pDSPSettings
);
return 0;
}
uint32_t FACT3DApply(
F3DAUDIO_DSP_SETTINGS *pDSPSettings,
FACTCue *pCue
) {
if (pDSPSettings == NULL || pCue == NULL)
{
return 0;
}
FACTCue_SetMatrixCoefficients(
pCue,
pDSPSettings->SrcChannelCount,
pDSPSettings->DstChannelCount,
pDSPSettings->pMatrixCoefficients
);
FACTCue_SetVariable(
pCue,
FACTCue_GetVariableIndex(pCue, "Distance"),
pDSPSettings->EmitterToListenerDistance
);
FACTCue_SetVariable(
pCue,
FACTCue_GetVariableIndex(pCue, "DopplerPitchScalar"),
pDSPSettings->DopplerFactor
);
FACTCue_SetVariable(
pCue,
FACTCue_GetVariableIndex(pCue, "OrientationAngle"),
pDSPSettings->EmitterToListenerAngle * (180.0f / F3DAUDIO_PI)
);
return 0;
}
/* vim: set noexpandtab shiftwidth=8 tabstop=8: */
/* 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>
*
*/
#include "FAPOFX.h"
#include "FAudio_internal.h"
uint32_t FAPOFX_CreateFX(
const FAudioGUID *clsid,
FAPO **pEffect,
const void *pInitData,
uint32_t InitDataByteSize
) {
return FAPOFX_CreateFXWithCustomAllocatorEXT(
clsid,
pEffect,
pInitData,
InitDataByteSize,
FAudio_malloc,
FAudio_free,
FAudio_realloc
);
}
uint32_t FAPOFX_CreateFXWithCustomAllocatorEXT(
const FAudioGUID *clsid,
FAPO **pEffect,
const void *pInitData,
uint32_t InitDataByteSize,
FAudioMallocFunc customMalloc,
FAudioFreeFunc customFree,
FAudioReallocFunc customRealloc
) {
#define CHECK_AND_RETURN(effect) \
if (FAudio_memcmp(clsid, &FAPOFX_CLSID_FX##effect, sizeof(FAudioGUID)) == 0) \
{ \
return FAPOFXCreate##effect( \
pEffect, \
pInitData, \
InitDataByteSize, \
customMalloc, \
customFree, \
customRealloc, \
0 \
); \
} \
else if (FAudio_memcmp(clsid, &FAPOFX_CLSID_FX##effect##_LEGACY, sizeof(FAudioGUID)) == 0) \
{ \
return FAPOFXCreate##effect( \
pEffect, \
pInitData, \
InitDataByteSize, \
customMalloc, \
customFree, \
customRealloc, \
1 \
); \
}
CHECK_AND_RETURN(EQ)
CHECK_AND_RETURN(MasteringLimiter)
CHECK_AND_RETURN(Reverb)
CHECK_AND_RETURN(Echo)
#undef CHECK_AND_RETURN
return -1;
}
/* vim: set noexpandtab shiftwidth=8 tabstop=8: */
/* 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>
*
*/
#include "FAPOFX.h"
#include "FAudio_internal.h"
/* FXEcho FAPO Implementation */
const FAudioGUID FAPOFX_CLSID_FXEcho =
{
0x5039D740,
0xF736,
0x449A,
{
0x84,
0xD3,
0xA5,
0x62,
0x02,
0x55,
0x7B,
0x87
}
};
static FAPORegistrationProperties FXEchoProperties =
{
/* .clsid = */ {0},
/* .FriendlyName = */
{
'F', 'X', 'E', 'c', 'h', 'o', '\0'
},
/*.CopyrightInfo = */
{
'C', 'o', 'p', 'y', 'r', 'i', 'g', 'h', 't', ' ', '(', 'c', ')',
'E', 't', 'h', 'a', 'n', ' ', 'L', 'e', 'e', '\0'
},
/*.MajorVersion = */ 0,
/*.MinorVersion = */ 0,
/*.Flags = */(
FAPO_FLAG_FRAMERATE_MUST_MATCH |
FAPO_FLAG_BITSPERSAMPLE_MUST_MATCH |
FAPO_FLAG_BUFFERCOUNT_MUST_MATCH |
FAPO_FLAG_INPLACE_SUPPORTED |
FAPO_FLAG_INPLACE_REQUIRED
),
/*.MinInputBufferCount = */ 1,
/*.MaxInputBufferCount = */ 1,
/*.MinOutputBufferCount = */ 1,
/*.MaxOutputBufferCount =*/ 1
};
const FAudioGUID FAPOFX_CLSID_FXEcho_LEGACY =
{
0xA90BC001,
0xE897,
0xE897,
{
0x74,
0x39,
0x43,
0x55,
0x00,
0x00,
0x00,
0x03
}
};
static FAPORegistrationProperties FXEchoProperties_LEGACY =
{
/* .clsid = */ {0},
/* .FriendlyName = */
{
'F', 'X', 'E', 'c', 'h', 'o', '\0'
},
/*.CopyrightInfo = */
{
'C', 'o', 'p', 'y', 'r', 'i', 'g', 'h', 't', ' ', '(', 'c', ')',
'E', 't', 'h', 'a', 'n', ' ', 'L', 'e', 'e', '\0'
},
/*.MajorVersion = */ 0,
/*.MinorVersion = */ 0,
/*.Flags = */(
FAPO_FLAG_FRAMERATE_MUST_MATCH |
FAPO_FLAG_BITSPERSAMPLE_MUST_MATCH |
FAPO_FLAG_BUFFERCOUNT_MUST_MATCH |
FAPO_FLAG_INPLACE_SUPPORTED |
FAPO_FLAG_INPLACE_REQUIRED
),
/*.MinInputBufferCount = */ 1,
/*.MaxInputBufferCount = */ 1,
/*.MinOutputBufferCount = */ 1,
/*.MaxOutputBufferCount =*/ 1
};
typedef struct FAPOFXEcho
{
FAPOBase base;
/* TODO */
} FAPOFXEcho;
uint32_t FAPOFXEcho_Initialize(
FAPOFXEcho *fapo,
const void* pData,
uint32_t DataByteSize
) {
#define INITPARAMS(offset) \
FAudio_memcpy( \
fapo->base.m_pParameterBlocks + DataByteSize * offset, \
pData, \
DataByteSize \
);
INITPARAMS(0)
INITPARAMS(1)
INITPARAMS(2)
#undef INITPARAMS
return 0;
}
void FAPOFXEcho_Process(
FAPOFXEcho *fapo,
uint32_t InputProcessParameterCount,
const FAPOProcessBufferParameters* pInputProcessParameters,
uint32_t OutputProcessParameterCount,
FAPOProcessBufferParameters* pOutputProcessParameters,
int32_t IsEnabled
) {
FAPOBase_BeginProcess(&fapo->base);
/* TODO */
FAPOBase_EndProcess(&fapo->base);
}
void FAPOFXEcho_Free(void* fapo)
{
FAPOFXEcho *echo = (FAPOFXEcho*) fapo;
echo->base.pFree(echo->base.m_pParameterBlocks);
echo->base.pFree(fapo);
}
/* Public API */
uint32_t FAPOFXCreateEcho(
FAPO **pEffect,
const void *pInitData,
uint32_t InitDataByteSize,
FAudioMallocFunc customMalloc,
FAudioFreeFunc customFree,
FAudioReallocFunc customRealloc,
uint8_t legacy
) {
const FAPOFXEchoParameters fxdefault =
{
FAPOFXECHO_DEFAULT_WETDRYMIX,
FAPOFXECHO_DEFAULT_FEEDBACK,
FAPOFXECHO_DEFAULT_DELAY
};
/* Allocate... */
FAPOFXEcho *result = (FAPOFXEcho*) customMalloc(
sizeof(FAPOFXEcho)
);
uint8_t *params = (uint8_t*) customMalloc(
sizeof(FAPOFXEchoParameters) * 3
);
if (pInitData == NULL)
{
FAudio_zero(params, sizeof(FAPOFXEchoParameters) * 3);
#define INITPARAMS(offset) \
FAudio_memcpy( \
params + sizeof(FAPOFXEchoParameters) * offset, \
&fxdefault, \
sizeof(FAPOFXEchoParameters) \
);
INITPARAMS(0)
INITPARAMS(1)
INITPARAMS(2)
#undef INITPARAMS
}
else
{
FAudio_assert(InitDataByteSize == sizeof(FAPOFXEchoParameters));
FAudio_memcpy(params, pInitData, InitDataByteSize);
FAudio_memcpy(params + InitDataByteSize, pInitData, InitDataByteSize);
FAudio_memcpy(params + (InitDataByteSize * 2), pInitData, InitDataByteSize);
}
/* Initialize... */
FAudio_memcpy(
&FXEchoProperties_LEGACY.clsid,
&FAPOFX_CLSID_FXEcho_LEGACY,
sizeof(FAudioGUID)
);
FAudio_memcpy(
&FXEchoProperties.clsid,
&FAPOFX_CLSID_FXEcho,
sizeof(FAudioGUID)
);
CreateFAPOBaseWithCustomAllocatorEXT(
&result->base,
legacy ? &FXEchoProperties_LEGACY : &FXEchoProperties,
params,
sizeof(FAPOFXEchoParameters),
0,
customMalloc,
customFree,
customRealloc
);
/* Function table... */
result->base.base.Initialize = (InitializeFunc)
FAPOFXEcho_Initialize;
result->base.base.Process = (ProcessFunc)
FAPOFXEcho_Process;
result->base.Destructor = FAPOFXEcho_Free;
/* Finally. */
*pEffect = &result->base.base;
return 0;
}
/* vim: set noexpandtab shiftwidth=8 tabstop=8: */
/* 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>
*
*/
#include "FAPOFX.h"
#include "FAudio_internal.h"
/* FXEQ FAPO Implementation */
const FAudioGUID FAPOFX_CLSID_FXEQ =
{
0xF5E01117,
0xD6C4,
0x485A,
{
0xA3,
0xF5,
0x69,
0x51,
0x96,
0xF3,
0xDB,
0xFA
}
};
static FAPORegistrationProperties FXEQProperties =
{
/* .clsid = */ {0},
/* .FriendlyName = */
{
'F', 'X', 'E', 'Q', '\0'
},
/*.CopyrightInfo = */
{
'C', 'o', 'p', 'y', 'r', 'i', 'g', 'h', 't', ' ', '(', 'c', ')',
'E', 't', 'h', 'a', 'n', ' ', 'L', 'e', 'e', '\0'
},
/*.MajorVersion = */ 0,
/*.MinorVersion = */ 0,
/*.Flags = */(
FAPO_FLAG_FRAMERATE_MUST_MATCH |
FAPO_FLAG_BITSPERSAMPLE_MUST_MATCH |
FAPO_FLAG_BUFFERCOUNT_MUST_MATCH |
FAPO_FLAG_INPLACE_SUPPORTED |
FAPO_FLAG_INPLACE_REQUIRED
),
/*.MinInputBufferCount = */ 1,
/*.MaxInputBufferCount = */ 1,
/*.MinOutputBufferCount = */ 1,
/*.MaxOutputBufferCount =*/ 1
};
const FAudioGUID FAPOFX_CLSID_FXEQ_LEGACY =
{
0xA90BC001,
0xE897,
0xE897,
{
0x74,
0x39,
0x43,
0x55,
0x00,
0x00,
0x00,
0x00
}
};
static FAPORegistrationProperties FXEQProperties_LEGACY =
{
/* .clsid = */ {0},
/* .FriendlyName = */
{
'F', 'X', 'E', 'Q', '\0'
},
/*.CopyrightInfo = */
{
'C', 'o', 'p', 'y', 'r', 'i', 'g', 'h', 't', ' ', '(', 'c', ')',
'E', 't', 'h', 'a', 'n', ' ', 'L', 'e', 'e', '\0'
},
/*.MajorVersion = */ 0,
/*.MinorVersion = */ 0,
/*.Flags = */(
FAPO_FLAG_FRAMERATE_MUST_MATCH |
FAPO_FLAG_BITSPERSAMPLE_MUST_MATCH |
FAPO_FLAG_BUFFERCOUNT_MUST_MATCH |
FAPO_FLAG_INPLACE_SUPPORTED |
FAPO_FLAG_INPLACE_REQUIRED
),
/*.MinInputBufferCount = */ 1,
/*.MaxInputBufferCount = */ 1,
/*.MinOutputBufferCount = */ 1,
/*.MaxOutputBufferCount =*/ 1
};
typedef struct FAPOFXEQ
{
FAPOBase base;
/* TODO */
} FAPOFXEQ;
uint32_t FAPOFXEQ_Initialize(
FAPOFXEQ *fapo,
const void* pData,
uint32_t DataByteSize
) {
#define INITPARAMS(offset) \
FAudio_memcpy( \
fapo->base.m_pParameterBlocks + DataByteSize * offset, \
pData, \
DataByteSize \
);
INITPARAMS(0)
INITPARAMS(1)
INITPARAMS(2)
#undef INITPARAMS
return 0;
}
void FAPOFXEQ_Process(
FAPOFXEQ *fapo,
uint32_t InputProcessParameterCount,
const FAPOProcessBufferParameters* pInputProcessParameters,
uint32_t OutputProcessParameterCount,
FAPOProcessBufferParameters* pOutputProcessParameters,
int32_t IsEnabled
) {
FAPOBase_BeginProcess(&fapo->base);
/* TODO */
FAPOBase_EndProcess(&fapo->base);
}
void FAPOFXEQ_Free(void* fapo)
{
FAPOFXEQ *eq = (FAPOFXEQ*) fapo;
eq->base.pFree(eq->base.m_pParameterBlocks);
eq->base.pFree(fapo);
}
/* Public API */
uint32_t FAPOFXCreateEQ(
FAPO **pEffect,
const void *pInitData,
uint32_t InitDataByteSize,
FAudioMallocFunc customMalloc,
FAudioFreeFunc customFree,
FAudioReallocFunc customRealloc,
uint8_t legacy
) {
const FAPOFXEQParameters fxdefault =
{
FAPOFXEQ_DEFAULT_FREQUENCY_CENTER_0,
FAPOFXEQ_DEFAULT_GAIN,
FAPOFXEQ_DEFAULT_BANDWIDTH,
FAPOFXEQ_DEFAULT_FREQUENCY_CENTER_1,
FAPOFXEQ_DEFAULT_GAIN,
FAPOFXEQ_DEFAULT_BANDWIDTH,
FAPOFXEQ_DEFAULT_FREQUENCY_CENTER_2,
FAPOFXEQ_DEFAULT_GAIN,
FAPOFXEQ_DEFAULT_BANDWIDTH,
FAPOFXEQ_DEFAULT_FREQUENCY_CENTER_3,
FAPOFXEQ_DEFAULT_GAIN,
FAPOFXEQ_DEFAULT_BANDWIDTH
};
/* Allocate... */
FAPOFXEQ *result = (FAPOFXEQ*) customMalloc(
sizeof(FAPOFXEQ)
);
uint8_t *params = (uint8_t*) customMalloc(
sizeof(FAPOFXEQParameters) * 3
);
if (pInitData == NULL)
{
FAudio_zero(params, sizeof(FAPOFXEQParameters) * 3);
#define INITPARAMS(offset) \
FAudio_memcpy( \
params + sizeof(FAPOFXEQParameters) * offset, \
&fxdefault, \
sizeof(FAPOFXEQParameters) \
);
INITPARAMS(0)
INITPARAMS(1)
INITPARAMS(2)
#undef INITPARAMS
}
else
{
FAudio_assert(InitDataByteSize == sizeof(FAPOFXEQParameters));
FAudio_memcpy(params, pInitData, InitDataByteSize);
FAudio_memcpy(params + InitDataByteSize, pInitData, InitDataByteSize);
FAudio_memcpy(params + (InitDataByteSize * 2), pInitData, InitDataByteSize);
}
/* Initialize... */
FAudio_memcpy(
&FXEQProperties_LEGACY.clsid,
&FAPOFX_CLSID_FXEQ_LEGACY,
sizeof(FAudioGUID)
);
FAudio_memcpy(
&FXEQProperties.clsid,
&FAPOFX_CLSID_FXEQ,
sizeof(FAudioGUID)
);
CreateFAPOBaseWithCustomAllocatorEXT(
&result->base,
legacy ? &FXEQProperties_LEGACY : &FXEQProperties,
params,
sizeof(FAPOFXEQParameters),
0,
customMalloc,
customFree,
customRealloc
);
/* Function table... */
result->base.base.Initialize = (InitializeFunc)
FAPOFXEQ_Initialize;
result->base.base.Process = (ProcessFunc)
FAPOFXEQ_Process;
result->base.Destructor = FAPOFXEQ_Free;
/* Finally. */
*pEffect = &result->base.base;
return 0;
}
/* vim: set noexpandtab shiftwidth=8 tabstop=8: */
/* 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>
*
*/
#include "FAPOFX.h"
#include "FAudio_internal.h"
/* FXMasteringLimiter FAPO Implementation */
const FAudioGUID FAPOFX_CLSID_FXMasteringLimiter =
{
0xC4137916,
0x2BE1,
0x46FD,
{
0x85,
0x99,
0x44,
0x15,
0x36,
0xF4,
0x98,
0x56
}
};
static FAPORegistrationProperties FXMasteringLimiterProperties =
{
/* .clsid = */ {0},
/* .FriendlyName = */
{
'F', 'X', 'M', 'a', 's', 't', 'e', 'r', 'i', 'n', 'g', 'L', 'i', 'm', 'i', 't', 'e', 'r', '\0'
},
/*.CopyrightInfo = */
{
'C', 'o', 'p', 'y', 'r', 'i', 'g', 'h', 't', ' ', '(', 'c', ')',
'E', 't', 'h', 'a', 'n', ' ', 'L', 'e', 'e', '\0'
},
/*.MajorVersion = */ 0,
/*.MinorVersion = */ 0,
/*.Flags = */(
FAPO_FLAG_FRAMERATE_MUST_MATCH |
FAPO_FLAG_BITSPERSAMPLE_MUST_MATCH |
FAPO_FLAG_BUFFERCOUNT_MUST_MATCH |
FAPO_FLAG_INPLACE_SUPPORTED |
FAPO_FLAG_INPLACE_REQUIRED
),
/*.MinInputBufferCount = */ 1,
/*.MaxInputBufferCount = */ 1,
/*.MinOutputBufferCount = */ 1,
/*.MaxOutputBufferCount =*/ 1
};
const FAudioGUID FAPOFX_CLSID_FXMasteringLimiter_LEGACY =
{
0xA90BC001,
0xE897,
0xE897,
{
0x74,
0x39,
0x43,
0x55,
0x00,
0x00,
0x00,
0x01
}
};
static FAPORegistrationProperties FXMasteringLimiterProperties_LEGACY =
{
/* .clsid = */ {0},
/* .FriendlyName = */
{
'F', 'X', 'M', 'a', 's', 't', 'e', 'r', 'i', 'n', 'g', 'L', 'i', 'm', 'i', 't', 'e', 'r', '\0'
},
/*.CopyrightInfo = */
{
'C', 'o', 'p', 'y', 'r', 'i', 'g', 'h', 't', ' ', '(', 'c', ')',
'E', 't', 'h', 'a', 'n', ' ', 'L', 'e', 'e', '\0'
},
/*.MajorVersion = */ 0,
/*.MinorVersion = */ 0,
/*.Flags = */(
FAPO_FLAG_FRAMERATE_MUST_MATCH |
FAPO_FLAG_BITSPERSAMPLE_MUST_MATCH |
FAPO_FLAG_BUFFERCOUNT_MUST_MATCH |
FAPO_FLAG_INPLACE_SUPPORTED |
FAPO_FLAG_INPLACE_REQUIRED
),
/*.MinInputBufferCount = */ 1,
/*.MaxInputBufferCount = */ 1,
/*.MinOutputBufferCount = */ 1,
/*.MaxOutputBufferCount =*/ 1
};
typedef struct FAPOFXMasteringLimiter
{
FAPOBase base;
/* TODO */
} FAPOFXMasteringLimiter;
uint32_t FAPOFXMasteringLimiter_Initialize(
FAPOFXMasteringLimiter *fapo,
const void* pData,
uint32_t DataByteSize
) {
#define INITPARAMS(offset) \
FAudio_memcpy( \
fapo->base.m_pParameterBlocks + DataByteSize * offset, \
pData, \
DataByteSize \
);
INITPARAMS(0)
INITPARAMS(1)
INITPARAMS(2)
#undef INITPARAMS
return 0;
}
void FAPOFXMasteringLimiter_Process(
FAPOFXMasteringLimiter *fapo,
uint32_t InputProcessParameterCount,
const FAPOProcessBufferParameters* pInputProcessParameters,
uint32_t OutputProcessParameterCount,
FAPOProcessBufferParameters* pOutputProcessParameters,
int32_t IsEnabled
) {
FAPOBase_BeginProcess(&fapo->base);
/* TODO */
FAPOBase_EndProcess(&fapo->base);
}
void FAPOFXMasteringLimiter_Free(void* fapo)
{
FAPOFXMasteringLimiter *limiter = (FAPOFXMasteringLimiter*) fapo;
limiter->base.pFree(limiter->base.m_pParameterBlocks);
limiter->base.pFree(fapo);
}
/* Public API */
uint32_t FAPOFXCreateMasteringLimiter(
FAPO **pEffect,
const void *pInitData,
uint32_t InitDataByteSize,
FAudioMallocFunc customMalloc,
FAudioFreeFunc customFree,
FAudioReallocFunc customRealloc,
uint8_t legacy
) {
const FAPOFXMasteringLimiterParameters fxdefault =
{
FAPOFXMASTERINGLIMITER_DEFAULT_RELEASE,
FAPOFXMASTERINGLIMITER_DEFAULT_LOUDNESS
};
/* Allocate... */
FAPOFXMasteringLimiter *result = (FAPOFXMasteringLimiter*) customMalloc(
sizeof(FAPOFXMasteringLimiter)
);
uint8_t *params = (uint8_t*) customMalloc(
sizeof(FAPOFXMasteringLimiterParameters) * 3
);
if (pInitData == NULL)
{
FAudio_zero(params, sizeof(FAPOFXMasteringLimiterParameters) * 3);
#define INITPARAMS(offset) \
FAudio_memcpy( \
params + sizeof(FAPOFXMasteringLimiterParameters) * offset, \
&fxdefault, \
sizeof(FAPOFXMasteringLimiterParameters) \
);
INITPARAMS(0)
INITPARAMS(1)
INITPARAMS(2)
#undef INITPARAMS
}
else
{
FAudio_assert(InitDataByteSize == sizeof(FAPOFXMasteringLimiterParameters));
FAudio_memcpy(params, pInitData, InitDataByteSize);
FAudio_memcpy(params + InitDataByteSize, pInitData, InitDataByteSize);
FAudio_memcpy(params + (InitDataByteSize * 2), pInitData, InitDataByteSize);
}
/* Initialize... */
FAudio_memcpy(
&FXMasteringLimiterProperties_LEGACY.clsid,
&FAPOFX_CLSID_FXMasteringLimiter_LEGACY,
sizeof(FAudioGUID)
);
FAudio_memcpy(
&FXMasteringLimiterProperties.clsid,
&FAPOFX_CLSID_FXMasteringLimiter,
sizeof(FAudioGUID)
);
CreateFAPOBaseWithCustomAllocatorEXT(
&result->base,
legacy ? &FXMasteringLimiterProperties_LEGACY : &FXMasteringLimiterProperties,
params,
sizeof(FAPOFXMasteringLimiterParameters),
0,
customMalloc,
customFree,
customRealloc
);
/* Function table... */
result->base.base.Initialize = (InitializeFunc)
FAPOFXMasteringLimiter_Initialize;
result->base.base.Process = (ProcessFunc)
FAPOFXMasteringLimiter_Process;
result->base.Destructor = FAPOFXMasteringLimiter_Free;
/* Finally. */
*pEffect = &result->base.base;
return 0;
}
/* vim: set noexpandtab shiftwidth=8 tabstop=8: */
/* 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>
*
*/
#include "FAPOFX.h"
#include "FAudio_internal.h"
/* FXReverb FAPO Implementation */
const FAudioGUID FAPOFX_CLSID_FXReverb =
{
0x7D9ACA56,
0xCB68,
0x4807,
{
0xB6,
0x32,
0xB1,
0x37,
0x35,
0x2E,
0x85,
0x96
}
};
static FAPORegistrationProperties FXReverbProperties =
{
/* .clsid = */ {0},
/* .FriendlyName = */
{
'F', 'X', 'R', 'e', 'v', 'e', 'r', 'b', '\0'
},
/*.CopyrightInfo = */
{
'C', 'o', 'p', 'y', 'r', 'i', 'g', 'h', 't', ' ', '(', 'c', ')',
'E', 't', 'h', 'a', 'n', ' ', 'L', 'e', 'e', '\0'
},
/*.MajorVersion = */ 0,
/*.MinorVersion = */ 0,
/*.Flags = */(
FAPO_FLAG_FRAMERATE_MUST_MATCH |
FAPO_FLAG_BITSPERSAMPLE_MUST_MATCH |
FAPO_FLAG_BUFFERCOUNT_MUST_MATCH |
FAPO_FLAG_INPLACE_SUPPORTED |
FAPO_FLAG_INPLACE_REQUIRED
),
/*.MinInputBufferCount = */ 1,
/*.MaxInputBufferCount = */ 1,
/*.MinOutputBufferCount = */ 1,
/*.MaxOutputBufferCount =*/ 1
};
const FAudioGUID FAPOFX_CLSID_FXReverb_LEGACY =
{
0xA90BC001,
0xE897,
0xE897,
{
0x74,
0x39,
0x43,
0x55,
0x00,
0x00,
0x00,
0x02
}
};
static FAPORegistrationProperties FXReverbProperties_LEGACY =
{
/* .clsid = */ {0},
/* .FriendlyName = */
{
'F', 'X', 'R', 'e', 'v', 'e', 'r', 'b', '\0'
},
/*.CopyrightInfo = */
{
'C', 'o', 'p', 'y', 'r', 'i', 'g', 'h', 't', ' ', '(', 'c', ')',
'E', 't', 'h', 'a', 'n', ' ', 'L', 'e', 'e', '\0'
},
/*.MajorVersion = */ 0,
/*.MinorVersion = */ 0,
/*.Flags = */(
FAPO_FLAG_FRAMERATE_MUST_MATCH |
FAPO_FLAG_BITSPERSAMPLE_MUST_MATCH |
FAPO_FLAG_BUFFERCOUNT_MUST_MATCH |
FAPO_FLAG_INPLACE_SUPPORTED |
FAPO_FLAG_INPLACE_REQUIRED
),
/*.MinInputBufferCount = */ 1,
/*.MaxInputBufferCount = */ 1,
/*.MinOutputBufferCount = */ 1,
/*.MaxOutputBufferCount =*/ 1
};
typedef struct FAPOFXReverb
{
FAPOBase base;
/* TODO */
} FAPOFXReverb;
uint32_t FAPOFXReverb_Initialize(
FAPOFXReverb *fapo,
const void* pData,
uint32_t DataByteSize
) {
#define INITPARAMS(offset) \
FAudio_memcpy( \
fapo->base.m_pParameterBlocks + DataByteSize * offset, \
pData, \
DataByteSize \
);
INITPARAMS(0)
INITPARAMS(1)
INITPARAMS(2)
#undef INITPARAMS
return 0;
}
void FAPOFXReverb_Process(
FAPOFXReverb *fapo,
uint32_t InputProcessParameterCount,
const FAPOProcessBufferParameters* pInputProcessParameters,
uint32_t OutputProcessParameterCount,
FAPOProcessBufferParameters* pOutputProcessParameters,
int32_t IsEnabled
) {
FAPOBase_BeginProcess(&fapo->base);
/* TODO */
FAPOBase_EndProcess(&fapo->base);
}
void FAPOFXReverb_Free(void* fapo)
{
FAPOFXReverb *reverb = (FAPOFXReverb*) fapo;
reverb->base.pFree(reverb->base.m_pParameterBlocks);
reverb->base.pFree(fapo);
}
/* Public API */
uint32_t FAPOFXCreateReverb(
FAPO **pEffect,
const void *pInitData,
uint32_t InitDataByteSize,
FAudioMallocFunc customMalloc,
FAudioFreeFunc customFree,
FAudioReallocFunc customRealloc,
uint8_t legacy
) {
const FAPOFXReverbParameters fxdefault =
{
FAPOFXREVERB_DEFAULT_DIFFUSION,
FAPOFXREVERB_DEFAULT_ROOMSIZE,
};
/* Allocate... */
FAPOFXReverb *result = (FAPOFXReverb*) customMalloc(
sizeof(FAPOFXReverb)
);
uint8_t *params = (uint8_t*) customMalloc(
sizeof(FAPOFXReverbParameters) * 3
);
if (pInitData == NULL)
{
FAudio_zero(params, sizeof(FAPOFXReverbParameters) * 3);
#define INITPARAMS(offset) \
FAudio_memcpy( \
params + sizeof(FAPOFXReverbParameters) * offset, \
&fxdefault, \
sizeof(FAPOFXReverbParameters) \
);
INITPARAMS(0)
INITPARAMS(1)
INITPARAMS(2)
#undef INITPARAMS
}
else
{
FAudio_assert(InitDataByteSize == sizeof(FAPOFXReverbParameters));
FAudio_memcpy(params, pInitData, InitDataByteSize);
FAudio_memcpy(params + InitDataByteSize, pInitData, InitDataByteSize);
FAudio_memcpy(params + (InitDataByteSize * 2), pInitData, InitDataByteSize);
}
/* Initialize... */
FAudio_memcpy(
&FXReverbProperties_LEGACY.clsid,
&FAPOFX_CLSID_FXReverb_LEGACY,
sizeof(FAudioGUID)
);
FAudio_memcpy(
&FXReverbProperties.clsid,
&FAPOFX_CLSID_FXReverb,
sizeof(FAudioGUID)
);
CreateFAPOBaseWithCustomAllocatorEXT(
&result->base,
legacy ? &FXReverbProperties_LEGACY : &FXReverbProperties,
params,
sizeof(FAPOFXReverbParameters),
0,
customMalloc,
customFree,
customRealloc
);
/* Function table... */
result->base.base.Initialize = (InitializeFunc)
FAPOFXReverb_Initialize;
result->base.base.Process = (ProcessFunc)
FAPOFXReverb_Process;
result->base.Destructor = FAPOFXReverb_Free;
/* Finally. */
*pEffect = &result->base.base;
return 0;
}
/* vim: set noexpandtab shiftwidth=8 tabstop=8: */
/* 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>
*
*/
#include "FAudioFX.h"
#include "FAudio_internal.h"
/* Volume Meter FAPO Implementation */
const FAudioGUID FAudioFX_CLSID_AudioVolumeMeter = /* 2.7 */
{
0xCAC1105F,
0x619B,
0x4D04,
{
0x83,
0x1A,
0x44,
0xE1,
0xCB,
0xF1,
0x2D,
0x57
}
};
static FAPORegistrationProperties VolumeMeterProperties =
{
/* .clsid = */ {0},
/* .FriendlyName = */
{
'V', 'o', 'l', 'u', 'm', 'e', 'M', 'e', 't', 'e', 'r', '\0'
},
/*.CopyrightInfo = */
{
'C', 'o', 'p', 'y', 'r', 'i', 'g', 'h', 't', ' ', '(', 'c', ')',
'E', 't', 'h', 'a', 'n', ' ', 'L', 'e', 'e', '\0'
},
/*.MajorVersion = */ 0,
/*.MinorVersion = */ 0,
/*.Flags = */(
FAPO_FLAG_CHANNELS_MUST_MATCH |
FAPO_FLAG_FRAMERATE_MUST_MATCH |
FAPO_FLAG_BITSPERSAMPLE_MUST_MATCH |
FAPO_FLAG_BUFFERCOUNT_MUST_MATCH |
FAPO_FLAG_INPLACE_SUPPORTED |
FAPO_FLAG_INPLACE_REQUIRED
),
/*.MinInputBufferCount = */ 1,
/*.MaxInputBufferCount = */ 1,
/*.MinOutputBufferCount = */ 1,
/*.MaxOutputBufferCount =*/ 1
};
typedef struct FAudioFXVolumeMeter
{
FAPOBase base;
uint16_t channels;
} FAudioFXVolumeMeter;
uint32_t FAudioFXVolumeMeter_LockForProcess(
FAudioFXVolumeMeter *fapo,
uint32_t InputLockedParameterCount,
const FAPOLockForProcessBufferParameters *pInputLockedParameters,
uint32_t OutputLockedParameterCount,
const FAPOLockForProcessBufferParameters *pOutputLockedParameters
) {
FAudioFXVolumeMeterLevels *levels = (FAudioFXVolumeMeterLevels*)
fapo->base.m_pParameterBlocks;
/* Verify parameter counts... */
if ( InputLockedParameterCount < fapo->base.m_pRegistrationProperties->MinInputBufferCount ||
InputLockedParameterCount > fapo->base.m_pRegistrationProperties->MaxInputBufferCount ||
OutputLockedParameterCount < fapo->base.m_pRegistrationProperties->MinOutputBufferCount ||
OutputLockedParameterCount > fapo->base.m_pRegistrationProperties->MaxOutputBufferCount )
{
return FAUDIO_E_INVALID_ARG;
}
/* Validate input/output formats */
#define VERIFY_FORMAT_FLAG(flag, prop) \
if ( (fapo->base.m_pRegistrationProperties->Flags & flag) && \
(pInputLockedParameters->pFormat->prop != pOutputLockedParameters->pFormat->prop) ) \
{ \
return FAUDIO_E_INVALID_ARG; \
}
VERIFY_FORMAT_FLAG(FAPO_FLAG_CHANNELS_MUST_MATCH, nChannels)
VERIFY_FORMAT_FLAG(FAPO_FLAG_FRAMERATE_MUST_MATCH, nSamplesPerSec)
VERIFY_FORMAT_FLAG(FAPO_FLAG_BITSPERSAMPLE_MUST_MATCH, wBitsPerSample)
#undef VERIFY_FORMAT_FLAG
if ( (fapo->base.m_pRegistrationProperties->Flags & FAPO_FLAG_BUFFERCOUNT_MUST_MATCH) &&
(InputLockedParameterCount != OutputLockedParameterCount) )
{
return FAUDIO_E_INVALID_ARG;
}
/* Allocate volume meter arrays */
fapo->channels = pInputLockedParameters->pFormat->nChannels;
levels[0].pPeakLevels = (float*) fapo->base.pMalloc(
fapo->channels * sizeof(float) * 6
);
FAudio_zero(levels[0].pPeakLevels, fapo->channels * sizeof(float) * 6);
levels[0].pRMSLevels = levels[0].pPeakLevels + fapo->channels;
levels[1].pPeakLevels = levels[0].pPeakLevels + (fapo->channels * 2);
levels[1].pRMSLevels = levels[0].pPeakLevels + (fapo->channels * 3);
levels[2].pPeakLevels = levels[0].pPeakLevels + (fapo->channels * 4);
levels[2].pRMSLevels = levels[0].pPeakLevels + (fapo->channels * 5);
fapo->base.m_fIsLocked = 1;
return 0;
}
void FAudioFXVolumeMeter_UnlockForProcess(FAudioFXVolumeMeter *fapo)
{
FAudioFXVolumeMeterLevels *levels = (FAudioFXVolumeMeterLevels*)
fapo->base.m_pParameterBlocks;
fapo->base.pFree(levels[0].pPeakLevels);
fapo->base.m_fIsLocked = 0;
}
void FAudioFXVolumeMeter_Process(
FAudioFXVolumeMeter *fapo,
uint32_t InputProcessParameterCount,
const FAPOProcessBufferParameters* pInputProcessParameters,
uint32_t OutputProcessParameterCount,
FAPOProcessBufferParameters* pOutputProcessParameters,
int32_t IsEnabled
) {
float peak;
float total;
float *buffer;
uint32_t i, j;
FAudioFXVolumeMeterLevels *levels = (FAudioFXVolumeMeterLevels*)
FAPOBase_BeginProcess(&fapo->base);
/* TODO: This could probably be SIMD-ified... */
for (i = 0; i < fapo->channels; i += 1)
{
peak = 0.0f;
total = 0.0f;
buffer = ((float*) pInputProcessParameters->pBuffer) + i;
for (j = 0; j < pInputProcessParameters->ValidFrameCount; j += 1, buffer += fapo->channels)
{
const float sampleAbs = FAudio_fabsf(*buffer);
if (sampleAbs > peak)
{
peak = sampleAbs;
}
total += (*buffer) * (*buffer);
}
levels->pPeakLevels[i] = peak;
levels->pRMSLevels[i] = FAudio_sqrtf(
total / pInputProcessParameters->ValidFrameCount
);
}
FAPOBase_EndProcess(&fapo->base);
}
void FAudioFXVolumeMeter_GetParameters(
FAudioFXVolumeMeter *fapo,
FAudioFXVolumeMeterLevels *pParameters,
uint32_t ParameterByteSize
) {
FAudioFXVolumeMeterLevels *levels = (FAudioFXVolumeMeterLevels*)
fapo->base.m_pCurrentParameters;
FAudio_assert(ParameterByteSize == sizeof(FAudioFXVolumeMeterLevels));
FAudio_assert(pParameters->ChannelCount == fapo->channels);
/* Copy what's current as of the last Process */
if (pParameters->pPeakLevels != NULL)
{
FAudio_memcpy(
pParameters->pPeakLevels,
levels->pPeakLevels,
fapo->channels * sizeof(float)
);
}
if (pParameters->pRMSLevels != NULL)
{
FAudio_memcpy(
pParameters->pRMSLevels,
levels->pRMSLevels,
fapo->channels * sizeof(float)
);
}
}
void FAudioFXVolumeMeter_Free(void* fapo)
{
FAudioFXVolumeMeter *volumemeter = (FAudioFXVolumeMeter*) fapo;
volumemeter->base.pFree(volumemeter->base.m_pParameterBlocks);
volumemeter->base.pFree(fapo);
}
/* Public API */
uint32_t FAudioCreateVolumeMeter(FAPO** ppApo, uint32_t Flags)
{
return FAudioCreateVolumeMeterWithCustomAllocatorEXT(
ppApo,
Flags,
FAudio_malloc,
FAudio_free,
FAudio_realloc
);
}
uint32_t FAudioCreateVolumeMeterWithCustomAllocatorEXT(
FAPO** ppApo,
uint32_t Flags,
FAudioMallocFunc customMalloc,
FAudioFreeFunc customFree,
FAudioReallocFunc customRealloc
) {
/* Allocate... */
FAudioFXVolumeMeter *result = (FAudioFXVolumeMeter*) customMalloc(
sizeof(FAudioFXVolumeMeter)
);
uint8_t *params = (uint8_t*) customMalloc(
sizeof(FAudioFXVolumeMeterLevels) * 3
);
FAudio_zero(params, sizeof(FAudioFXVolumeMeterLevels) * 3);
/* Initialize... */
FAudio_memcpy(
&VolumeMeterProperties.clsid,
&FAudioFX_CLSID_AudioVolumeMeter,
sizeof(FAudioGUID)
);
CreateFAPOBaseWithCustomAllocatorEXT(
&result->base,
&VolumeMeterProperties,
params,
sizeof(FAudioFXVolumeMeterLevels),
1,
customMalloc,
customFree,
customRealloc
);
/* Function table... */
result->base.base.LockForProcess = (LockForProcessFunc)
FAudioFXVolumeMeter_LockForProcess;
result->base.base.UnlockForProcess = (UnlockForProcessFunc)
FAudioFXVolumeMeter_UnlockForProcess;
result->base.base.Process = (ProcessFunc)
FAudioFXVolumeMeter_Process;
result->base.base.GetParameters = (GetParametersFunc)
FAudioFXVolumeMeter_GetParameters;
result->base.Destructor = FAudioFXVolumeMeter_Free;
/* Finally. */
*ppApo = &result->base.base;
return 0;
}
/* vim: set noexpandtab shiftwidth=8 tabstop=8: */
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment