Compare commits

...

1 Commits

Author SHA1 Message Date
devin
3d716e1518 axfx: link AXFXReverbHiExpDpl2 + AXFXReverbStdExp (objdiff 100%)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 06:25:47 +00:00
7 changed files with 875 additions and 8 deletions

View File

@@ -1448,10 +1448,10 @@ config.libs = [
Object(Matching, "axfx/AXFXReverbHi.c"),
Object(Matching, "axfx/AXFXReverbHiDpl2.c"),
Object(Matching, "axfx/AXFXReverbHiExp.c"),
Object(NonMatching, "axfx/AXFXReverbHiExpDpl2.c"),
Object(Matching, "axfx/AXFXReverbHiExpDpl2.c"),
Object(Matching, "axfx/AXFXDelay.c"),
Object(Matching, "axfx/AXFXReverbStd.c"),
Object(NonMatching, "axfx/AXFXReverbStdExp.c"),
Object(Matching, "axfx/AXFXReverbStdExp.c"),
Object(Matching, "axfx/AXFXChorus.c"),
Object(NonMatching, "axfx/AXFXChorusExp.c"),
Object(Matching, "axfx/AXFXLfoTable.c"),

View File

@@ -7,6 +7,8 @@
extern "C" {
#endif
#define AXFX_STEREO_CHANNEL_MAX 3
typedef struct AXFX_BUS {
s32* left; // 0x00
s32* right; // 0x04
@@ -19,6 +21,13 @@ typedef struct AXFX_BUFFERUPDATE {
s32* surround; // 0x08
} AXFX_BUFFERUPDATE;
typedef struct AXFX_BUS_DPL2 {
s32* left; // 0x00
s32* right; // 0x04
s32* left_surround; // 0x08
s32* right_surround; // 0x0C
} AXFX_BUS_DPL2;
typedef struct AXFX_BUFFERUPDATE_DPL2 {
s32* left; // 0x00
s32* right; // 0x04

View File

@@ -49,13 +49,13 @@ typedef struct AXFX_REVERBHI_EXP_DPL2 {
f32 crosstalk; // 0x15C
f32 earlyGain; // 0x160
f32 fusedGain; // 0x164
AXFX_BUS* busIn; // 0x168
AXFX_BUS* busOut; // 0x16C
AXFX_BUS_DPL2* busIn; // 0x168
AXFX_BUS_DPL2* busOut; // 0x16C
f32 outGain; // 0x170
f32 sendGain; // 0x174
} AXFX_REVERBHI_EXP_DPL2;
u32 AXFXReverbHiExpGetMemSizeDpl2(const AXFX_REVERBHI_EXP_DPL2* fx);
u32 AXFXReverbHiExpGetMemSizeDpl2(AXFX_REVERBHI_EXP_DPL2* fx);
BOOL AXFXReverbHiExpInitDpl2(AXFX_REVERBHI_EXP_DPL2* fx);
void AXFXReverbHiExpShutdownDpl2(AXFX_REVERBHI_EXP_DPL2* fx);
BOOL AXFXReverbHiExpSettingsDpl2(AXFX_REVERBHI_EXP_DPL2* fx);

View File

@@ -49,11 +49,11 @@ typedef struct AXFX_REVERBSTD_EXP {
f32 sendGain; // 0xE4
} AXFX_REVERBSTD_EXP;
u32 AXFXReverbStdExpGetMemSize(const AXFX_REVERBSTD_EXP* fx);
u32 AXFXReverbStdExpGetMemSize(AXFX_REVERBSTD_EXP* fx);
BOOL AXFXReverbStdExpInit(AXFX_REVERBSTD_EXP* fx);
void AXFXReverbStdExpShutdown(AXFX_REVERBSTD_EXP* fx);
BOOL AXFXReverbStdExpSettings(AXFX_REVERBSTD_EXP* fx);
void AXFXReverbStdExpCallback(void* chans, AXFX_REVERBSTD_EXP* context);
void AXFXReverbStdExpCallback(AXFX_BUS* update, AXFX_REVERBSTD_EXP* fx);
#ifdef __cplusplus
}

View File

@@ -0,0 +1,461 @@
#include <private/axfx.h>
#include <revolution/AXFX.h>
#include <revolution/MEM.h>
#include <revolution/OS.h>
#include <revolution/ax.h>
#include <math.h>
#include <string.h>
static BOOL __AllocDelayLine(AXFX_REVERBHI_EXP_DPL2* fx);
static void __BzeroDelayLines(AXFX_REVERBHI_EXP_DPL2* fx);
static void __FreeDelayLine(AXFX_REVERBHI_EXP_DPL2* fx);
static BOOL __InitParams(AXFX_REVERBHI_EXP_DPL2* fx);
static u32 __EarlySizeTable[8][3] = {{157, 479, 829}, {317, 809, 1117}, {479, 941, 1487}, {641, 1259, 1949},
{797, 1667, 2579}, {967, 1901, 2903}, {1123, 2179, 3413}, {1279, 2477, 3889}};
static f32 __EarlyCoefTable[8][3] = {{0.4f, -1.0f, 0.3f}, {0.5f, -0.95f, 0.3f}, {0.6f, -0.9f, 0.3f}, {0.75f, -0.85f, 0.3f},
{-0.9f, 0.8f, 0.3f}, {-1.0f, 0.7f, 0.3f}, {-1.0f, 0.7f, 0.3f}, {-1.0f, 0.7f, 0.3f}};
static u32 __FilterSizeTable[7][9] = {{1789, 1999, 2333, 433, 149, 47, 73, 67, 71}, {149, 293, 449, 251, 103, 47, 73, 67, 71},
{947, 1361, 1531, 433, 137, 47, 73, 67, 71}, {1279, 1531, 1973, 509, 149, 47, 73, 67, 71},
{1531, 1847, 2297, 563, 179, 47, 73, 67, 71}, {1823, 2357, 2693, 571, 137, 47, 73, 67, 71},
{1823, 2357, 2693, 571, 179, 47, 73, 67, 71}};
u32 AXFXReverbHiExpGetMemSizeDpl2(AXFX_REVERBHI_EXP_DPL2* fx) {
u32 sum = 0;
u32 i = 0;
sum += __EarlySizeTable[7][2];
sum += (int)(fx->preDelayTimeMax * 32000);
for (i = 0; i < 5; i++) {
sum += __FilterSizeTable[6][i];
}
sum *= 4;
for (i = 5; i < 9; i++) {
sum += __FilterSizeTable[6][i];
}
sum *= 4;
return sum;
}
BOOL AXFXReverbHiExpInitDpl2(AXFX_REVERBHI_EXP_DPL2* fx) {
u32 ch, i;
BOOL result = TRUE;
BOOL mask = OSDisableInterrupts();
if (AXGetMode() != AX_OUTPUT_DPL2) {
OSRestoreInterrupts(mask);
return FALSE;
}
fx->active = 1;
if (fx->preDelayTimeMax < 0.0f) {
AXFXReverbHiExpShutdownDpl2(fx);
OSRestoreInterrupts(mask);
return FALSE;
}
fx->earlyMaxLength = __EarlySizeTable[8 - 1][2];
fx->preDelayMaxLength = (u32)(fx->preDelayTimeMax * 32000);
for (i = 0; i < 3; i++) {
fx->combMaxLength[i] = __FilterSizeTable[6][i];
}
for (i = 0; i < 2; i++) {
fx->allpassMaxLength[i] = __FilterSizeTable[6][3 + i];
}
for (ch = 0; ch < 4; ch++) {
fx->lastAllpassMaxLength[ch] = __FilterSizeTable[6][5 + ch];
}
result = __AllocDelayLine(fx);
if (result == FALSE) {
AXFXReverbHiExpShutdownDpl2(fx);
OSRestoreInterrupts(mask);
return FALSE;
}
__BzeroDelayLines(fx);
result = __InitParams(fx);
if (result == FALSE) {
AXFXReverbHiExpShutdownDpl2(fx);
OSRestoreInterrupts(mask);
return FALSE;
}
fx->active &= ~1;
OSRestoreInterrupts(mask);
return TRUE;
}
BOOL AXFXReverbHiExpSettingsDpl2(AXFX_REVERBHI_EXP_DPL2* fx) {
BOOL mask = OSDisableInterrupts();
fx->active = fx->active | 1;
AXFXReverbHiExpShutdownDpl2(fx);
if (!AXFXReverbHiExpInitDpl2(fx)) {
AXFXReverbHiExpShutdownDpl2(fx);
OSRestoreInterrupts(mask);
return FALSE;
} else {
fx->active |= 2;
fx->active &= ~1;
OSRestoreInterrupts(mask);
return TRUE;
}
}
void AXFXReverbHiExpShutdownDpl2(AXFX_REVERBHI_EXP_DPL2* fx) {
BOOL mask = OSDisableInterrupts();
fx->active |= 1;
__FreeDelayLine(fx);
OSRestoreInterrupts(mask);
}
void AXFXReverbHiExpCallbackDpl2(AXFX_BUFFERUPDATE_DPL2* bufferUpdate, AXFX_REVERBHI_EXP_DPL2* fx) {
u32 ch, i;
u32 samp;
s32* input[4];
f32 data;
f32 output[4];
f32* earlyLine;
f32 earlyOut;
f32* preDelayLine;
f32 preDelayOut;
f32 filterOut;
f32* combLine;
f32 combOutOne;
f32* allpass;
f32 outTmp;
f32 allpassIn;
f32 allpassCoef;
f32 lpfOut;
f32 lpfCoef1;
f32 lpfCoef2;
f32 fusedOut[4];
f32 fusedGain;
f32 crosstalkGain;
f32 crosstalkL;
f32 crosstalkR;
f32 crosstalkLs;
f32 crosstalkRs;
s32* inBusData[4];
s32* outBusData[4];
if (fx->active != 0) {
fx->active &= ~2;
return;
}
input[0] = bufferUpdate->left;
input[1] = bufferUpdate->right;
input[2] = bufferUpdate->left_surround;
input[3] = bufferUpdate->right_surround;
if (fx->busIn != NULL) {
inBusData[0] = fx->busIn->left;
inBusData[1] = fx->busIn->right;
inBusData[2] = fx->busIn->left_surround;
inBusData[3] = fx->busIn->right_surround;
}
if (fx->busOut != NULL) {
outBusData[0] = fx->busOut->left;
outBusData[1] = fx->busOut->right;
outBusData[2] = fx->busOut->left_surround;
outBusData[3] = fx->busOut->right_surround;
}
lpfCoef1 = 1.0f - fx->lpfCoef;
lpfCoef2 = fx->lpfCoef;
allpassCoef = fx->allpassCoef;
fusedGain = fx->fusedGain * 0.6f;
crosstalkGain = fx->crosstalk * 0.333333f;
for (samp = 0; samp < 96; samp++) {
for (ch = 0; ch < 4; ch++) {
if (fx->busIn != NULL) {
data = (f32)(*(input[ch]) + *(inBusData[ch]++));
} else {
data = (f32)(*input[ch]);
}
earlyLine = fx->earlyLine[ch];
earlyOut = earlyLine[fx->earlyPos[0]] * fx->earlyCoef[0] + earlyLine[fx->earlyPos[1]] * fx->earlyCoef[1] +
earlyLine[fx->earlyPos[2]] * fx->earlyCoef[2];
earlyLine[fx->earlyPos[2]] = data;
if (fx->preDelayLength != 0) {
preDelayLine = fx->preDelayLine[ch];
preDelayOut = preDelayLine[fx->preDelayPos];
preDelayLine[fx->preDelayPos] = data;
} else {
preDelayOut = data;
}
filterOut = 0.0f;
for (i = 0; i < 3; i++) {
combLine = fx->combLine[ch][i];
combOutOne = combLine[fx->combPos[i]];
combLine[fx->combPos[i]] = preDelayOut + (combOutOne * fx->combCoef[i]);
filterOut += combOutOne;
}
for (i = 0; i < 2; i++) {
allpass = fx->allpassLine[ch][i];
outTmp = allpass[fx->allpassPos[i]];
allpassIn = filterOut + outTmp * allpassCoef;
allpass[fx->allpassPos[i]] = allpassIn;
filterOut = outTmp - allpassIn * allpassCoef;
}
lpfOut = lpfCoef1 * filterOut + lpfCoef2 * fx->lastLpfOut[ch];
fx->lastLpfOut[ch] = lpfOut;
allpass = fx->lastAllpassLine[ch];
outTmp = allpass[fx->lastAllpassPos[ch]];
allpassIn = lpfOut + outTmp * allpassCoef;
allpass[fx->lastAllpassPos[ch]] = allpassIn;
fusedOut[ch] = outTmp - allpassIn * allpassCoef;
if (++fx->lastAllpassPos[ch] >= fx->lastAllpassLength[ch]) {
fx->lastAllpassPos[ch] = 0;
}
fusedOut[ch] *= fusedGain;
fusedOut[ch] += earlyOut;
}
crosstalkL = fusedOut[1] + fusedOut[2] + fusedOut[3];
crosstalkR = fusedOut[0] + fusedOut[2] + fusedOut[3];
crosstalkLs = fusedOut[0] + fusedOut[1] + fusedOut[3];
crosstalkRs = fusedOut[0] + fusedOut[1] + fusedOut[2];
output[0] = fusedOut[0] + crosstalkL * crosstalkGain;
output[1] = fusedOut[1] + crosstalkR * crosstalkGain;
output[2] = fusedOut[2] + crosstalkLs * crosstalkGain;
output[3] = fusedOut[3] + crosstalkRs * crosstalkGain;
*(input[0]++) = (s32)(output[0] * fx->outGain);
*(input[1]++) = (s32)(output[1] * fx->outGain);
*(input[2]++) = (s32)(output[2] * fx->outGain);
*(input[3]++) = (s32)(output[3] * fx->outGain);
if (fx->busOut != NULL) {
*(outBusData[0]++) = (s32)(output[0] * fx->sendGain);
*(outBusData[1]++) = (s32)(output[1] * fx->sendGain);
*(outBusData[2]++) = (s32)(output[2] * fx->sendGain);
*(outBusData[3]++) = (s32)(output[3] * fx->sendGain);
}
for (i = 0; i < 3; i++) {
if (++fx->earlyPos[i] >= fx->earlyLength) {
fx->earlyPos[i] = 0;
}
}
if (fx->preDelayLength != 0) {
if (++fx->preDelayPos >= fx->preDelayLength) {
fx->preDelayPos = 0;
}
}
for (i = 0; i < 3; i++) {
if (++fx->combPos[i] >= fx->combLength[i]) {
fx->combPos[i] = 0;
}
}
for (i = 0; i < 2; i++) {
if (++fx->allpassPos[i] >= fx->allpassLength[i]) {
fx->allpassPos[i] = 0;
}
}
}
}
static BOOL __AllocDelayLine(AXFX_REVERBHI_EXP_DPL2* fx) {
u32 ch, i;
for (ch = 0; ch < 4; ch++) {
fx->earlyLine[ch] = (f32*)__AXFXAlloc(sizeof(f32) * fx->earlyMaxLength);
if (fx->earlyLine[ch] == NULL)
return FALSE;
if (fx->preDelayMaxLength != 0) {
fx->preDelayLine[ch] = (f32*)__AXFXAlloc(sizeof(f32) * fx->preDelayMaxLength);
if (fx->preDelayLine[ch] == NULL)
return FALSE;
} else {
fx->preDelayLine[ch] = NULL;
}
for (i = 0; i < 3; i++) {
fx->combLine[ch][i] = (f32*)__AXFXAlloc(sizeof(f32) * fx->combMaxLength[i]);
if (fx->combLine[ch][i] == NULL)
return FALSE;
}
for (i = 0; i < 2; i++) {
fx->allpassLine[ch][i] = (f32*)__AXFXAlloc(sizeof(f32) * fx->allpassMaxLength[i]);
if (fx->allpassLine[ch][i] == NULL)
return FALSE;
}
fx->lastAllpassLine[ch] = (f32*)__AXFXAlloc(sizeof(f32) * fx->lastAllpassMaxLength[ch]);
if (fx->lastAllpassLine[ch] == NULL)
return FALSE;
}
return TRUE;
}
static void __BzeroDelayLines(AXFX_REVERBHI_EXP_DPL2* fx) {
u32 ch, i;
for (ch = 0; ch < 4; ch++) {
if (fx->earlyLine[ch] != NULL) {
memset(fx->earlyLine[ch], 0, sizeof(f32) * fx->earlyMaxLength);
}
if (fx->preDelayLine[ch] != NULL) {
memset(fx->preDelayLine[ch], 0, sizeof(f32) * fx->preDelayMaxLength);
}
for (i = 0; i < 3; i++) {
if (fx->combLine[ch][i] != NULL) {
memset(fx->combLine[ch][i], 0, sizeof(f32) * fx->combMaxLength[i]);
}
}
for (i = 0; i < 2; i++) {
if (fx->allpassLine[ch][i] != NULL) {
memset(fx->allpassLine[ch][i], 0, sizeof(f32) * fx->allpassMaxLength[i]);
}
}
if (fx->lastAllpassLine[ch] != NULL) {
memset(fx->lastAllpassLine[ch], 0, sizeof(f32) * fx->lastAllpassMaxLength[ch]);
}
}
}
static void __FreeDelayLine(AXFX_REVERBHI_EXP_DPL2* fx) {
u32 ch, i;
for (ch = 0; ch < 4; ch++) {
if (fx->earlyLine[ch] != NULL) {
__AXFXFree(fx->earlyLine[ch]);
fx->earlyLine[ch] = NULL;
}
if (fx->preDelayLine[ch] != NULL) {
__AXFXFree(fx->preDelayLine[ch]);
fx->preDelayLine[ch] = NULL;
}
for (i = 0; i < 3; i++) {
if (fx->combLine[ch][i] != NULL) {
__AXFXFree(fx->combLine[ch][i]);
fx->combLine[ch][i] = NULL;
}
}
for (i = 0; i < 2; i++) {
if (fx->allpassLine[ch][i] != NULL) {
__AXFXFree(fx->allpassLine[ch][i]);
fx->allpassLine[ch][i] = NULL;
}
}
if (fx->lastAllpassLine[ch] != NULL) {
__AXFXFree(fx->lastAllpassLine[ch]);
fx->lastAllpassLine[ch] = NULL;
}
}
}
DECOMP_FORCE_LITERAL(AXFXReverbHiExpDpl2_c, -3.0f, 10.0);
static BOOL __InitParams(AXFX_REVERBHI_EXP_DPL2* reverb) {
u32 ch, i;
if (reverb->earlyMode >= 8)
return FALSE;
if (reverb->preDelayTime < 0.0f || reverb->preDelayTime > reverb->preDelayTimeMax)
return FALSE;
if (reverb->fusedMode >= 6)
return FALSE;
if (reverb->fusedTime < 0.0f)
return FALSE;
if (reverb->coloration < 0.0f || reverb->coloration > 1.0f)
return FALSE;
if (reverb->damping < 0.0f || reverb->damping > 1.0f)
return FALSE;
if (reverb->crosstalk < 0.0f || reverb->crosstalk > 1.0f)
return FALSE;
if (reverb->earlyGain < 0.0f || reverb->earlyGain > 1.0f)
return FALSE;
if (reverb->fusedGain < 0.0f || reverb->fusedGain > 1.0f)
return FALSE;
if (reverb->outGain < 0.0f || reverb->outGain > 1.0f)
return FALSE;
if (reverb->sendGain < 0.0f || reverb->sendGain > 1.0f)
return FALSE;
reverb->earlyLength = __EarlySizeTable[reverb->earlyMode][2];
for (i = 0; i < 3; i++) {
reverb->earlyPos[i] = reverb->earlyLength - __EarlySizeTable[reverb->earlyMode][i];
reverb->earlyCoef[i] = __EarlyCoefTable[reverb->earlyMode][i] * reverb->earlyGain * 0.6f;
}
reverb->preDelayPos = 0;
reverb->preDelayLength = (u32)(reverb->preDelayTime * (f32)32000);
for (i = 0; i < 3; i++) {
reverb->combPos[i] = 0;
reverb->combLength[i] = __FilterSizeTable[reverb->fusedMode][i];
reverb->combCoef[i] = pow(10.0f, (-3.0f * (f32)(reverb->combLength[i]) / (f32)(reverb->fusedTime * 32000)));
}
for (i = 0; i < 2; i++) {
reverb->allpassPos[i] = 0;
reverb->allpassLength[i] = __FilterSizeTable[reverb->fusedMode][3 + i];
}
for (ch = 0; ch < 4; ch++) {
reverb->lastAllpassPos[ch] = 0;
reverb->lastAllpassLength[ch] = __FilterSizeTable[reverb->fusedMode][5 + ch];
}
reverb->allpassCoef = reverb->coloration;
reverb->lpfCoef = 1.0f - reverb->damping;
if (reverb->lpfCoef > 0.95f)
reverb->lpfCoef = 0.95f;
for (ch = 0; ch < 4; ch++) {
reverb->lastLpfOut[ch] = 0.0f;
}
return TRUE;
}

View File

@@ -23,7 +23,7 @@ BOOL AXFXReverbStdSettings(AXFX_REVERBSTD* fx) {
}
void AXFXReverbStdCallback(void* chans, void* context) {
AXFXReverbStdExpCallback((AXFX_BUFFERUPDATE*)chans, (AXFX_REVERBSTD_EXP*)context);
AXFXReverbStdExpCallback((AXFX_BUS*)chans, (AXFX_REVERBSTD_EXP*)context);
}
static void __ParamConvert(AXFX_REVERBSTD* fx) {

View File

@@ -0,0 +1,397 @@
#include <private/axfx.h>
#include <revolution/AXFX.h>
#include <revolution/MEM.h>
#include <revolution/OS.h>
#include <revolution/ax.h>
#include <math.h>
#include <string.h>
static BOOL __AllocDelayLine(AXFX_REVERBSTD_EXP* fx);
static void __BzeroDelayLines(AXFX_REVERBSTD_EXP* fx);
static void __FreeDelayLine(AXFX_REVERBSTD_EXP* fx);
static BOOL __InitParams(AXFX_REVERBSTD_EXP* fx);
static u32 __EarlySizeTable[8] = {163, 317, 479, 641, 797, 967, 1123, 1283};
static u32 __FilterSizeTable[7][4] = {{1789, 1999, 433, 149}, {149, 293, 251, 103}, {947, 1361, 433, 137},
{1279, 1531, 509, 149}, {1531, 1847, 563, 179}, {1823, 2357, 571, 137},
{1823, 2357, 571, 179}};
u32 AXFXReverbStdExpGetMemSize(AXFX_REVERBSTD_EXP* fx) {
u32 sum = 0;
u32 i = 0;
sum += __EarlySizeTable[7];
sum += (int)(fx->preDelayTimeMax * 32000);
for (i = 0; i < 4; i++) {
sum += __FilterSizeTable[6][i];
}
sum *= 3;
sum *= 4;
return sum;
}
BOOL AXFXReverbStdExpInit(AXFX_REVERBSTD_EXP* fx) {
u32 ch, i;
BOOL result = TRUE;
BOOL mask = OSDisableInterrupts();
fx->active = 1;
if (fx->preDelayTimeMax < 0.0f) {
AXFXReverbStdExpShutdown(fx);
OSRestoreInterrupts(mask);
return FALSE;
}
fx->earlyMaxLength = __EarlySizeTable[8 - 1];
fx->preDelayMaxLength = (u32)(fx->preDelayTimeMax * 32000);
for (i = 0; i < 2; i++) {
fx->combMaxLength[i] = __FilterSizeTable[6][i];
}
for (i = 0; i < 2; i++) {
fx->allpassMaxLength[i] = __FilterSizeTable[6][2 + i];
}
result = __AllocDelayLine(fx);
if (result == FALSE) {
AXFXReverbStdExpShutdown(fx);
OSRestoreInterrupts(mask);
return FALSE;
}
__BzeroDelayLines(fx);
result = __InitParams(fx);
if (result == FALSE) {
AXFXReverbStdExpShutdown(fx);
OSRestoreInterrupts(mask);
return FALSE;
}
fx->active &= ~1;
OSRestoreInterrupts(mask);
return TRUE;
}
BOOL AXFXReverbStdExpSettings(AXFX_REVERBSTD_EXP* fx) {
BOOL mask = OSDisableInterrupts();
fx->active = fx->active | 1;
AXFXReverbStdExpShutdown(fx);
if (!AXFXReverbStdExpInit(fx)) {
AXFXReverbStdExpShutdown(fx);
OSRestoreInterrupts(mask);
return FALSE;
} else {
fx->active |= 2;
fx->active &= ~1;
OSRestoreInterrupts(mask);
return TRUE;
}
}
void AXFXReverbStdExpShutdown(AXFX_REVERBSTD_EXP* fx) {
BOOL mask = OSDisableInterrupts();
fx->active |= 1;
__FreeDelayLine(fx);
OSRestoreInterrupts(mask);
}
void AXFXReverbStdExpCallback(AXFX_BUS* bus, AXFX_REVERBSTD_EXP* reverb) {
u32 i, j;
s32* busParam[AXFX_STEREO_CHANNEL_MAX];
s32* busIn[AXFX_STEREO_CHANNEL_MAX];
s32* busOut[AXFX_STEREO_CHANNEL_MAX];
u32 earlyPos;
u32 preDelayPos;
u32 combPos0;
u32 combPos1;
u32 allpassPos0;
u32 allpassPos1;
f32 sp64;
f32 sp60;
f32* earlyLine;
f32 sp58;
f32 earlyCoef;
f32* preDelayLine;
f32 sp4C;
f32* combLine0;
f32* combLine1;
f32 sp40;
f32 sp3C;
f32 sp38;
f32 combCoef0;
f32 combCoef1;
f32 sp2C;
f32 sp28;
f32 sp24;
f32 sp20;
f32 allpassCoef;
f32 sp18;
f32 sp14;
f32 lpfCoef;
f32 spC;
f32 sp8;
f32* allpassLine;
if (reverb->active != 0) {
reverb->active &= ~2;
return;
}
busParam[AX_STEREO_L] = bus->left;
busParam[AX_STEREO_R] = bus->right;
busParam[AX_STEREO_S] = bus->surround;
if (reverb->busIn) {
busIn[AX_STEREO_L] = reverb->busIn->left;
busIn[AX_STEREO_R] = reverb->busIn->right;
busIn[AX_STEREO_S] = reverb->busIn->surround;
}
if (reverb->busOut) {
busOut[AX_STEREO_L] = reverb->busOut->left;
busOut[AX_STEREO_R] = reverb->busOut->right;
busOut[AX_STEREO_S] = reverb->busOut->surround;
}
sp14 = 1.0f - reverb->lpfCoef;
lpfCoef = reverb->lpfCoef;
earlyCoef = reverb->earlyCoef;
combCoef0 = reverb->combCoef[0];
combCoef1 = reverb->combCoef[1];
allpassCoef = reverb->allpassCoef;
spC = 0.6f * reverb->earlyGain;
sp8 = 0.6f * reverb->fusedGain;
for (i = 0; i < 96; i++) {
earlyPos = reverb->earlyPos;
preDelayPos = reverb->preDelayPos;
combPos0 = reverb->combPos[0];
combPos1 = reverb->combPos[1];
allpassPos0 = reverb->allpassPos[0];
allpassPos1 = reverb->allpassPos[1];
for (j = 0; j < AXFX_STEREO_CHANNEL_MAX; j++) {
if (reverb->busIn) {
sp64 = *busParam[j] + *busIn[j]++;
} else {
sp64 = *busParam[j];
}
earlyLine = reverb->earlyLine[j];
sp58 = earlyLine[earlyPos];
earlyLine[earlyPos] = sp64 + (sp58 * earlyCoef);
if (reverb->preDelayLength != 0) {
preDelayLine = reverb->preDelayLine[j];
sp4C = preDelayLine[preDelayPos];
preDelayLine[preDelayPos] = sp64;
} else {
sp4C = sp64;
}
combLine0 = reverb->combLine[j][0];
sp40 = combLine0[combPos0];
combLine0[combPos0] = sp4C + (sp40 * combCoef0);
combLine1 = reverb->combLine[j][1];
sp3C = combLine1[combPos1];
combLine1[combPos1] = sp4C + (sp3C * combCoef1);
sp38 = sp40 + sp3C;
allpassLine = reverb->allpassLine[j][0];
sp2C = allpassLine[allpassPos0];
sp28 = sp38 + (sp2C * allpassCoef);
allpassLine[allpassPos0] = sp28;
sp24 = sp2C - (sp28 * allpassCoef);
sp18 = (sp14 * sp24) + (lpfCoef * reverb->lastLpfOut[j]);
reverb->lastLpfOut[j] = sp18;
allpassLine = reverb->allpassLine[j][1];
sp2C = allpassLine[allpassPos1];
sp28 = sp18 + (sp2C * allpassCoef);
allpassLine[allpassPos1] = sp28;
sp20 = sp2C - (sp28 * allpassCoef);
sp60 = (sp58 * spC) + (sp20 * sp8);
*busParam[j]++ = (sp60 * reverb->outGain);
if (reverb->busOut) {
*busOut[j]++ = (sp60 * reverb->sendGain);
}
}
if (++reverb->earlyPos >= reverb->earlyLength) {
reverb->earlyPos = 0;
}
if (reverb->preDelayLength != 0) {
if (++reverb->preDelayPos >= reverb->preDelayLength) {
reverb->preDelayPos = 0;
}
}
if (++reverb->combPos[0] >= reverb->combLength[0]) {
reverb->combPos[0] = 0;
}
if (++reverb->combPos[1] >= reverb->combLength[1]) {
reverb->combPos[1] = 0;
}
if (++reverb->allpassPos[0] >= reverb->allpassLength[0]) {
reverb->allpassPos[0] = 0;
}
if (++reverb->allpassPos[1] >= reverb->allpassLength[1]) {
reverb->allpassPos[1] = 0;
}
}
}
static BOOL __AllocDelayLine(AXFX_REVERBSTD_EXP* fx) {
u32 ch, i;
for (ch = 0; ch < 3; ch++) {
fx->earlyLine[ch] = (f32*)__AXFXAlloc(sizeof(f32) * fx->earlyMaxLength);
if (fx->earlyLine[ch] == NULL)
return FALSE;
if (fx->preDelayMaxLength) {
fx->preDelayLine[ch] = (f32*)__AXFXAlloc(sizeof(f32) * fx->preDelayMaxLength);
if (fx->preDelayLine[ch] == NULL)
return FALSE;
} else {
fx->preDelayLine[ch] = NULL;
}
for (i = 0; i < 2; i++) {
fx->combLine[ch][i] = (f32*)__AXFXAlloc(sizeof(f32) * fx->combMaxLength[i]);
if (fx->combLine[ch][i] == NULL)
return FALSE;
}
for (i = 0; i < 2; i++) {
fx->allpassLine[ch][i] = (f32*)__AXFXAlloc(sizeof(f32) * fx->allpassMaxLength[i]);
if (fx->allpassLine[ch][i] == NULL)
return FALSE;
}
}
return TRUE;
}
static void __BzeroDelayLines(AXFX_REVERBSTD_EXP* fx) {
u32 ch, i;
for (ch = 0; ch < 3; ch++) {
if (fx->earlyLine[ch])
memset(fx->earlyLine[ch], 0, sizeof(f32) * fx->earlyMaxLength);
if (fx->preDelayLine[ch])
memset(fx->preDelayLine[ch], 0, sizeof(f32) * fx->preDelayMaxLength);
for (i = 0; i < 2; i++) {
if (fx->combLine[ch][i])
memset(fx->combLine[ch][i], 0, sizeof(f32) * fx->combMaxLength[i]);
}
for (i = 0; i < 2; i++) {
if (fx->allpassLine[ch][i])
memset(fx->allpassLine[ch][i], 0, sizeof(f32) * fx->allpassMaxLength[i]);
}
}
}
static void __FreeDelayLine(AXFX_REVERBSTD_EXP* fx) {
u32 ch, i;
for (ch = 0; ch < 3; ch++) {
if (fx->earlyLine[ch]) {
__AXFXFree(fx->earlyLine[ch]);
fx->earlyLine[ch] = NULL;
}
if (fx->preDelayLine[ch]) {
__AXFXFree(fx->preDelayLine[ch]);
fx->preDelayLine[ch] = NULL;
}
for (i = 0; i < 2; i++) {
if (fx->combLine[ch][i]) {
__AXFXFree(fx->combLine[ch][i]);
fx->combLine[ch][i] = NULL;
}
}
for (i = 0; i < 2; i++) {
if (fx->allpassLine[ch][i]) {
__AXFXFree(fx->allpassLine[ch][i]);
fx->allpassLine[ch][i] = NULL;
}
}
}
}
static BOOL __InitParams(AXFX_REVERBSTD_EXP* fx) {
u32 i;
if (fx->earlyMode >= 8)
return FALSE;
if (fx->preDelayTime < 0.0f || fx->preDelayTime > fx->preDelayTimeMax)
return FALSE;
if (fx->fusedMode >= 6)
return FALSE;
if (fx->fusedTime < 0.0f)
return FALSE;
if (fx->coloration < 0.0f || fx->coloration > 1.0f)
return FALSE;
if (fx->damping < 0.0f || fx->damping > 1.0f)
return FALSE;
if (fx->earlyGain < 0.0f || fx->earlyGain > 1.0f)
return FALSE;
if (fx->fusedGain < 0.0f || fx->fusedGain > 1.0f)
return FALSE;
if (fx->outGain < 0.0f || fx->outGain > 1.0f)
return FALSE;
if (fx->sendGain < 0.0f || fx->sendGain > 1.0f)
return FALSE;
fx->earlyPos = 0;
fx->earlyLength = __EarlySizeTable[fx->earlyMode];
if (fx->earlyMode <= 3) {
fx->earlyCoef = -0.33f;
} else {
fx->earlyCoef = 0.33f;
}
fx->preDelayPos = 0;
fx->preDelayLength = (u32)(fx->preDelayTime * 32000);
for (i = 0; i < 2; i++) {
f32 t;
fx->combPos[i] = 0;
fx->combLength[i] = __FilterSizeTable[fx->fusedMode][i];
t = -3.0f * (f32)(fx->combLength[i]) / (f32)(fx->fusedTime * 32000);
fx->combCoef[i] = pow(10.0f, t);
}
fx->allpassPos[0] = 0;
fx->allpassLength[0] = __FilterSizeTable[fx->fusedMode][2];
fx->allpassPos[1] = 0;
fx->allpassLength[1] = __FilterSizeTable[fx->fusedMode][3];
fx->allpassCoef = fx->coloration;
fx->lpfCoef = 1.0f - fx->damping;
if (fx->lpfCoef > 0.95f) {
fx->lpfCoef = 0.95f;
}
fx->lastLpfOut[0] = 0.0f;
fx->lastLpfOut[1] = 0.0f;
fx->lastLpfOut[2] = 0.0f;
return TRUE;
}