From 139243d32cbb01919c43df02b278b2f31ff15b73 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Thu, 29 Jun 2023 03:56:20 -0700 Subject: [PATCH] Add missing musyx header, minor progress on reverb.c --- configure.py | 8 +-- include/musyx/hardware.h | 16 +++++ include/musyx/musyx.h | 6 +- src/musyx/runtime/reverb.c | 117 ------------------------------------- 4 files changed, 23 insertions(+), 124 deletions(-) create mode 100644 include/musyx/hardware.h delete mode 100644 src/musyx/runtime/reverb.c diff --git a/configure.py b/configure.py index f2fdc619..b5946adc 100755 --- a/configure.py +++ b/configure.py @@ -919,10 +919,10 @@ LIBS = [ }, { "lib": "musyx", - #"mw_version": "1.2.5", - #"cflags": "-proc gecko -fp hard -nodefaults -nosyspath -i include -i libc -g -sym on -D_DEBUG=1 -enum int -DMUSY_VERSION_MAJOR=1 -DMUSY_VERSION_MINOR=5 -DMUSY_VERSION_PATCH=3", - "mw_version": "1.3.2", - "cflags": "$cflags_musyx -DMUSY_VERSION_MAJOR=1 -DMUSY_VERSION_MINOR=5 -DMUSY_VERSION_PATCH=4", + "mw_version": "1.2.5", + "cflags": "-proc gecko -fp hard -nodefaults -nosyspath -i include -i libc -g -sym on -D_DEBUG=1 -enum int -DMUSY_VERSION_MAJOR=1 -DMUSY_VERSION_MINOR=5 -DMUSY_VERSION_PATCH=3", + #"mw_version": "1.3.2", + #"cflags": "$cflags_musyx -DMUSY_VERSION_MAJOR=1 -DMUSY_VERSION_MINOR=5 -DMUSY_VERSION_PATCH=4", "host": False, "objects": [ ["musyx/runtime/seq", False], diff --git a/include/musyx/hardware.h b/include/musyx/hardware.h new file mode 100644 index 00000000..67bd47de --- /dev/null +++ b/include/musyx/hardware.h @@ -0,0 +1,16 @@ +#ifndef _MUSYX_HARDWARE +#define _MUSYX_HARDWARE + + +#include "musyx/musyx_priv.h" +#ifdef __cplusplus +extern "C" { +#endif + +u32 hwIsStudioActive(u8 studio); + +#ifdef __cplusplus +} +#endif + +#endif // _MUSYX_HARDWARE diff --git a/include/musyx/musyx.h b/include/musyx/musyx.h index a9863300..ebddc786 100644 --- a/include/musyx/musyx.h +++ b/include/musyx/musyx.h @@ -27,7 +27,7 @@ typedef double f64; typedef unsigned char bool8; #endif #ifndef __cplusplus -typedef signed long bool; +typedef unsigned long bool; #define FALSE 0 #define TRUE 1 #endif @@ -318,8 +318,8 @@ typedef struct SND_AUX_REVERBHI { } SND_AUX_REVERBHI; void sndAuxCallbackReverbHI(u8 reason, SND_AUX_INFO* info, void* user); -s32 sndAuxCallbackPrepareReverbHI(SND_AUX_REVERBHI* rev); -s32 sndAuxCallbackShutdownReverbHI(SND_AUX_REVERBHI* rev); +bool sndAuxCallbackPrepareReverbHI(SND_AUX_REVERBHI* rev); +bool sndAuxCallbackShutdownReverbHI(SND_AUX_REVERBHI* rev); typedef struct SND_AUX_DELAY { u32 currentSize[3]; diff --git a/src/musyx/runtime/reverb.c b/src/musyx/runtime/reverb.c deleted file mode 100644 index 4bdfd29b..00000000 --- a/src/musyx/runtime/reverb.c +++ /dev/null @@ -1,117 +0,0 @@ -#include "math.h" -#include "musyx/musyx_priv.h" - -static void DLsetdelay(_SND_REVHI_DELAYLINE* delayline, s32 len) { - delayline->outPoint = delayline->inPoint - (len * sizeof(f32)); - while (delayline->outPoint < 0) { - delayline->outPoint += delayline->length; - } -} - -static void DLcreate(_SND_REVHI_DELAYLINE* delayline, s32 length) { - delayline->length = length * sizeof(f32); - delayline->inputs = (f32*)salMalloc(length * sizeof(f32)); - memset(delayline->inputs, 0, length * sizeof(length)); - delayline->lastOutput = 0.f; - DLsetdelay(delayline, length * sizeof(f32)); - delayline->inPoint = 0; - delayline->outPoint = 0; -} - -static void DLdelete(_SND_REVHI_DELAYLINE* delayline) { salFree(delayline->inputs); } -bool ReverbHICreate(_SND_REVHI_WORK* rev, f32 coloration, f32 time, f32 mix, f32 damping, - f32 preDelay, f32 crosstalk) { - static int lens[] = {1789, 1999, 2333, 433, 149, 47, 73, 67}; - u8 i; - u8 j; - if (coloration < 0.f || coloration > 1.f || time < 0.01f || time > 10.f || mix < 0.f || - mix > 1.f || crosstalk < 0.f || crosstalk > 1.f || damping < 0.f || damping > 1.f || - preDelay < 0.f || preDelay > 0.1f) { - return FALSE; - } - - memset(rev, 0, sizeof(_SND_REVHI_WORK)); - - for (i = 0; i < 3; ++i) { - for (j = 0; j < 3; ++j) { - DLcreate(&rev->C[j + i], lens[j] + 2); - DLsetdelay(&rev->C[j + i], lens[j]); - rev->combCoef[j + i * 3] = pow(10.f, (lens[j] * -3) / (32000.f * time)); - } - - for (j = 0; j < 2; ++j) { - DLcreate(&rev->AP[j + i], lens[j + 3] + 2); - DLsetdelay(&rev->AP[j + i], lens[j + 3]); - } - DLcreate(&rev->AP[i + 2], lens[i + 5] + 2); - DLsetdelay(&rev->AP[i + 2], lens[i + 5]); - rev->lpLastout[i] = 0.f; - } - - rev->allPassCoeff = coloration; - rev->level = mix; - rev->crosstalk = crosstalk; - rev->damping = damping; - if (rev->damping < 0.05f) { - rev->damping = 0.05f; - } - - rev->damping = 1.f - ((rev->damping * 0.8f) + 0.5f); - if (preDelay != 0.f) { - rev->preDelayTime = preDelay * 32000.f; - for (i = 0; i < 3; ++i) { - rev->preDelayLine[i] = (f32*)salMalloc(rev->preDelayTime * sizeof(f32)); - memset(rev->preDelayLine[i], 0, rev->preDelayTime * sizeof(f32)); - rev->preDelayPtr[i] = rev->preDelayLine[i]; - } - } else { - rev->preDelayTime = 0; - for (i = 0; i < 3; ++i) { - rev->preDelayPtr[i] = NULL; - rev->preDelayLine[i] = NULL; - } - } - - return TRUE; -} - -static void DoCrossTalk(s32* a, s32* b, f32 start, f32 end) {} - -static void HandleReverb(s32*, SND_AUX_REVERBHI* rev, s32) {} - -#pragma dont_inline on -void ReverbHICallback(s32* left, s32* right, s32* surround, SND_AUX_REVERBHI* rev) { - u8 i; - for (i = 0; i < 3; ++i) { - switch (i) { - case 0: - if (rev->rv.crosstalk != 0.f) { - DoCrossTalk(left, right, 0.5f * rev->rv.crosstalk, 1.f - (0.5f * rev->rv.crosstalk)); - } - HandleReverb(left, rev, 0); - break; - case 1: - HandleReverb(right, rev, 1); - break; - case 2: - HandleReverb(surround, rev, 2); - break; - } - } -} -#pragma dont_inline reset - -void ReverbHIFree(_SND_REVHI_WORK* rv) { - u8 i; - for (i = 0; i < 9; ++i) { - DLdelete(&rv->AP[i]); - } - for (i = 0; i < 9; ++i) { - DLdelete(&rv->C[i]); - } - if (rv->preDelayTime != 0) { - for (i = 0; i < 3; ++i) { - salFree(rv->preDelayLine[i]); - } - } -}