mirror of
https://github.com/izzy2lost/Diddy-Kong-Racing.git
synced 2026-06-19 01:16:26 -07:00
c: _filterBuffer
This commit is contained in:
@@ -97,7 +97,8 @@ else
|
||||
endif
|
||||
|
||||
AS = $(CROSS)as
|
||||
CC := $(QEMU_IRIX) -silent -L $(IRIX_ROOT) $(IRIX_ROOT)/usr/bin/cc
|
||||
#CC := $(QEMU_IRIX) -silent -L $(IRIX_ROOT) $(IRIX_ROOT)/usr/bin/cc
|
||||
CC := $(QEMU_IRIX) -L $(IRIX_ROOT) $(IRIX_ROOT)/usr/bin/cc
|
||||
CPP := cpp -P -Wno-trigraphs
|
||||
LD = $(CROSS)ld
|
||||
OBJDUMP = $(CROSS)objdump
|
||||
@@ -237,6 +238,7 @@ $(BUILD_DIR)/lib/src/unknown_0C91A0.o : OPT_FLAGS := -O1
|
||||
$(BUILD_DIR)/lib/src/unknown_0D29F0.o: OPT_FLAGS := -O1
|
||||
$(BUILD_DIR)/lib/src/unknown_0CDE90.o: OPT_FLAGS := -O1
|
||||
$(BUILD_DIR)/lib/src/unknown_0D3160.o: OPT_FLAGS := -O1
|
||||
$(BUILD_DIR)/lib/src/unknown_066460.o: OPT_FLAGS := -O2 -Wo,-loopunroll,0
|
||||
$(BUILD_DIR)/lib/src/osCreateThread.o : OPT_FLAGS := -O1
|
||||
$(BUILD_DIR)/lib/src/osGetThreadPri.o : OPT_FLAGS := -O1
|
||||
$(BUILD_DIR)/lib/src/osJamMesg.o : OPT_FLAGS := -O1
|
||||
|
||||
+748
-11
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,269 @@
|
||||
#ifndef _AUDIO_INTERNAL_H
|
||||
#define _AUDIO_INTERNAL_H
|
||||
|
||||
#include "PR/libaudio.h"
|
||||
|
||||
/*
|
||||
* filter message ids
|
||||
*/
|
||||
enum {
|
||||
AL_FILTER_FREE_VOICE,
|
||||
AL_FILTER_SET_SOURCE,
|
||||
AL_FILTER_ADD_SOURCE,
|
||||
AL_FILTER_ADD_UPDATE,
|
||||
AL_FILTER_RESET,
|
||||
AL_FILTER_SET_WAVETABLE,
|
||||
/* AL_FILTER_SET_DMA_PROC,*/
|
||||
/* AL_FILTER_SKIP_LOOP,*/
|
||||
AL_FILTER_SET_DRAM,
|
||||
AL_FILTER_SET_PITCH,
|
||||
AL_FILTER_SET_UNITY_PITCH,
|
||||
AL_FILTER_START,
|
||||
/* AL_FILTER_SET_DECAY,*/
|
||||
/* AL_FILTER_SET_FC,*/
|
||||
AL_FILTER_SET_STATE,
|
||||
AL_FILTER_SET_VOLUME,
|
||||
AL_FILTER_SET_PAN,
|
||||
AL_FILTER_START_VOICE_ALT,
|
||||
AL_FILTER_START_VOICE,
|
||||
AL_FILTER_STOP_VOICE,
|
||||
AL_FILTER_SET_FXAMT
|
||||
};
|
||||
|
||||
#define AL_MAX_RSP_SAMPLES 160
|
||||
|
||||
/*
|
||||
* buffer locations based on AL_MAX_RSP_SAMPLES
|
||||
*/
|
||||
#define AL_DECODER_IN 0
|
||||
#define AL_RESAMPLER_OUT 0
|
||||
#define AL_TEMP_0 0
|
||||
#define AL_DECODER_OUT 320
|
||||
#define AL_TEMP_1 320
|
||||
#define AL_TEMP_2 640
|
||||
#define AL_MAIN_L_OUT 1088
|
||||
#define AL_MAIN_R_OUT 1408
|
||||
#define AL_AUX_L_OUT 1728
|
||||
#define AL_AUX_R_OUT 2048
|
||||
|
||||
/*
|
||||
* filter types
|
||||
*/
|
||||
enum {
|
||||
AL_ADPCM,
|
||||
AL_RESAMPLE,
|
||||
AL_BUFFER,
|
||||
AL_SAVE,
|
||||
AL_ENVMIX,
|
||||
AL_FX,
|
||||
AL_AUXBUS,
|
||||
AL_MAINBUS
|
||||
};
|
||||
|
||||
typedef struct ALParam_s {
|
||||
struct ALParam_s *next;
|
||||
s32 delta;
|
||||
s16 type;
|
||||
union {
|
||||
f32 f;
|
||||
s32 i;
|
||||
} data;
|
||||
union {
|
||||
f32 f;
|
||||
s32 i;
|
||||
} moredata;
|
||||
union {
|
||||
f32 f;
|
||||
s32 i;
|
||||
} stillmoredata;
|
||||
union {
|
||||
f32 f;
|
||||
s32 i;
|
||||
} yetstillmoredata;
|
||||
} ALParam;
|
||||
|
||||
typedef struct {
|
||||
struct ALParam_s *next;
|
||||
s32 delta;
|
||||
s16 type;
|
||||
s16 unity; /* disable resampler */
|
||||
f32 pitch;
|
||||
s16 volume;
|
||||
ALPan pan;
|
||||
u8 fxMix;
|
||||
s32 samples;
|
||||
struct ALWaveTable_s *wave;
|
||||
} ALStartParamAlt;
|
||||
|
||||
typedef struct {
|
||||
struct ALParam_s *next;
|
||||
s32 delta;
|
||||
s16 type;
|
||||
s16 unity; /* disable resampler */
|
||||
struct ALWaveTable_s *wave;
|
||||
} ALStartParam;
|
||||
|
||||
typedef struct {
|
||||
struct ALParam_s *next;
|
||||
s32 delta;
|
||||
s16 type;
|
||||
struct PVoice_s *pvoice;
|
||||
} ALFreeParam;
|
||||
|
||||
typedef Acmd *(*ALCmdHandler)(void *, s16 *, s32, s32, Acmd *);
|
||||
typedef s32 (*ALSetParam)(void *, s32, void *);
|
||||
|
||||
typedef struct ALFilter_s {
|
||||
struct ALFilter_s *source;
|
||||
ALCmdHandler handler;
|
||||
ALSetParam setParam;
|
||||
s16 inp;
|
||||
s16 outp;
|
||||
s32 type;
|
||||
} ALFilter;
|
||||
|
||||
#define AL_MAX_ADPCM_STATES 3 /* Depends on number of subframes
|
||||
* per frame and loop length
|
||||
*/
|
||||
typedef struct {
|
||||
ALFilter filter;
|
||||
ADPCM_STATE *state;
|
||||
ADPCM_STATE *lstate;
|
||||
ALRawLoop loop;
|
||||
struct ALWaveTable_s *table;
|
||||
s32 bookSize;
|
||||
ALDMAproc dma;
|
||||
void *dmaState;
|
||||
s32 sample;
|
||||
s32 lastsam;
|
||||
s32 first;
|
||||
s32 memin;
|
||||
} ALLoadFilter;
|
||||
|
||||
typedef struct ALResampler_s {
|
||||
ALFilter filter;
|
||||
RESAMPLE_STATE *state;
|
||||
f32 ratio;
|
||||
s32 upitch;
|
||||
f32 delta;
|
||||
s32 first;
|
||||
ALParam *ctrlList;
|
||||
ALParam *ctrlTail;
|
||||
s32 motion;
|
||||
} ALResampler;
|
||||
|
||||
typedef struct {
|
||||
s16 fc;
|
||||
s16 fgain;
|
||||
union {
|
||||
s16 fccoef[16];
|
||||
s64 force_aligned;
|
||||
} fcvec;
|
||||
POLEF_STATE *fstate;
|
||||
s32 first;
|
||||
} ALLowPass;
|
||||
|
||||
typedef struct {
|
||||
u32 input;
|
||||
u32 output;
|
||||
s16 ffcoef;
|
||||
s16 fbcoef;
|
||||
s16 gain;
|
||||
f32 rsinc;
|
||||
f32 rsval;
|
||||
s32 rsdelta;
|
||||
f32 rsgain;
|
||||
ALLowPass *lp;
|
||||
ALResampler *rs;
|
||||
} ALDelay;
|
||||
|
||||
typedef s32 (*ALSetFXParam)(void *, s32, void *);
|
||||
typedef struct {
|
||||
struct ALFilter_s filter;
|
||||
s16 *base;
|
||||
s16 *input;
|
||||
u32 length;
|
||||
ALDelay *delay;
|
||||
u8 section_count;
|
||||
ALSetFXParam paramHdl;
|
||||
} ALFx;
|
||||
|
||||
#define AL_MAX_MAIN_BUS_SOURCES 1
|
||||
typedef struct ALMainBus_s {
|
||||
ALFilter filter;
|
||||
s32 sourceCount;
|
||||
s32 maxSources;
|
||||
ALFilter **sources;
|
||||
} ALMainBus;
|
||||
|
||||
#define AL_MAX_AUX_BUS_SOURCES 8
|
||||
#define AL_MAX_AUX_BUS_FX 1
|
||||
typedef struct ALAuxBus_s {
|
||||
ALFilter filter;
|
||||
s32 sourceCount;
|
||||
s32 maxSources;
|
||||
ALFilter **sources;
|
||||
ALFx fx[AL_MAX_AUX_BUS_FX];
|
||||
} ALAuxBus;
|
||||
|
||||
typedef struct ALSave_s {
|
||||
ALFilter filter;
|
||||
s32 dramout;
|
||||
s32 first;
|
||||
} ALSave;
|
||||
|
||||
typedef struct ALEnvMixer_s {
|
||||
ALFilter filter;
|
||||
ENVMIX_STATE *state;
|
||||
s16 pan;
|
||||
s16 volume;
|
||||
s16 cvolL;
|
||||
s16 cvolR;
|
||||
s16 dryamt;
|
||||
s16 wetamt;
|
||||
u16 lratl;
|
||||
s16 lratm;
|
||||
s16 ltgt;
|
||||
u16 rratl;
|
||||
s16 rratm;
|
||||
s16 rtgt;
|
||||
s32 delta;
|
||||
s32 segEnd;
|
||||
s32 first;
|
||||
ALParam *ctrlList;
|
||||
ALParam *ctrlTail;
|
||||
ALFilter **sources;
|
||||
s32 motion;
|
||||
} ALEnvMixer;
|
||||
|
||||
/*
|
||||
* heap stuff
|
||||
*/
|
||||
typedef struct {
|
||||
s32 magic; /* check structure integrety */
|
||||
s32 size; /* size of this allocated block */
|
||||
u8 *file; /* file that this alloc was called from */
|
||||
s32 line; /* line that it was called from */
|
||||
s32 count; /* heap call number */
|
||||
s32 pad0;
|
||||
s32 pad1;
|
||||
s32 pad2; /* Make it 32 bytes */
|
||||
} HeapInfo;
|
||||
|
||||
#define AL_CACHE_ALIGN 15
|
||||
|
||||
/*
|
||||
* synth stuff
|
||||
*/
|
||||
|
||||
typedef struct PVoice_s {
|
||||
ALLink node;
|
||||
struct ALVoice_s *vvoice;
|
||||
ALFilter *channelKnob;
|
||||
ALLoadFilter decoder;
|
||||
ALResampler resampler;
|
||||
ALEnvMixer envmixer;
|
||||
s32 offset;
|
||||
} PVoice;
|
||||
|
||||
#endif
|
||||
Binary file not shown.
+94
-124
@@ -4,6 +4,7 @@
|
||||
#include "types.h"
|
||||
#include "macros.h"
|
||||
#include "libultra_internal.h"
|
||||
#include "audio_internal.h"
|
||||
|
||||
extern s32 alAuxBusPull;
|
||||
extern s32 alAuxBusParam;
|
||||
@@ -20,9 +21,9 @@ extern s32 alSavePull;
|
||||
|
||||
GLOBAL_ASM("asm/non_matchings/unknown_064830/alFxPull.s")
|
||||
|
||||
s32 alFxParam(s32* arg0, s32 arg1, s32 arg2) {
|
||||
if (arg1 == 1) {
|
||||
*arg0 = arg2;
|
||||
s32 alFxParam(void* filter, s32 paramID, void* param) {
|
||||
if (paramID == 1) {
|
||||
((ALFilter *)filter)->source = param;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -31,140 +32,109 @@ GLOBAL_ASM("asm/non_matchings/unknown_064830/alFxParamHdl.s")
|
||||
GLOBAL_ASM("asm/non_matchings/unknown_064830/_loadOutputBuffer.s")
|
||||
GLOBAL_ASM("asm/non_matchings/unknown_064830/_loadBuffer.s")
|
||||
GLOBAL_ASM("asm/non_matchings/unknown_064830/_saveBuffer.s")
|
||||
GLOBAL_ASM("asm/non_matchings/unknown_064830/_filterBuffer.s")
|
||||
//GLOBAL_ASM("asm/non_matchings/unknown_064830/_filterBuffer.s")
|
||||
Acmd *_filterBuffer(ALLowPass *lp, s32 buff, s32 count, Acmd *p)
|
||||
{
|
||||
Acmd *ptr = p;
|
||||
|
||||
aSetBuffer(ptr++, 0, buff, buff, count<<1);
|
||||
aLoadADPCM(ptr++, 32, osVirtualToPhysical(lp->fcvec.fccoef));
|
||||
aPoleFilter(ptr++, lp->first, lp->fgain, osVirtualToPhysical(lp->fstate));
|
||||
lp->first = 0;
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
GLOBAL_ASM("asm/non_matchings/unknown_064830/_doModFunc.s")
|
||||
GLOBAL_ASM("asm/non_matchings/unknown_064830/func_8006492C.s")
|
||||
GLOBAL_ASM("asm/non_matchings/unknown_064830/init_lpfilter.s")
|
||||
|
||||
#define SCALE 16384
|
||||
|
||||
void init_lpfilter(ALLowPass *lp)
|
||||
{
|
||||
s32 i, temp;
|
||||
s16 fc;
|
||||
f64 ffc, fcoef;
|
||||
|
||||
temp = lp->fc * SCALE;
|
||||
fc = temp >> 15;
|
||||
lp->fgain = SCALE - fc;
|
||||
|
||||
lp->first = 1;
|
||||
for (i=0; i<8; i++)
|
||||
lp->fcvec.fccoef[i] = 0;
|
||||
|
||||
lp->fcvec.fccoef[i++] = fc;
|
||||
fcoef = ffc = (f64)fc/SCALE;
|
||||
|
||||
for (; i<16; i++){
|
||||
fcoef *= ffc;
|
||||
lp->fcvec.fccoef[i] = (s16)(fcoef * SCALE);
|
||||
}
|
||||
}
|
||||
|
||||
GLOBAL_ASM("asm/non_matchings/unknown_064830/alFxNew.s")
|
||||
|
||||
typedef struct unk80064E54 {
|
||||
u8 unk00[0x14]; // unknown
|
||||
s32 unk14;
|
||||
s16 unk18;
|
||||
s16 unk1A;
|
||||
s16 unk1C;
|
||||
s16 unk1E;
|
||||
s16 unk20;
|
||||
s16 unk22;
|
||||
s16 unk24;
|
||||
s16 unk26;
|
||||
s16 unk28;
|
||||
u8 unk2A[0x04]; // unknown
|
||||
s16 unk2E;
|
||||
s32 unk30;
|
||||
s32 unk34;
|
||||
s32 unk38;
|
||||
s32 unk3C;
|
||||
s32 unk40;
|
||||
s32 unk44;
|
||||
s32 unk48;
|
||||
} unk80064E54;
|
||||
|
||||
void alEnvmixerNew(unk80064E54* arg0, s32 arg1) {
|
||||
alFilterNew(arg0, &alEnvMixerPull, &alEnvmixerParam, 4);
|
||||
arg0->unk14 = alHeapDBAlloc(0, 0, arg1, 1, 0x50);
|
||||
arg0->unk38 = 1;
|
||||
arg0->unk48 = 0;
|
||||
arg0->unk1A = 1;
|
||||
arg0->unk28 = 1;
|
||||
arg0->unk2E = 1;
|
||||
arg0->unk1C = 1;
|
||||
arg0->unk1E = 1;
|
||||
arg0->unk20 = 0;
|
||||
arg0->unk22 = 0;
|
||||
arg0->unk26 = 1;
|
||||
arg0->unk24 = 0;
|
||||
arg0->unk30 = 0;
|
||||
arg0->unk34 = 0;
|
||||
arg0->unk18 = 0;
|
||||
arg0->unk3C = 0;
|
||||
arg0->unk40 = 0;
|
||||
arg0->unk44 = 0;
|
||||
void alEnvmixerNew(ALEnvMixer* e, s32 arg1) {
|
||||
alFilterNew(e, &alEnvMixerPull, &alEnvmixerParam, 4);
|
||||
e->state = alHeapDBAlloc(0, 0, arg1, 1, 0x50);
|
||||
e->first = 1;
|
||||
e->motion = AL_STOPPED;
|
||||
e->volume = 1;
|
||||
e->ltgt = 1;
|
||||
e->rtgt = 1;
|
||||
e->cvolL = 1;
|
||||
e->cvolR = 1;
|
||||
e->dryamt = 0;
|
||||
e->wetamt = 0;
|
||||
e->lratm = 1;
|
||||
e->lratl = 0;
|
||||
e->delta = 0;
|
||||
e->segEnd = 0;
|
||||
e->pan = 0;
|
||||
e->ctrlList = 0;
|
||||
e->ctrlTail = 0;
|
||||
e->sources = 0;
|
||||
}
|
||||
|
||||
typedef struct ALFilter_s {
|
||||
u8 unk00[0x14]; // unknown
|
||||
s32 unk14;
|
||||
s32 unk18;
|
||||
u8 unk1C[0x14]; // unknown
|
||||
s32 unk30;
|
||||
s32 unk34;
|
||||
u8 unk38[0x04]; // unknown
|
||||
s32 unk3C;
|
||||
s32 unk40;
|
||||
s32 unk44;
|
||||
} ALFilter;
|
||||
|
||||
void alLoadNew(ALFilter* arg0, s32 (*arg1)(s32*), s32 arg2) {
|
||||
void alLoadNew(ALLoadFilter* arg0, s32 (*arg1)(s32*), s32 arg2) {
|
||||
alFilterNew(arg0, &alLoadPull, &alLoadParam, 0);
|
||||
arg0->unk14 = alHeapDBAlloc(0, 0, arg2, 1, 0x20);
|
||||
arg0->unk18 = alHeapDBAlloc(0, 0, arg2, 1, 0x20);
|
||||
arg0->unk30 = arg1(&arg0->unk34);
|
||||
arg0->unk3C = 0;
|
||||
arg0->unk40 = 1;
|
||||
arg0->unk44 = 0;
|
||||
arg0->state = alHeapDBAlloc(0, 0, arg2, 1, 0x20);
|
||||
arg0->lstate = alHeapDBAlloc(0, 0, arg2, 1, 0x20);
|
||||
arg0->dma = arg1(&arg0->dmaState);
|
||||
arg0->lastsam = 0;
|
||||
arg0->first = 1;
|
||||
arg0->memin = 0;
|
||||
}
|
||||
|
||||
typedef struct unk80064F9C {
|
||||
u8 unk00[0x14]; // unknown
|
||||
s32 unk14;
|
||||
f32 unk18;
|
||||
s32 unk1C;
|
||||
f32 unk20;
|
||||
s32 unk24;
|
||||
s32 unk28;
|
||||
s32 unk2C;
|
||||
s32 unk30;
|
||||
} unk80064F9C;
|
||||
|
||||
void alResampleNew(unk80064F9C* arg0, s32 arg1) {
|
||||
alFilterNew(arg0, &alResamplePull, &alResampleParam, 1);
|
||||
arg0->unk14 = alHeapDBAlloc(0, 0, arg1, 1, 0x20);
|
||||
arg0->unk24 = 1;
|
||||
arg0->unk30 = 0;
|
||||
arg0->unk1C = 0;
|
||||
arg0->unk28 = 0;
|
||||
arg0->unk2C = 0;
|
||||
arg0->unk20 = 0.0f;
|
||||
arg0->unk18 = 1.0f;
|
||||
void alResampleNew(ALResampler* r, ALHeap* hp) {
|
||||
alFilterNew(r, &alResamplePull, &alResampleParam, 1);
|
||||
r->state = alHeapDBAlloc(0, 0, hp, 1, 0x20);
|
||||
r->first = 1;
|
||||
r->motion = AL_STOPPED;
|
||||
r->upitch = 0;
|
||||
r->ctrlList = 0;
|
||||
r->ctrlTail = 0;
|
||||
r->delta = 0.0f;
|
||||
r->ratio = 1.0f;
|
||||
}
|
||||
|
||||
typedef struct unk80065024 {
|
||||
u8 unk00[0x14]; // unknown
|
||||
s32 unk14;
|
||||
s32 unk18;
|
||||
s32 unk1C;
|
||||
} unk80065024;
|
||||
|
||||
void alAuxBusNew(unk80065024* arg0, s32 arg1, s32 arg2) {
|
||||
alFilterNew(arg0, &alAuxBusPull, &alAuxBusParam, 6);
|
||||
arg0->unk14 = 0;
|
||||
arg0->unk18 = arg2;
|
||||
arg0->unk1C = arg1;
|
||||
void alAuxBusNew(ALAuxBus* m, void* sources, s32 maxSources) {
|
||||
alFilterNew(m, &alAuxBusPull, &alAuxBusParam, 6);
|
||||
m->sourceCount = 0;
|
||||
m->maxSources = maxSources;
|
||||
m->sources = sources;
|
||||
}
|
||||
|
||||
typedef struct unk80065084 {
|
||||
u8 unk00[0x14]; // unknown
|
||||
s32 unk14;
|
||||
s32 unk18;
|
||||
s32 unk1C;
|
||||
} unk80065084;
|
||||
|
||||
void alMainBusNew(unk80065084* arg0, s32 arg1, s32 arg2) {
|
||||
alFilterNew(arg0, &alMainBusPull, &alMainBusParam, 7);
|
||||
arg0->unk14 = 0;
|
||||
arg0->unk18 = arg2;
|
||||
arg0->unk1C = arg1;
|
||||
void alMainBusNew(ALMainBus* m, void* sources, s32 maxSources) {
|
||||
alFilterNew(m, &alMainBusPull, &alMainBusParam, 7);
|
||||
m->sourceCount = 0;
|
||||
m->maxSources = maxSources;
|
||||
m->sources = sources;
|
||||
}
|
||||
|
||||
typedef struct unk800650E4 {
|
||||
u8 unk00[0x14]; // unknown
|
||||
s32 unk14;
|
||||
s32 unk18;
|
||||
} unk800650E4;
|
||||
|
||||
void alSaveNew(unk800650E4* arg0) {
|
||||
alFilterNew(arg0, &alSavePull, &alSaveParam, 3);
|
||||
arg0->unk14 = 0;
|
||||
arg0->unk18 = 1;
|
||||
void alSaveNew(ALSave* f) {
|
||||
alFilterNew(f, &alSavePull, &alSaveParam, AL_SAVE);
|
||||
f->dramout = 0;
|
||||
f->first = 1;
|
||||
}
|
||||
|
||||
+14
-1
@@ -3,5 +3,18 @@
|
||||
|
||||
#include "types.h"
|
||||
#include "macros.h"
|
||||
#include "audio_internal.h"
|
||||
|
||||
GLOBAL_ASM("asm/non_matchings/unknown_066460/alSynAllocFX.s")
|
||||
#if 1
|
||||
GLOBAL_ASM("asm/non_matchings/unknown_066460/alSynAllocFX.s")
|
||||
#else
|
||||
ALFxRef *alSynAllocFX(ALSynth *s, s16 bus, ALSynConfig *c, ALHeap *hp)
|
||||
{
|
||||
alFxNew(&s->auxBus[bus].fx[0], c, hp);
|
||||
alFxParam(&s->auxBus[bus].fx[0], AL_FILTER_SET_SOURCE,
|
||||
&s->auxBus[bus]);
|
||||
alMainBusParam(s->mainBus, AL_FILTER_ADD_SOURCE,&s->auxBus[bus].fx[0]);
|
||||
|
||||
return (ALFxRef)(&s->auxBus[bus].fx[0]);
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user