Add missing musyx header, minor progress on reverb.c

Former-commit-id: 139243d32c
This commit is contained in:
Phillip Stephens 2023-06-29 03:56:20 -07:00
parent c30690fe6c
commit 4108a3f839
4 changed files with 23 additions and 124 deletions

View File

@ -919,10 +919,10 @@ LIBS = [
}, },
{ {
"lib": "musyx", "lib": "musyx",
#"mw_version": "1.2.5", "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", "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", #"mw_version": "1.3.2",
"cflags": "$cflags_musyx -DMUSY_VERSION_MAJOR=1 -DMUSY_VERSION_MINOR=5 -DMUSY_VERSION_PATCH=4", #"cflags": "$cflags_musyx -DMUSY_VERSION_MAJOR=1 -DMUSY_VERSION_MINOR=5 -DMUSY_VERSION_PATCH=4",
"host": False, "host": False,
"objects": [ "objects": [
["musyx/runtime/seq", False], ["musyx/runtime/seq", False],

16
include/musyx/hardware.h Normal file
View File

@ -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

View File

@ -27,7 +27,7 @@ typedef double f64;
typedef unsigned char bool8; typedef unsigned char bool8;
#endif #endif
#ifndef __cplusplus #ifndef __cplusplus
typedef signed long bool; typedef unsigned long bool;
#define FALSE 0 #define FALSE 0
#define TRUE 1 #define TRUE 1
#endif #endif
@ -318,8 +318,8 @@ typedef struct SND_AUX_REVERBHI {
} SND_AUX_REVERBHI; } SND_AUX_REVERBHI;
void sndAuxCallbackReverbHI(u8 reason, SND_AUX_INFO* info, void* user); void sndAuxCallbackReverbHI(u8 reason, SND_AUX_INFO* info, void* user);
s32 sndAuxCallbackPrepareReverbHI(SND_AUX_REVERBHI* rev); bool sndAuxCallbackPrepareReverbHI(SND_AUX_REVERBHI* rev);
s32 sndAuxCallbackShutdownReverbHI(SND_AUX_REVERBHI* rev); bool sndAuxCallbackShutdownReverbHI(SND_AUX_REVERBHI* rev);
typedef struct SND_AUX_DELAY { typedef struct SND_AUX_DELAY {
u32 currentSize[3]; u32 currentSize[3];

View File

@ -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]);
}
}
}