diff --git a/include/musyx/musyx.h b/include/musyx/musyx.h index 23fe3574..f1070ec4 100644 --- a/include/musyx/musyx.h +++ b/include/musyx/musyx.h @@ -3,6 +3,10 @@ #include "types.h" +#ifndef bool8 +typedef char bool8; +#endif + #ifdef __cplusplus extern "C" { #endif @@ -16,10 +20,59 @@ typedef struct _SynthInfo { } SynthInfo; typedef struct _SND_HOOKS { - void *(*malloc)(u32 len); - void (*free)(void *addr); + void* (*malloc)(u32 len); + void (*free)(void* addr); } SND_HOOKS; - + +#define SND_AUX_NUMPARAMETERS 4 + +typedef struct SND_AUX_INFO { + union SND_AUX_DATA { + struct SND_AUX_BUFFERUPDATE { + s32* left; + s32* right; + s32* surround; + } bufferUpdate; + struct SND_AUX_PARAMETERUPDATE { + u16 para[SND_AUX_NUMPARAMETERS]; + } parameterUpdate; + } data; +} SND_AUX_INFO; + +typedef struct _SND_REVHI_DELAYLINE { + s32 inPoint; + s32 outPoint; + s32 length; + f32* inputs; + f32 lastOutput; +} _SND_REVHI_DELAYLINE; + +typedef struct _SND_REVHI_WORK { + _SND_REVHI_DELAYLINE AP[9]; + _SND_REVHI_DELAYLINE C[9]; + f32 allPassCoeff; + f32 combCoef[9]; + f32 lpLastout[3]; + f32 level; + f32 damping; + s32 preDelayTime; + f32 crosstalk; + f32* preDelayLine[3]; + f32* preDelayPtr[3]; +} _SND_REVHI_WORK; + +typedef struct SND_AUX_REVERBHI { + _SND_REVHI_WORK rv; + bool8 tempDisableFX; + + f32 coloration; + f32 mix; + f32 time; + f32 damping; + f32 preDelay; + f32 crosstalk; +} SND_AUX_REVERBHI; + #ifdef __cplusplus } #endif diff --git a/obj_files.mk b/obj_files.mk index 69c033a0..c6ba6c21 100644 --- a/obj_files.mk +++ b/obj_files.mk @@ -808,7 +808,7 @@ MUSYX_FILES :=\ $(BUILD_DIR)/src/musyx/hw_memory.o\ $(BUILD_DIR)/asm/musyx/creverb_fx.o\ $(BUILD_DIR)/asm/musyx/creverb.o\ - $(BUILD_DIR)/asm/musyx/reverb_fx.o\ + $(BUILD_DIR)/src/musyx/reverb_fx.o\ $(BUILD_DIR)/asm/musyx/reverb.o\ $(BUILD_DIR)/asm/musyx/delay_fx.o\ $(BUILD_DIR)/asm/musyx/chorus_fx.o diff --git a/src/musyx/reverb_fx.c b/src/musyx/reverb_fx.c new file mode 100644 index 00000000..dfd8c8b2 --- /dev/null +++ b/src/musyx/reverb_fx.c @@ -0,0 +1,35 @@ +#include "musyx/musyx_priv.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern bool8 ReverbHICreate(_SND_REVHI_WORK* rev, f32 coloration, f32 time, f32 mix, f32 damping, f32 preDelay, f32 crosstalk); +extern void ReverbHIFree(_SND_REVHI_WORK* rev); + +void sndAuxCallbackReverbHI(u8 reason, SND_AUX_INFO* info, void* user) { + switch (reason) { + case 0: + if (*((u8*)user + 0x1c4) == 0) { + ReverbHICallback(info->data.bufferUpdate.left, info->data.bufferUpdate.right, info->data.bufferUpdate.surround, user); + } + /* fallthrough */ + case 1: + return; + } +} + +bool8 sndAuxCallbackPrepareReverbHI(SND_AUX_REVERBHI *rev) { + rev->tempDisableFX = 0; + return ReverbHICreate(&rev->rv, rev->coloration, rev->time, rev->mix, rev->damping, rev->preDelay, rev->crosstalk); +} + +bool8 sndAuxCallbackShutdownReverbHI(SND_AUX_REVERBHI* rev) { + ReverbHIFree(&rev->rv); + return 1; +} + + +#ifdef __cplusplus +} +#endif