From 82334f790b4c0d252628035aeb61be9281b2a949 Mon Sep 17 00:00:00 2001 From: gheskett Date: Wed, 4 Aug 2021 23:16:03 -0500 Subject: [PATCH] delayBufs now 2 variables --- src/audio/heap.c | 9 ++++----- src/audio/synthesis.c | 29 +++++++++++++++-------------- src/audio/synthesis.h | 3 ++- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/audio/heap.c b/src/audio/heap.c index 27423a10..65daf79f 100644 --- a/src/audio/heap.c +++ b/src/audio/heap.c @@ -1460,12 +1460,11 @@ void audio_reset_session(void) { for (i = 0; i < NUM_ALLPASS; ++i) delays[i] = delaysBaseline[i] / gReverbDownsampleRate; - delayBufs = (s32***) soundAlloc(&gAudioSessionPool, 2 * sizeof(s32**)); - delayBufs[0] = (s32**) soundAlloc(&gAudioSessionPool, NUM_ALLPASS * sizeof(s32*)); - delayBufs[1] = (s32**) soundAlloc(&gAudioSessionPool, NUM_ALLPASS * sizeof(s32*)); + delayBufsL = (s32**) soundAlloc(&gAudioSessionPool, NUM_ALLPASS * sizeof(s32*)); + delayBufsR = (s32**) soundAlloc(&gAudioSessionPool, NUM_ALLPASS * sizeof(s32*)); for (i = 0; i < NUM_ALLPASS; ++i) { - delayBufs[0][i] = (s32*) soundAlloc(&gAudioSessionPool, delays[i] * sizeof(s32)); - delayBufs[1][i] = (s32*) soundAlloc(&gAudioSessionPool, delays[i] * sizeof(s32)); + delayBufsL[i] = (s32*) soundAlloc(&gAudioSessionPool, delays[i] * sizeof(s32)); + delayBufsR[i] = (s32*) soundAlloc(&gAudioSessionPool, delays[i] * sizeof(s32)); } } #endif diff --git a/src/audio/synthesis.c b/src/audio/synthesis.c index d412c469..ac60faad 100644 --- a/src/audio/synthesis.c +++ b/src/audio/synthesis.c @@ -123,7 +123,8 @@ u8 toggleBetterReverb = TRUE; s32 allpassIdx[NUM_ALLPASS] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; s32 tmpBufL[NUM_ALLPASS] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; s32 tmpBufR[NUM_ALLPASS] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -s32 ***delayBufs; +s32 **delayBufsL; +s32 **delayBufsR; #endif @@ -180,29 +181,29 @@ inline void reverb_samples(s16 *outSampleL, s16 *outSampleR, s32 inSampleL, s32 s32 tmpCarryoverR = ((tmpBufR[NUM_ALLPASS-1] * gReverbRevIndex) / 256); for (; i < NUM_ALLPASS; ++i, ++j) { - tmpBufL[i] = delayBufs[0][i][allpassIdx[i]]; - tmpBufR[i] = delayBufs[1][i][allpassIdx[i]]; + tmpBufL[i] = delayBufsL[i][allpassIdx[i]]; + tmpBufR[i] = delayBufsR[i][allpassIdx[i]]; if (j == 2) { j = -1; outTmpL += (tmpBufL[i] * reverbMults[0][k]) / 256; outTmpR += (tmpBufR[i] * reverbMults[1][k++]) / 256; - delayBufs[0][i][allpassIdx[i]] = tmpCarryoverL; - delayBufs[1][i][allpassIdx[i]] = tmpCarryoverR; + delayBufsL[i][allpassIdx[i]] = tmpCarryoverL; + delayBufsR[i][allpassIdx[i]] = tmpCarryoverR; if (i != NUM_ALLPASS - 1) { tmpCarryoverL = (tmpBufL[i] * gReverbRevIndex) / 256; tmpCarryoverR = (tmpBufR[i] * gReverbRevIndex) / 256; } } else { - delayBufs[0][i][allpassIdx[i]] = (tmpBufL[i] * (-gReverbGainIndex)) / 256 + tmpCarryoverL; - delayBufs[1][i][allpassIdx[i]] = (tmpBufR[i] * (-gReverbGainIndex)) / 256 + tmpCarryoverR; + delayBufsL[i][allpassIdx[i]] = (tmpBufL[i] * (-gReverbGainIndex)) / 256 + tmpCarryoverL; + delayBufsR[i][allpassIdx[i]] = (tmpBufR[i] * (-gReverbGainIndex)) / 256 + tmpCarryoverR; if (i == 6) - delayBufs[1][i][allpassIdx[i]] += inSampleR; // Unique to right channel + delayBufsR[i][allpassIdx[i]] += inSampleR; // Unique to right channel - tmpCarryoverL = (delayBufs[0][i][allpassIdx[i]] * gReverbGainIndex) / 256 + tmpBufL[i]; - tmpCarryoverR = (delayBufs[1][i][allpassIdx[i]] * gReverbGainIndex) / 256 + tmpBufR[i]; + tmpCarryoverL = (delayBufsL[i][allpassIdx[i]] * gReverbGainIndex) / 256 + tmpBufL[i]; + tmpCarryoverR = (delayBufsR[i][allpassIdx[i]] * gReverbGainIndex) / 256 + tmpBufR[i]; } if (++allpassIdx[i] == delays[i]) @@ -221,18 +222,18 @@ inline void reverb_mono_sample(s16 *outSample, s32 inSample) { s32 tmpCarryover = ((tmpBufL[NUM_ALLPASS-1] * gReverbRevIndex) / 256) + inSample; for (; i < NUM_ALLPASS; ++i, ++j) { - tmpBufL[i] = delayBufs[0][i][allpassIdx[i]]; + tmpBufL[i] = delayBufsL[i][allpassIdx[i]]; if (j == 2) { j = -1; outTmp += (tmpBufL[i] * reverbMults[0][k++]) / 256; - delayBufs[0][i][allpassIdx[i]] = tmpCarryover; + delayBufsL[i][allpassIdx[i]] = tmpCarryover; if (i != NUM_ALLPASS - 1) tmpCarryover = (tmpBufL[i] * gReverbRevIndex) / 256; } else { - delayBufs[0][i][allpassIdx[i]] = (tmpBufL[i] * (-gReverbGainIndex)) / 256 + tmpCarryover; - tmpCarryover = (delayBufs[0][i][allpassIdx[i]] * gReverbGainIndex) / 256 + tmpBufL[i]; + delayBufsL[i][allpassIdx[i]] = (tmpBufL[i] * (-gReverbGainIndex)) / 256 + tmpCarryover; + tmpCarryover = (delayBufsL[i][allpassIdx[i]] * gReverbGainIndex) / 256 + tmpBufL[i]; } if (++allpassIdx[i] == delays[i]) diff --git a/src/audio/synthesis.h b/src/audio/synthesis.h index de636143..6d1f5916 100644 --- a/src/audio/synthesis.h +++ b/src/audio/synthesis.h @@ -30,7 +30,8 @@ extern s32 betterReverbWindowsSize; extern const s32 delaysBaseline[NUM_ALLPASS]; extern s32 delays[NUM_ALLPASS]; -extern s32 ***delayBufs; +extern s32 **delayBufsL; +extern s32 **delayBufsR; extern u8 toggleBetterReverb; extern s8 betterReverbConsoleDownsample;