mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-23 07:59:42 +00:00
Cleanup some xaudio headers
This commit is contained in:
parent
f5bc0edbaa
commit
88cd91c586
@ -435,6 +435,8 @@ static void xa_set_nonblock_state(void *data, bool state)
|
||||
static bool xa_start(void *data, bool is_shutdown)
|
||||
{
|
||||
xa_t *xa = (xa_t*)data;
|
||||
if (!xa)
|
||||
return false;
|
||||
xa->flags &= ~(XA2_FLAG_IS_PAUSED);
|
||||
return true;
|
||||
}
|
||||
@ -462,6 +464,8 @@ static size_t xa_write_avail(void *data)
|
||||
static size_t xa_buffer_size(void *data)
|
||||
{
|
||||
xa_t *xa = (xa_t*)data;
|
||||
if (!xa)
|
||||
return 0;
|
||||
return xa->bufsize;
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,8 @@ typedef enum XAUDIO2_WINDOWS_PROCESSOR_SPECIFIER
|
||||
} XAUDIO2_WINDOWS_PROCESSOR_SPECIFIER, XAUDIO2_PROCESSOR;
|
||||
#endif
|
||||
|
||||
typedef enum XAUDIO2_FILTER_TYPE {
|
||||
typedef enum XAUDIO2_FILTER_TYPE
|
||||
{
|
||||
LowPassFilter,
|
||||
BandPassFilter,
|
||||
HighPassFilter
|
||||
|
@ -733,85 +733,6 @@ DECLARE_INTERFACE(IXAudio2VoiceCallback)
|
||||
|
||||
#endif /* #ifndef __cplusplus */
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* Utility functions used to convert from pitch in semitones and volume
|
||||
* in decibels to the frequency and amplitude ratio units used by XAudio2.
|
||||
* These are only defined if the client #defines XAUDIO2_HELPER_FUNCTIONS
|
||||
* prior to #including xaudio2.h.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifdef XAUDIO2_HELPER_FUNCTIONS
|
||||
|
||||
#define _USE_MATH_DEFINES /* Make math.h define M_PI */
|
||||
#include <math.h> /* For powf, log10f, sinf and asinf */
|
||||
|
||||
/* Calculate the argument to SetVolume from a decibel value */
|
||||
static INLINE float XAudio2DecibelsToAmplitudeRatio(float Decibels)
|
||||
{
|
||||
return powf(10.0f, Decibels / 20.0f);
|
||||
}
|
||||
|
||||
/* Recover a volume in decibels from an amplitude factor */
|
||||
static INLINE float XAudio2AmplitudeRatioToDecibels(float Volume)
|
||||
{
|
||||
if (Volume == 0)
|
||||
return -3.402823466e+38f; /* Smallest float value (-FLT_MAX) */
|
||||
return 20.0f * log10f(Volume);
|
||||
}
|
||||
|
||||
/* Calculate the argument to SetFrequencyRatio from a semitone value */
|
||||
static INLINE float XAudio2SemitonesToFrequencyRatio(float Semitones)
|
||||
{
|
||||
/* FrequencyRatio = 2 ^ Octaves
|
||||
* = 2 ^ (Semitones / 12)
|
||||
*/
|
||||
return powf(2.0f, Semitones / 12.0f);
|
||||
}
|
||||
|
||||
/* Recover a pitch in semitones from a frequency ratio */
|
||||
static INLINE float XAudio2FrequencyRatioToSemitones(float FrequencyRatio)
|
||||
{
|
||||
/* Semitones = 12 * log2(FrequencyRatio)
|
||||
* = 12 * log2(10) * log10(FrequencyRatio)
|
||||
*/
|
||||
return 39.86313713864835f * log10f(FrequencyRatio);
|
||||
}
|
||||
|
||||
/* Convert from filter cutoff frequencies expressed in Hertz to the radian
|
||||
* frequency values used in XAUDIO2_FILTER_PARAMETERS.Frequency, state-variable
|
||||
* filter types only. Use XAudio2CutoffFrequencyToOnePoleCoefficient() for one-pole filter types.
|
||||
* Note that the highest CutoffFrequency supported is SampleRate/6.
|
||||
* Higher values of CutoffFrequency will return XAUDIO2_MAX_FILTER_FREQUENCY.
|
||||
*/
|
||||
static INLINE float XAudio2CutoffFrequencyToRadians(float CutoffFrequency, UINT32 SampleRate)
|
||||
{
|
||||
if ((UINT32)(CutoffFrequency * 6.0f) >= SampleRate)
|
||||
return XAUDIO2_MAX_FILTER_FREQUENCY;
|
||||
return 2.0f * sinf((float)M_PI * CutoffFrequency / SampleRate);
|
||||
}
|
||||
|
||||
/* Convert from radian frequencies back to absolute frequencies in Hertz */
|
||||
static INLINE float XAudio2RadiansToCutoffFrequency(float Radians, float SampleRate)
|
||||
{
|
||||
return SampleRate * asinf(Radians / 2.0f) / (float)M_PI;
|
||||
}
|
||||
|
||||
/* Convert from filter cutoff frequencies expressed in Hertz to the filter
|
||||
* coefficients used with XAUDIO2_FILTER_PARAMETERS.Frequency,
|
||||
* LowPassOnePoleFilter and HighPassOnePoleFilter filter types only.
|
||||
* Use XAudio2CutoffFrequencyToRadians() for state-variable filter types.
|
||||
*/
|
||||
static INLINE float XAudio2CutoffFrequencyToOnePoleCoefficient(float CutoffFrequency, UINT32 SampleRate)
|
||||
{
|
||||
if ((UINT32)CutoffFrequency >= SampleRate)
|
||||
return XAUDIO2_MAX_FILTER_FREQUENCY;
|
||||
return (1.0f - powf(1.0f - 2.0f * CutoffFrequency / SampleRate, 2.0f));
|
||||
}
|
||||
|
||||
#endif /* #ifdef XAUDIO2_HELPER_FUNCTIONS */
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* XAudio2Create: Top-level function that creates an XAudio2 instance.
|
||||
@ -876,15 +797,11 @@ static INLINE HRESULT XAudio2Create(_Outptr_ IXAudio2** ppXAudio2,
|
||||
|
||||
if (!s_dllInstance)
|
||||
{
|
||||
s_dllInstance = LoadLibraryEx(XAUDIO2_DLL, NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
|
||||
if (!s_dllInstance)
|
||||
if (!(s_dllInstance = LoadLibraryEx(XAUDIO2_DLL, NULL, LOAD_LIBRARY_SEARCH_SYSTEM32)))
|
||||
return HRESULT_FROM_WIN32(GetLastError());
|
||||
|
||||
s_pfnAudio2CreateWithVersion = (XAudio2CreateWithVersionInfoFunc)(void*)GetProcAddress(s_dllInstance, "XAudio2CreateWithVersionInfo");
|
||||
if (!s_pfnAudio2CreateWithVersion)
|
||||
if (!(s_pfnAudio2CreateWithVersion = (XAudio2CreateWithVersionInfoFunc)(void*)GetProcAddress(s_dllInstance, "XAudio2CreateWithVersionInfo")))
|
||||
{
|
||||
s_pfnAudio2Create = (XAudio2CreateInfoFunc)(void*)GetProcAddress(s_dllInstance, "XAudio2Create");
|
||||
if (!s_pfnAudio2Create)
|
||||
if (!(s_pfnAudio2Create = (XAudio2CreateInfoFunc)(void*)GetProcAddress(s_dllInstance, "XAudio2Create")))
|
||||
return HRESULT_FROM_WIN32(GetLastError());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user