Convert panning.c to C++

This commit is contained in:
Chris Robinson
2018-11-03 19:02:11 -07:00
parent ba5ec8b074
commit 4bfaa173c4
5 changed files with 31 additions and 13 deletions
+5
View File
@@ -90,6 +90,11 @@ extern inline void aluMatrixfSet(aluMatrixf *matrix,
ALfloat m20, ALfloat m21, ALfloat m22, ALfloat m23,
ALfloat m30, ALfloat m31, ALfloat m32, ALfloat m33);
extern inline void CalcDirectionCoeffs(const ALfloat dir[3], ALfloat spread, ALfloat coeffs[MAX_AMBI_COEFFS]);
extern inline void CalcAngleCoeffs(ALfloat azimuth, ALfloat elevation, ALfloat spread, ALfloat coeffs[MAX_AMBI_COEFFS]);
extern inline float ScaleAzimuthFront(float azimuth, float scale);
extern inline void ComputePanGains(const MixParams *dry, const ALfloat*RESTRICT coeffs, ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
/* Cone scalar */
ALfloat ConeScale = 1.0f;
+8
View File
@@ -4,6 +4,10 @@
#include "alstring.h"
#include "alMain.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Helpers to read .ambdec configuration files. */
enum AmbDecScaleType {
@@ -43,4 +47,8 @@ void ambdec_init(AmbDecConf *conf);
void ambdec_deinit(AmbDecConf *conf);
int ambdec_load(AmbDecConf *conf, const char *fname);
#ifdef __cplusplus
} // extern "C"
#endif
#endif /* AMBDEC_H */
+8
View File
@@ -9,6 +9,10 @@
#include "atomic.h"
#ifdef __cplusplus
extern "C" {
#endif
#define HRTF_HISTORY_BITS (6)
#define HRTF_HISTORY_LENGTH (1<<HRTF_HISTORY_BITS)
#define HRTF_HISTORY_MASK (HRTF_HISTORY_LENGTH-1)
@@ -81,4 +85,8 @@ void GetHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azimuth,
*/
void BuildBFormatHrtf(const struct Hrtf *Hrtf, DirectHrtfState *state, ALsizei NumChannels, const struct AngularPoint *AmbiPoints, const ALfloat (*RESTRICT AmbiMatrix)[MAX_AMBI_COEFFS], ALsizei AmbiCount, const ALfloat *RESTRICT AmbiOrderHFGain);
#ifdef __cplusplus
} // extern "C"
#endif
#endif /* ALC_HRTF_H */
+9 -12
View File
@@ -38,12 +38,6 @@
#include "bs2b.h"
extern inline void CalcDirectionCoeffs(const ALfloat dir[3], ALfloat spread, ALfloat coeffs[MAX_AMBI_COEFFS]);
extern inline void CalcAngleCoeffs(ALfloat azimuth, ALfloat elevation, ALfloat spread, ALfloat coeffs[MAX_AMBI_COEFFS]);
extern inline float ScaleAzimuthFront(float azimuth, float scale);
extern inline void ComputePanGains(const MixParams *dry, const ALfloat*RESTRICT coeffs, ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
static const ALsizei FuMa2ACN[MAX_AMBI_COEFFS] = {
0, /* W */
3, /* X */
@@ -324,7 +318,7 @@ static bool MakeSpeakerMap(ALCdevice *device, const AmbDecConf *conf, ALsizei sp
char c;
if(sscanf(name, "AUX%u%c", &n, &c) == 1 && n < 16)
ch = Aux0+n;
ch = static_cast<enum Channel>(Aux0+n);
else
{
ERR("AmbDec speaker label \"%s\" not recognized\n", name);
@@ -449,7 +443,8 @@ static void InitDistanceComp(ALCdevice *device, const AmbDecConf *conf, const AL
if(total > 0)
{
device->ChannelDelay[0].Buffer = al_calloc(16, total * sizeof(ALfloat));
device->ChannelDelay[0].Buffer = reinterpret_cast<float*>(
al_calloc(16, total * sizeof(ALfloat)));
for(i = 1;i < MAX_OUTPUT_CHANNELS;i++)
{
size_t len = RoundUp(device->ChannelDelay[i-1].Length, 4);
@@ -860,7 +855,8 @@ static void InitHrtfPanning(ALCdevice *device)
count = COUNTOF(IndexMap);
}
device->Hrtf = al_calloc(16, FAM_SIZE(DirectHrtfState, Chan, count));
device->Hrtf = reinterpret_cast<DirectHrtfState*>(
al_calloc(16, FAM_SIZE(DirectHrtfState, Chan, count)));
for(i = 0;i < count;i++)
{
@@ -1044,7 +1040,8 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, enum HrtfRequestMode hrtf
* higher).
*/
ALfloat scale = (ALfloat)(5000.0 / device->Frequency);
FrontStablizer *stablizer = al_calloc(16, sizeof(*stablizer));
FrontStablizer *stablizer = reinterpret_cast<FrontStablizer*>(
al_calloc(16, sizeof(*stablizer)));
bandsplit_init(&stablizer->LFilter, scale);
stablizer->RFilter = stablizer->LFilter;
@@ -1194,7 +1191,7 @@ no_hrtf:
ConfigValueInt(alstr_get_cstr(device->DeviceName), NULL, "cf_level", &bs2blevel);
if(bs2blevel > 0 && bs2blevel <= 6)
{
device->Bs2b = al_calloc(16, sizeof(*device->Bs2b));
device->Bs2b = reinterpret_cast<struct bs2b*>(al_calloc(16, sizeof(*device->Bs2b)));
bs2b_set_params(device->Bs2b, bs2blevel, device->Frequency);
TRACE("BS2B enabled\n");
InitPanning(device);
@@ -1212,7 +1209,7 @@ no_hrtf:
}
if(device->Render_Mode == NormalRender)
{
device->Uhj_Encoder = al_calloc(16, sizeof(Uhj2Encoder));
device->Uhj_Encoder = reinterpret_cast<Uhj2Encoder*>(al_calloc(16, sizeof(Uhj2Encoder)));
TRACE("UHJ enabled\n");
InitUhjPanning(device);
return;
+1 -1
View File
@@ -878,7 +878,7 @@ SET(ALC_OBJS
Alc/ambdec.h
Alc/bformatdec.cpp
Alc/bformatdec.h
Alc/panning.c
Alc/panning.cpp
Alc/polymorphism.h
Alc/mixvoice.c
Alc/mixer/defs.h