From 1b057824f721399b847202b46cfa578f6c5ea305 Mon Sep 17 00:00:00 2001 From: zelda2774 Date: Wed, 25 Aug 2021 23:09:24 +0200 Subject: [PATCH] cleanup --- include/functions.h | 4 +- include/z64audio.h | 157 +++++++++++++++---------------------- src/code/audio_heap.c | 22 +++--- src/code/audio_load.c | 20 ++--- src/code/audio_playback.c | 14 ++-- src/code/audio_seqplayer.c | 16 ++-- src/code/audio_synthesis.c | 37 +++++---- 7 files changed, 120 insertions(+), 150 deletions(-) diff --git a/include/functions.h b/include/functions.h index 8e995f9370..f56e20a6c9 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1949,8 +1949,8 @@ void Audio_AudioTableAsyncLoad(s32 arg0, s32 arg1, s32 arg2, OSMesgQueue* arg3); void Audio_AudioBankAsyncLoad(s32 arg0, s32 arg1, s32 arg2, OSMesgQueue* arg3); u8* func_800E1F38(s32 arg0, u32* arg1); void func_800E1F7C(s32 arg0); -s32 func_800E20D4(s32 playerIdx, s32 seqId, s32 arg2); -s32 func_800E2124(s32 playerIdx, s32 seqId, s32 arg2); +s32 func_800E20D4(s32 playerIndex, s32 seqId, s32 arg2); +s32 func_800E2124(s32 playerIndex, s32 seqId, s32 arg2); void Audio_ProcessLoads(s32 resetStatus); void func_800E301C(void* callback); void Audio_ContextInit(void* heap, u32 heapSize); diff --git a/include/z64audio.h b/include/z64audio.h index 25e17e7bbe..aa0cc9dd3c 100644 --- a/include/z64audio.h +++ b/include/z64audio.h @@ -5,7 +5,7 @@ /** * Structs in this repository have primarily been imported from the SM64 Decompilation. - * Many struct members are wrong; the symbol '?' next to an offset means the member is a guess. + * Some struct members may be wrong; the symbol '?' next to an offset means the member is a guess. */ #define NO_LAYER ((SequenceChannelLayer*)(-1)) @@ -87,7 +87,7 @@ typedef struct { /* 0x00 */ u32 start; /* 0x04 */ u32 end; /* 0x08 */ u32 count; - /*?0x0C */ char unk_0C[0x4]; + /* 0x0C */ char unk_0C[0x4]; /* 0x10 */ s16 state[16]; // only exists if count != 0. 8-byte aligned } AdpcmLoop; // size = 0x30 (or 0x10) @@ -98,16 +98,11 @@ typedef struct { } AdpcmBook; typedef struct { - union{ - struct { - /* 0x00 */ u32 codec : 4; - /* 0x00 */ u32 medium : 2; - /* 0x00 */ u32 unk_bits26 : 1; - /* 0x00 */ u32 unk_bits25 : 1; - /* 0x01 */ u32 size : 24; - }; - u32 bits; - }; + /* 0x00 */ u32 codec : 4; + /* 0x00 */ u32 medium : 2; + /* 0x00 */ u32 unk_bits26 : 1; + /* 0x00 */ u32 unk_bits25 : 1; + /* 0x01 */ u32 size : 24; /* 0x04 */ u8* sampleAddr; /* 0x08 */ AdpcmLoop* loop; /* 0x0C */ AdpcmBook* book; @@ -119,17 +114,16 @@ typedef struct { } AudioBankSound; // size = 0x8 typedef struct { - /*?0x00 */ s16 numSamplesAfterDownsampling; - /*?0x02 */ s16 chunkLen; // never read + /* 0x00 */ s16 numSamplesAfterDownsampling; // never read + /* 0x02 */ s16 chunkLen; // never read /* 0x04 */ s16* toDownsampleLeft; /* 0x08 */ s16* toDownsampleRight; // data pointed to by left and right are adjacent in memory - /*?0x0C */ s32 startPos; // start pos in ring buffer - /*?0x10 */ s16 lengthA; // first length in ring buffer (from startPos, at most until end) - /*?0x12 */ s16 lengthB; // second length in ring buffer (from pos 0) + /* 0x0C */ s32 startPos; // start pos in ring buffer + /* 0x10 */ s16 lengthA; // first length in ring buffer (from startPos, at most until end) + /* 0x12 */ s16 lengthB; // second length in ring buffer (from pos 0) /* 0x14 */ u16 unk_14; /* 0x16 */ u16 unk_16; /* 0x18 */ u16 unk_18; - /* 0x1A */ char unk_1A[2]; } ReverbRingBufferItem; // size = 0x1C typedef struct { @@ -173,7 +167,7 @@ typedef struct { } SynthesisReverb; // size = 0x2C8 typedef struct { - /*?0x00 */ u8 loaded; + /* 0x00 */ u8 loaded; /* 0x01 */ u8 normalRangeLo; /* 0x02 */ u8 normalRangeHi; /* 0x03 */ u8 releaseRate; @@ -186,7 +180,7 @@ typedef struct { typedef struct { /* 0x00 */ u8 releaseRate; /* 0x01 */ u8 pan; - /*?0x02 */ u8 loaded; + /* 0x02 */ u8 loaded; /* 0x04 */ AudioBankSound sound; /* 0x14 */ AdsrEnvelope* envelope; } Drum; // size >= 0x14 @@ -212,38 +206,21 @@ typedef struct { // Also known as a Group, according to debug strings. typedef struct { - union { - s32 playerState; - struct { - /* 0x000 */ u8 enabled : 1; - /*?0x000 */ u8 finished : 1; - /* 0x000 */ u8 muted : 1; - /* 0x000 */ u8 seqDmaInProgress : 1; - /* 0x000 */ u8 bankDmaInProgress : 1; - /*?0x000 */ u8 recalculateVolume : 1; - /* 0x000 */ u8 unk_0b2 : 1; - /* 0x000 */ u8 unk_0b1 : 1; - /* 0x001 */ u8 state; - /* 0x002 */ u8 noteAllocPolicy; - union { - /* 0x003 */ u8 muteBehavior; - struct { - u8 mute_u00 : 1; - u8 mute_u01 : 1; - u8 mute_u02 : 1; - u8 mute_u03 : 1; - u8 mute_u04 : 1; - u8 mute_u05 : 1; - u8 mute_u06 : 1; - u8 mute_u07 : 1; - }; - }; - }; - }; + /* 0x000 */ u8 enabled : 1; + /* 0x000 */ u8 finished : 1; + /* 0x000 */ u8 muted : 1; + /* 0x000 */ u8 seqDmaInProgress : 1; + /* 0x000 */ u8 bankDmaInProgress : 1; + /*?0x000 */ u8 recalculateVolume : 1; + /* 0x000 */ u8 unk_0b2 : 1; + /* 0x000 */ u8 unk_0b1 : 1; + /* 0x001 */ u8 state; + /* 0x002 */ u8 noteAllocPolicy; + /* 0x003 */ u8 muteBehavior; /* 0x004 */ u8 seqId; /* 0x005 */ u8 defaultBank; - /*?0x006 */ u8 loadingBankId; - /*?0x007 */ s8 seqVariationEu; + /* 0x006 */ u8 unk_06[1]; + /* 0x007 */ s8 playerIndex; /* 0x008 */ u16 tempo; // tatums per minute /* 0x00A */ u16 tempoAcc; /* 0x00C */ u16 unk_0C; @@ -251,7 +228,6 @@ typedef struct { /* 0x010 */ u16 delay; /* 0x012 */ u16 fadeTimer; /* 0x014 */ u16 fadeTimerUnkEu; - /* 0x016 */ char unk_16[0x2]; /* 0x018 */ u8* seqData; /* 0x01C */ f32 fadeVolume; /* 0x020 */ f32 fadeVelocity; @@ -261,7 +237,7 @@ typedef struct { /* 0x030 */ f32 appliedFadeVolume; /* 0x034 */ f32 unk_34; /* 0x038 */ struct SequenceChannel* channels[16]; - /*?0x078 */ M64ScriptState scriptState; + /* 0x078 */ M64ScriptState scriptState; /* 0x094 */ u8* shortNoteVelocityTable; /* 0x098 */ u8* shortNoteDurationTable; /* 0x09C */ NotePool notePool; @@ -332,36 +308,31 @@ typedef struct { /* 0x06 */ u16 unk_6; /* 0x08 */ f32 freqScale; /* 0x0C */ f32 velocity; - /* 0x10 */ s16* unk_10; - /* 0x14 */ s16 unk_14[8]; + /* 0x10 */ s16* filter; + /* 0x14 */ s16 filterBuf[8]; } NoteAttributes; // size = 0x24 // Also known as a SubTrack, according to debug strings. // Confusingly, a SubTrack is a container of Tracks. typedef struct SequenceChannel { + /* 0x00 */ u8 enabled : 1; + /* 0x00 */ u8 finished : 1; + /* 0x00 */ u8 stopScript : 1; + /* 0x00 */ u8 stopSomething2 : 1; // sets SequenceChannelLayer.stopSomething + /* 0x00 */ u8 hasInstrument : 1; + /* 0x00 */ u8 stereoHeadsetEffects : 1; + /* 0x00 */ u8 largeNotes : 1; // notes specify duration and velocity + /* 0x00 */ u8 unused : 1; union { - s32 channelState; struct { - /* 0x00 */ u8 enabled : 1; - /* 0x00 */ u8 finished : 1; - /* 0x00 */ u8 stopScript : 1; - /* 0x00 */ u8 stopSomething2 : 1; // sets SequenceChannelLayer.stopSomething - /* 0x00 */ u8 hasInstrument : 1; - /* 0x00 */ u8 stereoHeadsetEffects : 1; - /* 0x00 */ u8 largeNotes : 1; // notes specify duration and velocity - /* 0x00 */ u8 unused : 1; // still unused? - union { - struct { - /* 0x01 */ u8 freqScale : 1; - /* 0x01 */ u8 volume : 1; - /* 0x01 */ u8 pan : 1; - } s; - /* 0x01 */ u8 asByte; - } changes; - /* 0x02 */ u8 noteAllocPolicy; - /* 0x03 */ u8 muteBehavior; - }; - }; + /* 0x01 */ u8 freqScale : 1; + /* 0x01 */ u8 volume : 1; + /* 0x01 */ u8 pan : 1; + } s; + /* 0x01 */ u8 asByte; + } changes; + /* 0x02 */ u8 noteAllocPolicy; + /* 0x03 */ u8 muteBehavior; /* 0x04 */ u8 reverb; // or dry/wet mix /* 0x05 */ u8 notePriority; // 0-3 /* 0x06 */ u8 someOtherPriority; @@ -392,9 +363,9 @@ typedef struct SequenceChannel { /* 0x30 */ s32 pan; /* 0x34 */ f32 appliedVolume; /* 0x38 */ f32 freqScale; - /*?0x3C */ u8 (*dynTable)[][2]; - /* 0x40 */ struct Note* noteUnused; // still unused? - /*?0x44 */ struct SequenceChannelLayer* layerUnused; // still unused? + /* 0x3C */ u8 (*dynTable)[][2]; + /* 0x40 */ struct Note* noteUnused; + /* 0x44 */ struct SequenceChannelLayer* layerUnused; /* 0x48 */ Instrument* instrument; /* 0x4C */ SequencePlayer* seqPlayer; /* 0x50 */ struct SequenceChannelLayer* layers[4]; @@ -402,7 +373,7 @@ typedef struct SequenceChannel { /* 0x7C */ AdsrSettings adsr; /* 0x84 */ NotePool notePool; /* 0xC4 */ s8 soundScriptIO[8]; // bridge between sound script and audio lib - /* 0xCC */ s16* unk_CC; + /* 0xCC */ s16* filter; /* 0xD0 */ ReverbBits reverbBits; } SequenceChannel; // size = 0xD4 @@ -520,33 +491,33 @@ typedef struct { /* 0x00 */ u8 stereoHeadsetEffects : 1; /*?0x00 */ u8 usesHeadsetPanEffects : 1; } s; - /*?0x00 */ u8 asByte; + /* 0x00 */ u8 asByte; // likely does not exist } bitField0; union { struct { - /*?0x01 */ u8 reverbIndex : 3; + /* 0x01 */ u8 reverbIndex : 3; /* 0x01 */ u8 bookOffset : 2; /* 0x01 */ u8 isSyntheticWave : 1; /* 0x01 */ u8 hasTwoAdpcmParts : 1; /* 0x01 */ u8 usesHeadsetPanEffects2 : 1; } s; - /*?0x01 */ u8 asByte; + /* 0x01 */ u8 asByte; // likely does not exist } bitField1; /* 0x02 */ u8 unk_2; - /*?0x03 */ u8 headsetPanRight; - /*?0x04 */ u8 headsetPanLeft; - /*?0x05 */ u8 reverbVol; + /* 0x03 */ u8 headsetPanRight; + /* 0x04 */ u8 headsetPanLeft; + /* 0x05 */ u8 reverbVol; /* 0x06 */ u8 unk_06; /* 0x07 */ u8 unk_07; /* 0x08 */ u16 targetVolLeft; /* 0x0A */ u16 targetVolRight; - /*?0x0C */ u16 resamplingRateFixedPoint; + /* 0x0C */ u16 resamplingRateFixedPoint; /* 0x0E */ u16 unk_0E; /* 0x10 */ union { AudioBankSound* audioBankSound; - s16* samples; - } sound; // not sure if actually a union - /* 0x14 */ s16* unk_14; + s16* samples; // used for synthetic waves + } sound; + /* 0x14 */ s16* filter; /* 0x18 */ char pad_18[0x8]; } NoteSubEu; // size = 0x20 @@ -577,8 +548,8 @@ typedef struct { } ReverbSettings; // size = 0x18 typedef struct { - /*?0x00 */ u32 frequency; - /*?0x04 */ u8 unk_04; + /* 0x00 */ u32 frequency; + /* 0x04 */ u8 unk_04; /* 0x05 */ u8 maxSimultaneousNotes; /* 0x06 */ u8 numSequencePlayers; /* 0x07 */ u8 unk_07[0x2]; @@ -624,7 +595,7 @@ typedef struct { } SoundAllocPool; // size = 0x10 typedef struct { - /* 0x0 */ u8 *ptr; + /* 0x0 */ u8* ptr; /* 0x4 */ u32 size; /* 0x8 */ s16 poolIndex; /* 0xA */ s16 id; // seqId or bankId @@ -1017,7 +988,7 @@ typedef struct { /* 0x04 */ f32 frequency; /* 0x08 */ f32 velocity; /* 0x0C */ char unk_0C[0x4]; - /* 0x10 */ s16* unk_10; + /* 0x10 */ s16* filter; /* 0x14 */ u8 unk_14; /* 0x16 */ u16 unk_16; } Reverb; // size >= 0x18 diff --git a/src/code/audio_heap.c b/src/code/audio_heap.c index b984691290..0b45e0dd01 100644 --- a/src/code/audio_heap.c +++ b/src/code/audio_heap.c @@ -621,46 +621,46 @@ void func_800DF1D8(f32 arg0, f32 arg1, u16* arg2) { } } -void func_800DF5AC(s16* arg0) { +void func_800DF5AC(s16* filter) { s32 i; for (i = 0; i < 8; i++) { - arg0[i] = 0; + filter[i] = 0; } } -void func_800DF5DC(s16* arg0, s32 arg1) { +void func_800DF5DC(s16* filter, s32 arg1) { s32 i; s16* ptr = &D_80130228[8 * arg1]; for (i = 0; i < 8; i++) { - arg0[i] = ptr[i]; + filter[i] = ptr[i]; } } -void func_800DF630(s16* arg0, s32 arg1) { +void func_800DF630(s16* filter, s32 arg1) { s32 i; s16* ptr = &D_80130328[8 * (arg1 - 1)]; for (i = 0; i < 8; i++) { - arg0[i] = ptr[i]; + filter[i] = ptr[i]; } } -void func_800DF688(s16* arg0, s32 arg1, s32 arg2) { +void func_800DF688(s16* filter, s32 arg1, s32 arg2) { s32 i; if (arg1 == 0 && arg2 == 0) { - func_800DF5DC(arg0, 0); + func_800DF5DC(filter, 0); } else if (arg2 == 0) { - func_800DF5DC(arg0, arg1); + func_800DF5DC(filter, arg1); } else if (arg1 == 0) { - func_800DF630(arg0, arg2); + func_800DF630(filter, arg2); } else { s16* ptr1 = &D_80130228[8 * arg1]; s16* ptr2 = &D_80130328[8 * (arg2 - 1)]; for (i = 0; i < 8; i++) { - arg0[i] = (ptr1[i] + ptr2[i]) / 2; + filter[i] = (ptr1[i] + ptr2[i]) / 2; } } } diff --git a/src/code/audio_load.c b/src/code/audio_load.c index 4ed97e8ca0..95ea73a423 100644 --- a/src/code/audio_load.c +++ b/src/code/audio_load.c @@ -6,7 +6,7 @@ typedef enum { LOAD_STATUS_WAITING, LOAD_STATUS_START, LOAD_STATUS_LOADING, LOAD #define RELOC(v, base) (reloc = (void*)((u32)v + (u32)base)) /* forward declarations */ -s32 func_800E217C(s32 playerIdx, s32, s32); +s32 func_800E217C(s32 playerIndex, s32, s32); unk_ldr* func_800E2454(u32 bankId); AudioBankSample* Audio_GetBankSample(s32 bankId, s32 sfxId); void Audio_ProcessAsyncLoads(s32 arg0); @@ -381,27 +381,27 @@ void func_800E202C(s32 arg0) { Audio_DiscardBank(arg0); } -s32 func_800E20D4(s32 playerIdx, s32 seqId, s32 arg2) { +s32 func_800E20D4(s32 playerIndex, s32 seqId, s32 arg2) { if (gAudioContext.resetTimer != 0) { return 0; } else { - gAudioContext.seqPlayers[playerIdx].unk_DC = 0; - return func_800E217C(playerIdx, seqId, arg2); + gAudioContext.seqPlayers[playerIndex].unk_DC = 0; + return func_800E217C(playerIndex, seqId, arg2); } } -s32 func_800E2124(s32 playerIdx, s32 seqId, s32 arg2) { +s32 func_800E2124(s32 playerIndex, s32 seqId, s32 arg2) { if (gAudioContext.resetTimer != 0) { return 0; } - gAudioContext.seqPlayers[playerIdx].unk_DC = arg2; - return func_800E217C(playerIdx, seqId, 0); + gAudioContext.seqPlayers[playerIndex].unk_DC = arg2; + return func_800E217C(playerIndex, seqId, 0); } // InitSeqPlayer -s32 func_800E217C(s32 playerIdx, s32 seqId, s32 arg2) { - SequencePlayer* seqPlayer = &gAudioContext.seqPlayers[playerIdx]; +s32 func_800E217C(s32 playerIndex, s32 seqId, s32 arg2) { + SequencePlayer* seqPlayer = &gAudioContext.seqPlayers[playerIndex]; u8* seqData; s32 phi_s0; s32 phi_s1; @@ -437,7 +437,7 @@ s32 func_800E217C(s32 playerIdx, s32 seqId, s32 arg2) { seqPlayer->scriptState.depth = 0; seqPlayer->delay = 0; seqPlayer->finished = 0; - seqPlayer->seqVariationEu = playerIdx; + seqPlayer->playerIndex = playerIndex; Audio_ProcessSequence(seqPlayer); } diff --git a/src/code/audio_playback.c b/src/code/audio_playback.c index 05bb230c4d..17580145b1 100644 --- a/src/code/audio_playback.c +++ b/src/code/audio_playback.c @@ -95,7 +95,7 @@ void Audio_NoteSetVelPanReverb(Note* note, NoteSubEu* sub, Reverb* reverb) { sub->targetVolRight = (s32)((vel * volRight) * 4095.999f); sub->unk_2 = reverb->unk_1; - sub->unk_14 = reverb->unk_10; + sub->filter = reverb->filter; sub->unk_07 = reverb->unk_14; sub->unk_0E = reverb->unk_16; sub->reverbVol = reverbVol; @@ -256,7 +256,7 @@ void Audio_ProcessNotes(void) { reverb.vol = attributes->reverb; reverb.reverbBits = attributes->reverbBits; reverb.unk_1 = attributes->unk_1; - reverb.unk_10 = attributes->unk_10; + reverb.filter = attributes->filter; reverb.unk_14 = attributes->unk_4; reverb.unk_16 = attributes->unk_6; bookOffset = noteSubEu->bitField1.s.bookOffset; @@ -274,7 +274,7 @@ void Audio_ProcessNotes(void) { } reverb.vol = channel->reverb; reverb.unk_1 = channel->unk_0C; - reverb.unk_10 = channel->unk_CC; + reverb.filter = channel->filter; reverb.unk_14 = channel->unk_0F; reverb.unk_16 = channel->unk_20; bookOffset = channel->bookOffset & 0x7; @@ -471,13 +471,13 @@ void Audio_SeqChanLayerDecayRelease(SequenceChannelLayer* seqLayer, s32 target) chan = seqLayer->seqChannel; attributes->reverb = chan->reverb; attributes->unk_1 = chan->unk_0C; - attributes->unk_10 = chan->unk_CC; + attributes->filter = chan->filter; - if (attributes->unk_10 != NULL) { + if (attributes->filter != NULL) { for (i = 0; i < 8; i++) { - attributes->unk_14[i] = attributes->unk_10[i]; + attributes->filterBuf[i] = attributes->filter[i]; } - attributes->unk_10 = attributes->unk_14; + attributes->filter = attributes->filterBuf; } attributes->unk_6 = chan->unk_20; diff --git a/src/code/audio_seqplayer.c b/src/code/audio_seqplayer.c index 80b9b2318b..ce96ce467c 100644 --- a/src/code/audio_seqplayer.c +++ b/src/code/audio_seqplayer.c @@ -144,7 +144,7 @@ void Audio_SequenceChannelInit(SequenceChannel* seqChannel) { seqChannel->vibratoRateChangeDelay = 0; seqChannel->vibratoExtentChangeDelay = 0; seqChannel->vibratoDelay = 0; - seqChannel->unk_CC = NULL; + seqChannel->filter = NULL; seqChannel->unk_20 = 0; seqChannel->unk_0F = 0; seqChannel->volume = 1.0f; @@ -1275,7 +1275,7 @@ void Audio_SequenceChannelProcessScript(SequenceChannel* channel) { channel->vibratoRateTarget = 0; channel->vibratoRateStart = 0; channel->vibratoRateChangeDelay = 0; - channel->unk_CC = NULL; + channel->filter = NULL; channel->unk_0C = 0; channel->adsr.sustain = 0; channel->velocityRandomVariance = 0; @@ -1295,18 +1295,18 @@ void Audio_SequenceChannelProcessScript(SequenceChannel* channel) { case 0xB0: offset = (u16)parameters[0]; data = seqPlayer->seqData + offset; - channel->unk_CC = (s16*)data; + channel->filter = (s16*)data; break; case 0xB1: - channel->unk_CC = NULL; + channel->filter = NULL; break; case 0xB3: command = parameters[0]; - if (channel->unk_CC != NULL) { + if (channel->filter != NULL) { lowBits = (command >> 4) & 0xF; command &= 0xF; - func_800DF688(channel->unk_CC, lowBits, command); + func_800DF688(channel->filter, lowBits, command); } break; case 0xB2: @@ -1676,11 +1676,11 @@ void Audio_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) { case 0xC4: command = Audio_M64ReadU8(seqScript); if (command == 0xFF) { - command = seqPlayer->seqVariationEu; + command = seqPlayer->playerIndex; } commandLow = Audio_M64ReadU8(seqScript); func_800E20D4(command, commandLow, 0); - if (command == (u8)seqPlayer->seqVariationEu) { + if (command == (u8)seqPlayer->playerIndex) { return; } break; diff --git a/src/code/audio_synthesis.c b/src/code/audio_synthesis.c index d098557cbd..219c095337 100644 --- a/src/code/audio_synthesis.c +++ b/src/code/audio_synthesis.c @@ -34,7 +34,7 @@ extern u32 D_801304A8; extern u32 D_801304AC; extern u8 D_801304C0[]; -void AudioSynth_InitNextRingBuf(s32 chunkSize, s32 bufIndex, s32 reverbIndex) { +void AudioSynth_InitNextRingBuf(s32 chunkLen, s32 bufIndex, s32 reverbIndex) { ReverbRingBufferItem* bufItem; s32 pad[3]; SynthesisReverb* reverb = &gAudioContext.synthesisReverbs[reverbIndex]; @@ -64,7 +64,7 @@ void AudioSynth_InitNextRingBuf(s32 chunkSize, s32 bufIndex, s32 reverbIndex) { } bufItem = &reverb->items[reverb->curFrame][bufIndex]; - sampleCnt = chunkSize / reverb->downsampleRate; + sampleCnt = chunkLen / reverb->downsampleRate; extraSamples = (sampleCnt + reverb->nextRingBufPos) - reverb->bufSizePerChan; temp_a0_2 = reverb->nextRingBufPos; if (extraSamples < 0) { @@ -80,7 +80,7 @@ void AudioSynth_InitNextRingBuf(s32 chunkSize, s32 bufIndex, s32 reverbIndex) { } bufItem->numSamplesAfterDownsampling = sampleCnt; - bufItem->chunkLen = chunkSize; + bufItem->chunkLen = chunkLen; if (reverb->unk_14 != 0) { temp_a0_4 = reverb->unk_14 + temp_a0_2; @@ -88,7 +88,7 @@ void AudioSynth_InitNextRingBuf(s32 chunkSize, s32 bufIndex, s32 reverbIndex) { temp_a0_4 -= reverb->bufSizePerChan; } bufItem = &reverb->items2[reverb->curFrame][bufIndex]; - sampleCnt = chunkSize / reverb->downsampleRate; + sampleCnt = chunkLen / reverb->downsampleRate; extraSamples = (temp_a0_4 + sampleCnt) - reverb->bufSizePerChan; if (extraSamples < 0) { bufItem->lengthA = sampleCnt * 2; @@ -100,7 +100,7 @@ void AudioSynth_InitNextRingBuf(s32 chunkSize, s32 bufIndex, s32 reverbIndex) { bufItem->startPos = temp_a0_4; } bufItem->numSamplesAfterDownsampling = sampleCnt; - bufItem->chunkLen = chunkSize; + bufItem->chunkLen = chunkLen; } } @@ -125,7 +125,7 @@ void func_800DB03C(s32 arg0) { } Acmd* AudioSynth_Update(Acmd* cmdStart, s32* cmdCnt, s16* aiStart, s32 aiBufLen) { - s32 chunkSize; + s32 chunkLen; s16* aiBufP; Acmd* cmdP; s32 i; @@ -142,25 +142,25 @@ Acmd* AudioSynth_Update(Acmd* cmdStart, s32* cmdCnt, s16* aiStart, s32 aiBufLen) gAudioContext.curLoadedBook = NULL; for (i = gAudioContext.audioBufferParameters.updatesPerFrame; i > 0; i--) { if (i == 1) { - chunkSize = aiBufLen; + chunkLen = aiBufLen; } else if ((aiBufLen / i) >= gAudioContext.audioBufferParameters.samplesPerUpdateMax) { - chunkSize = gAudioContext.audioBufferParameters.samplesPerUpdateMax; + chunkLen = gAudioContext.audioBufferParameters.samplesPerUpdateMax; } else if (gAudioContext.audioBufferParameters.samplesPerUpdateMin >= (aiBufLen / i)) { - chunkSize = gAudioContext.audioBufferParameters.samplesPerUpdateMin; + chunkLen = gAudioContext.audioBufferParameters.samplesPerUpdateMin; } else { - chunkSize = gAudioContext.audioBufferParameters.samplesPerUpdate; + chunkLen = gAudioContext.audioBufferParameters.samplesPerUpdate; } for (j = 0; j < gAudioContext.numSynthesisReverbs; j++) { if (gAudioContext.synthesisReverbs[j].useReverb) { - AudioSynth_InitNextRingBuf(chunkSize, gAudioContext.audioBufferParameters.updatesPerFrame - i, j); + AudioSynth_InitNextRingBuf(chunkLen, gAudioContext.audioBufferParameters.updatesPerFrame - i, j); } } - cmdP = AudioSynth_DoOneAudioUpdate(aiBufP, chunkSize, cmdP, + cmdP = AudioSynth_DoOneAudioUpdate(aiBufP, chunkLen, cmdP, gAudioContext.audioBufferParameters.updatesPerFrame - i); - aiBufLen -= chunkSize; - aiBufP += chunkSize * 2; + aiBufLen -= chunkLen; + aiBufP += chunkLen * 2; } for (j = 0; j < gAudioContext.numSynthesisReverbs; j++) { @@ -702,7 +702,7 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS u32 nSamplesToLoad; u16 unk7; u16 unkE; - s16* thing4; + s16* filter; s32 bookOffset; s32 finished; s32 aligned; @@ -745,7 +745,6 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS if (noteSubEu->bitField1.s.isSyntheticWave) { cmd = AudioSynth_LoadWaveSamples(cmd, noteSubEu, synthState, nSamplesToLoad); - // loopInfo = loopInfo; noteSamplesDmemAddrBeforeResampling = DMEM_UNCOMPRESSED_NOTE + (synthState->samplePosInt * 2); synthState->samplePosInt += nSamplesToLoad; } else { @@ -1014,9 +1013,9 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS AudioSynth_HiLoGain(cmd++, phi_a1_2, DMEM_TEMP, 0, (aiBufLen * 2) + 0x20); } - thing4 = noteSubEu->unk_14; - if (thing4 != 0) { - AudioSynth_SetFilterCount(cmd++, aiBufLen * 2, thing4); + filter = noteSubEu->filter; + if (filter != 0) { + AudioSynth_SetFilterCount(cmd++, aiBufLen * 2, filter); AudioSynth_SetFilter(cmd++, flags, DMEM_TEMP, synthState->synthesisBuffers->mixEnvelopeState); }