diff --git a/include/functions.h b/include/functions.h index 136376368f..03ce9712b1 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3375,7 +3375,7 @@ s32 osFlashReadArray(OSIoMesg* mb, s32 priority, u32 pageNum, void* dramAddr, u3 // void func_8018B4F8(void); // void func_8018B520(void); // void func_8018B578(void); -// void func_8018B5D0(void); +void* AudioHeap_AllocDmaMemory(AudioAllocPool* pool, u32 size); // void func_8018B608(void); // void func_8018B640(void); // void func_8018B69C(void); @@ -3421,7 +3421,7 @@ s32 osFlashReadArray(OSIoMesg* mb, s32 priority, u32 pageNum, void* dramAddr, u3 // void func_8018EB60(void); // void func_8018EC4C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_8018EF88(void); -// void func_8018F220(void); +s32 AudioLoad_IsFontLoadComplete(s32 bankId); // void func_8018F298(void); // void func_8018F310(void); // void func_8018F388(void); @@ -3531,37 +3531,23 @@ void Audio_WritebackDCache(void* buf, size_t size); // void func_80194790(void); // void func_80194840(void); // void func_801948B0(void); -// void func_80194930(void); -// void func_80194DB0(void); -// void func_80194E60(void); -// void func_80194F20(void); -// void func_80194F84(void); -// void func_801954CC(void); -// void func_80195508(void); -// void func_801955DC(void); -// void func_801956C0(void); -// void func_801957B4(void); -// void func_801958F8(void); -// void func_80195C40(void); -// void func_80195C60(void); -// void func_80195C80(void); -// void func_80195D84(void); -// void func_80195DDC(void); -// void func_80195DEC(void); -// void func_80195E3C(void); -// void func_80195EE0(void); -// void func_80196040(void); -// void func_8019617C(void); -// void func_801961BC(void); -// void func_801961E8(void); -// void func_80196268(void); -// void func_801963E8(void); -// void func_8019641C(void); -// void func_80196448(void); -// void func_80196494(void); -// void func_801964F8(void); -// void func_801965F0(void); -// void func_801968C4(void); +void AudioPlayback_NoteDisable(Note* note); +void AudioPlayback_ProcessNotes(void); +SoundFontSound* AudioPlayback_InstrumentGetSound(Instrument* instrument, s32 semitone); +Instrument* AudioPlayback_GetInstrumentInner(s32 fontId, s32 instId); +Drum* AudioPlayback_GetDrum(s32 fontId, s32 drumId); +SoundFontSound* AudioPlayback_GetSfx(s32 fontId, s32 sfxId); +s32 AudioPlayback_SetFontInstrument(s32 instrumentType, s32 fontId, s32 index, void* value); +void AudioPlayback_SeqLayerNoteDecay(SequenceLayer* layer); +void AudioPlayback_SeqLayerNoteRelease(SequenceLayer* layer); +void AudioPlayback_InitSyntheticWave(Note* note, SequenceLayer* layer); +void AudioPlayback_InitNoteLists(NotePool* pool); +void AudioPlayback_InitNoteFreeList(void); +void AudioPlayback_NotePoolClear(NotePool* pool); +void AudioPlayback_NotePoolFill(NotePool* pool, s32 count); +void AudioPlayback_AudioListRemove(AudioListItem* item); +Note* AudioPlayback_AllocNote(SequenceLayer* layer); +void AudioPlayback_NoteInitAll(void); void AudioEffects_SequencePlayerProcessSound(SequencePlayer* seqPlayer); void AudioEffects_NoteVibratoUpdate(Note* note); void AudioEffects_NoteVibratoInit(Note* note); @@ -3574,14 +3560,14 @@ f32 AudioEffects_AdsrUpdate(AdsrState* adsr); // void func_80197880(void); // void func_801979D8(void); // void func_80197A54(void); -// void func_80197AA4(void); +void AudioSeq_SequenceChannelDisable(SequenceChannel* channel); // void func_80197B14(void); // void func_80197C0C(void); // void func_80197C8C(void); // void func_80197D24(void); void AudioSeq_SequencePlayerDisable(SequencePlayer* seqPlayer); -// void func_80197E08(void); -// void func_80197E48(void); +void AudioSeq_AudioListPushBack(AudioListItem* list, AudioListItem* item); +void* AudioSeq_AudioListPopBack(AudioListItem* list); // void func_80197E88(void); // void func_80197F28(void); // void func_80197F3C(void); diff --git a/include/variables.h b/include/variables.h index 98ff888dc8..b9b66c3caa 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1652,16 +1652,14 @@ extern f32 gBendPitchOneOctaveFrequencies[256]; // extern UNK_TYPE1 D_801D57B4; // extern UNK_TYPE1 D_801D57C4; // extern UNK_TYPE1 D_801D57D4; -// extern UNK_TYPE4 D_801D57E4; -// extern UNK_TYPE4 D_801D5804; -// extern UNK_TYPE2 D_801D5824; -// extern UNK_TYPE2 D_801D58A2; -// extern UNK_TYPE1 D_801D58AA; -// extern UNK_TYPE1 D_801D5928; -// extern UNK_TYPE1 D_801D5B24; -// extern UNK_TYPE1 D_801D5B28; -// extern UNK_TYPE1 D_801D5D24; -// extern UNK_TYPE1 D_801D5D28; +extern NoteSubEu gZeroNoteSub; +extern NoteSubEu gDefaultNoteSub; +extern u16 gHeadsetPanQuantization[]; +extern u16 gHeadsetPanQuantization[]; +extern s16 D_801D58A8[]; +extern f32 gHeadsetPanVolume[]; +extern f32 gStereoPanVolume[]; +extern f32 gDefaultPanVolume[]; // extern UNK_TYPE1 D_801D5F24; // extern UNK_TYPE4 D_801D5FB4; // extern UNK_TYPE4 D_801D5FB8; diff --git a/include/z64audio.h b/include/z64audio.h index 06f70b81b5..9baa9911e9 100644 --- a/include/z64audio.h +++ b/include/z64audio.h @@ -20,6 +20,14 @@ #define AIBUF_LEN 0x580 +typedef enum { + /* 0 */ AUDIO_MODE_STEREO, + /* 1 */ AUDIO_MODE_HEADSET, + /* 2 */ AUDIO_MODE_UNK, + /* 3 */ AUDIO_MODE_MONO, + /* 4 */ AUDIO_MODE_SURROUND, +} AudioSoundMode; + typedef enum { /* 0 */ ADSR_STATE_DISABLED, /* 1 */ ADSR_STATE_INITIAL, diff --git a/src/code/audio/audio_heap.c b/src/code/audio/audio_heap.c index 7c43ef0f1c..b3d83c1f98 100644 --- a/src/code/audio/audio_heap.c +++ b/src/code/audio/audio_heap.c @@ -18,7 +18,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B578.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B5D0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_AllocDmaMemory.s") #pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B608.s") diff --git a/src/code/audio/audio_load.c b/src/code/audio/audio_load.c index 15e54b3c5d..497f9d47a9 100644 --- a/src/code/audio/audio_load.c +++ b/src/code/audio/audio_load.c @@ -8,7 +8,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018EF88.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F220.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/AudioLoad_IsFontLoadComplete.s") #pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F298.s") diff --git a/src/code/audio/audio_playback.c b/src/code/audio/audio_playback.c index ec8dd86b89..78161943c6 100644 --- a/src/code/audio/audio_playback.c +++ b/src/code/audio/audio_playback.c @@ -1,63 +1,988 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_80194930.s") +void AudioPlayback_NoteSetResamplingRate(NoteSubEu* noteSubEu, f32 resamplingRateInput); +void AudioPlayback_AudioListPushFront(AudioListItem* list, AudioListItem* item); +void AudioPlayback_NoteInitForLayer(Note* note, SequenceLayer* layer); -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_80194DB0.s") +void AudioPlayback_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* attrs) { + f32 volRight, volLeft; + s32 smallPanIndex; + u64 pad; + u8 strongLeft; + u8 strongRight; + f32 vel; + u8 pan; + u8 reverbVol; + StereoData stereoData; + s32 stereoHeadsetEffects = note->playbackState.stereoHeadsetEffects; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_80194E60.s") + vel = attrs->velocity; + pan = attrs->pan; + reverbVol = attrs->reverbVol; + stereoData = attrs->stereo.s; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_80194F20.s") + sub->bitField0 = note->noteSubEu.bitField0; + sub->bitField1 = note->noteSubEu.bitField1; + sub->sound.samples = note->noteSubEu.sound.samples; + sub->unk_06 = note->noteSubEu.unk_06; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_80194F84.s") + AudioPlayback_NoteSetResamplingRate(sub, attrs->frequency); -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_801954CC.s") + pan &= 0x7F; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_80195508.s") + sub->bitField0.stereoStrongRight = false; + sub->bitField0.stereoStrongLeft = false; + sub->bitField0.stereoHeadsetEffects = stereoData.stereoHeadsetEffects; + sub->bitField0.usesHeadsetPanEffects = stereoData.usesHeadsetPanEffects; + if (stereoHeadsetEffects && gAudioContext.soundMode == AUDIO_MODE_HEADSET) { + smallPanIndex = pan >> 1; + if (smallPanIndex > 0x3F) { + smallPanIndex = 0x3F; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_801955DC.s") + sub->headsetPanLeft = gHeadsetPanQuantization[smallPanIndex]; + sub->headsetPanRight = gHeadsetPanQuantization[0x3F - smallPanIndex]; + sub->bitField1.usesHeadsetPanEffects2 = true; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_801956C0.s") + volLeft = gHeadsetPanVolume[pan]; + volRight = gHeadsetPanVolume[0x7F - pan]; + } else if (stereoHeadsetEffects && gAudioContext.soundMode == AUDIO_MODE_STEREO) { + strongLeft = strongRight = false; + sub->headsetPanRight = 0; + sub->headsetPanLeft = 0; + sub->bitField1.usesHeadsetPanEffects2 = false; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_801957B4.s") + volLeft = gStereoPanVolume[pan]; + volRight = gStereoPanVolume[0x7F - pan]; + if (pan < 0x20) { + strongLeft = true; + } else if (pan > 0x60) { + strongRight = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_801958F8.s") + sub->bitField0.stereoStrongRight = strongRight; + sub->bitField0.stereoStrongLeft = strongLeft; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_80195C40.s") + switch (stereoData.bit2) { + case 0: + break; + case 1: + sub->bitField0.stereoStrongRight = stereoData.strongRight; + sub->bitField0.stereoStrongLeft = stereoData.strongLeft; + break; + case 2: + sub->bitField0.stereoStrongRight = stereoData.strongRight | strongRight; + sub->bitField0.stereoStrongLeft = stereoData.strongLeft | strongLeft; + break; + case 3: + sub->bitField0.stereoStrongRight = stereoData.strongRight ^ strongRight; + sub->bitField0.stereoStrongLeft = stereoData.strongLeft ^ strongLeft; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_80195C60.s") + } else if (gAudioContext.soundMode == AUDIO_MODE_MONO) { + sub->bitField0.stereoHeadsetEffects = false; + sub->bitField0.usesHeadsetPanEffects = false; + volLeft = 0.707f; // approx 1/sqrt(2) + volRight = 0.707f; + } else { + sub->bitField0.stereoStrongRight = stereoData.strongRight; + sub->bitField0.stereoStrongLeft = stereoData.strongLeft; + volLeft = gDefaultPanVolume[pan]; + volRight = gDefaultPanVolume[0x7F - pan]; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_80195C80.s") + vel = 0.0f > vel ? 0.0f : vel; + vel = 1.0f < vel ? 1.0f : vel; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_80195D84.s") + sub->targetVolLeft = (s32)((vel * volLeft) * (0x1000 - 0.001f)); + sub->targetVolRight = (s32)((vel * volRight) * (0x1000 - 0.001f)); -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_80195DDC.s") + sub->unk_2 = attrs->unk_1; + sub->filter = attrs->filter; + sub->unk_07 = attrs->unk_14; + sub->unk_0E = attrs->unk_16; + sub->reverbVol = reverbVol; + sub->unk_19 = attrs->unk_3; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_80195DEC.s") +void AudioPlayback_NoteSetResamplingRate(NoteSubEu* noteSubEu, f32 resamplingRateInput) { + f32 resamplingRate = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_80195E3C.s") + if (resamplingRateInput < 2.0f) { + noteSubEu->bitField1.hasTwoParts = false; + resamplingRate = CLAMP_MAX(resamplingRateInput, 1.99998f); -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_80195EE0.s") + } else { + noteSubEu->bitField1.hasTwoParts = true; + if (resamplingRateInput > 3.99996f) { + resamplingRate = 1.99998f; + } else { + resamplingRate = resamplingRateInput * 0.5f; + } + } + noteSubEu->resamplingRateFixedPoint = (s32)(resamplingRate * 32768.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_80196040.s") +void AudioPlayback_NoteInit(Note* note) { + if (note->playbackState.parentLayer->adsr.releaseRate == 0) { + AudioEffects_AdsrInit(¬e->playbackState.adsr, note->playbackState.parentLayer->channel->adsr.envelope, + ¬e->playbackState.adsrVolScaleUnused); + } else { + AudioEffects_AdsrInit(¬e->playbackState.adsr, note->playbackState.parentLayer->adsr.envelope, + ¬e->playbackState.adsrVolScaleUnused); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_8019617C.s") + note->playbackState.unk_04 = 0; + note->playbackState.adsr.action.s.state = ADSR_STATE_INITIAL; + note->noteSubEu = gDefaultNoteSub; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_801961BC.s") +void AudioPlayback_NoteDisable(Note* note) { + if (note->noteSubEu.bitField0.needsInit == true) { + note->noteSubEu.bitField0.needsInit = false; + } + note->playbackState.priority = 0; + note->noteSubEu.bitField0.enabled = false; + note->playbackState.unk_04 = 0; + note->noteSubEu.bitField0.finished = false; + note->playbackState.parentLayer = NO_LAYER; + note->playbackState.prevParentLayer = NO_LAYER; + note->playbackState.adsr.action.s.state = ADSR_STATE_DISABLED; + note->playbackState.adsr.current = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_801961E8.s") +void AudioPlayback_ProcessNotes(void) { + s32 pad; + s32 unk_04; + NoteAttributes* attrs; + NoteSubEu* noteSubEu2; + NoteSubEu* noteSubEu; + Note* note; + NotePlaybackState* playbackState; + NoteSubAttributes subAttrs; + u8 bookOffset; + f32 scale; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_80196268.s") + for (i = 0; i < gAudioContext.numNotes; i++) { + note = &gAudioContext.notes[i]; + noteSubEu2 = &gAudioContext.noteSubsEu[gAudioContext.noteSubEuOffset + i]; + playbackState = ¬e->playbackState; + if (playbackState->parentLayer != NO_LAYER) { + if ((u32)playbackState->parentLayer < 0x7FFFFFFF) { + continue; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_801963E8.s") + if (note != playbackState->parentLayer->note && playbackState->unk_04 == 0) { + playbackState->adsr.action.s.release = true; + playbackState->adsr.fadeOutVel = gAudioContext.audioBufferParameters.updatesPerFrameInv; + playbackState->priority = 1; + playbackState->unk_04 = 2; + goto out; + } else if (!playbackState->parentLayer->enabled && playbackState->unk_04 == 0 && + playbackState->priority >= 1) { + // do nothing + } else if (playbackState->parentLayer->channel->seqPlayer == NULL) { + AudioSeq_SequenceChannelDisable(playbackState->parentLayer->channel); + playbackState->priority = 1; + playbackState->unk_04 = 1; + continue; + } else if (playbackState->parentLayer->channel->seqPlayer->muted && + (playbackState->parentLayer->channel->muteBehavior & 0x40)) { + // do nothing + } else { + goto out; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_8019641C.s") + AudioPlayback_SeqLayerNoteRelease(playbackState->parentLayer); + AudioPlayback_AudioListRemove(¬e->listItem); + AudioPlayback_AudioListPushFront(¬e->listItem.pool->decaying, ¬e->listItem); + playbackState->priority = 1; + playbackState->unk_04 = 2; + } else if (playbackState->unk_04 == 0 && playbackState->priority >= 1) { + continue; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_80196448.s") + out: + if (playbackState->priority != 0) { + if (1) {} + noteSubEu = ¬e->noteSubEu; + if (playbackState->unk_04 >= 1 || noteSubEu->bitField0.finished) { + if (playbackState->adsr.action.s.state == ADSR_STATE_DISABLED || noteSubEu->bitField0.finished) { + if (playbackState->wantedParentLayer != NO_LAYER) { + AudioPlayback_NoteDisable(note); + if (playbackState->wantedParentLayer->channel != NULL) { + AudioPlayback_NoteInitForLayer(note, playbackState->wantedParentLayer); + AudioEffects_NoteVibratoInit(note); + AudioEffects_NotePortamentoInit(note); + AudioPlayback_AudioListRemove(¬e->listItem); + AudioSeq_AudioListPushBack(¬e->listItem.pool->active, ¬e->listItem); + playbackState->wantedParentLayer = NO_LAYER; + // don't skip + } else { + AudioPlayback_NoteDisable(note); + AudioPlayback_AudioListRemove(¬e->listItem); + AudioSeq_AudioListPushBack(¬e->listItem.pool->disabled, ¬e->listItem); + playbackState->wantedParentLayer = NO_LAYER; + goto skip; + } + } else { + if (playbackState->parentLayer != NO_LAYER) { + playbackState->parentLayer->bit1 = true; + } + AudioPlayback_NoteDisable(note); + AudioPlayback_AudioListRemove(¬e->listItem); + AudioSeq_AudioListPushBack(¬e->listItem.pool->disabled, ¬e->listItem); + continue; + } + } + } else if (playbackState->adsr.action.s.state == ADSR_STATE_DISABLED) { + if (playbackState->parentLayer != NO_LAYER) { + playbackState->parentLayer->bit1 = true; + } + AudioPlayback_NoteDisable(note); + AudioPlayback_AudioListRemove(¬e->listItem); + AudioSeq_AudioListPushBack(¬e->listItem.pool->disabled, ¬e->listItem); + continue; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_80196494.s") + scale = AudioEffects_AdsrUpdate(&playbackState->adsr); + AudioEffects_NoteVibratoUpdate(note); + unk_04 = playbackState->unk_04; + attrs = &playbackState->attributes; + if (unk_04 == 1 || unk_04 == 2) { + subAttrs.frequency = attrs->freqScale; + subAttrs.velocity = attrs->velocity; + subAttrs.pan = attrs->pan; + subAttrs.reverbVol = attrs->reverb; + subAttrs.stereo = attrs->stereo; + subAttrs.unk_1 = attrs->unk_1; + subAttrs.filter = attrs->filter; + subAttrs.unk_14 = attrs->unk_4; + subAttrs.unk_16 = attrs->unk_6; + subAttrs.unk_3 = attrs->unk_3; + bookOffset = noteSubEu->bitField1.bookOffset; + } else { + SequenceLayer* layer = playbackState->parentLayer; + SequenceChannel* channel = playbackState->parentLayer->channel; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_801964F8.s") + subAttrs.frequency = layer->noteFreqScale; + subAttrs.velocity = layer->noteVelocity; + subAttrs.pan = layer->notePan; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_801965F0.s") + if (layer->unk_08 == 0x80) { + subAttrs.unk_3 = channel->unk_10; + } else { + subAttrs.unk_3 = layer->unk_08; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/func_801968C4.s") + if (layer->stereo.s.bit2 == 0) { + subAttrs.stereo = channel->stereo; + } else { + subAttrs.stereo = layer->stereo; + } + + if (layer->unk_0A.s.bit_2 == 1) { + subAttrs.reverbVol = channel->reverb; + } else { + subAttrs.reverbVol = layer->unk_09; + } + + if (layer->unk_0A.s.bit_9 == 1) { + subAttrs.unk_1 = channel->unk_0C; + } else { + subAttrs.unk_1 = 0; + if (1) {} + } + + subAttrs.filter = channel->filter; + subAttrs.unk_14 = channel->unk_0F; + subAttrs.unk_16 = channel->unk_20; + bookOffset = channel->bookOffset & 0x7; + + if (channel->seqPlayer->muted && (channel->muteBehavior & 8)) { + subAttrs.frequency = 0.0f; + subAttrs.velocity = 0.0f; + } + } + + subAttrs.frequency *= playbackState->vibratoFreqScale * playbackState->portamentoFreqScale; + subAttrs.frequency *= gAudioContext.audioBufferParameters.resampleRate; + subAttrs.velocity *= scale; + AudioPlayback_InitNoteSub(note, noteSubEu2, &subAttrs); + noteSubEu->bitField1.bookOffset = bookOffset; + skip:; + } + } +} + +SoundFontSound* AudioPlayback_InstrumentGetSound(Instrument* instrument, s32 semitone) { + SoundFontSound* sound; + + if (semitone < instrument->normalRangeLo) { + sound = &instrument->lowNotesSound; + } else if (semitone <= instrument->normalRangeHi) { + sound = &instrument->normalNotesSound; + } else { + sound = &instrument->highNotesSound; + } + return sound; +} + +Instrument* AudioPlayback_GetInstrumentInner(s32 fontId, s32 instId) { + Instrument* inst; + + if (fontId == 0xFF) { + return NULL; + } + + if (!AudioLoad_IsFontLoadComplete(fontId)) { + gAudioContext.audioErrorFlags = fontId + 0x10000000; + return NULL; + } + + if (instId >= gAudioContext.soundFonts[fontId].numInstruments) { + gAudioContext.audioErrorFlags = ((fontId << 8) + instId) + 0x3000000; + return NULL; + } + + inst = gAudioContext.soundFonts[fontId].instruments[instId]; + if (inst == NULL) { + gAudioContext.audioErrorFlags = ((fontId << 8) + instId) + 0x1000000; + return inst; + } + + return inst; +} + +Drum* AudioPlayback_GetDrum(s32 fontId, s32 drumId) { + Drum* drum; + + if (fontId == 0xFF) { + return NULL; + } + + if (!AudioLoad_IsFontLoadComplete(fontId)) { + gAudioContext.audioErrorFlags = fontId + 0x10000000; + return NULL; + } + + if (drumId >= gAudioContext.soundFonts[fontId].numDrums) { + gAudioContext.audioErrorFlags = ((fontId << 8) + drumId) + 0x4000000; + return NULL; + } + if ((u32)gAudioContext.soundFonts[fontId].drums < 0x80000000) { + return NULL; + } + drum = gAudioContext.soundFonts[fontId].drums[drumId]; + + if (drum == NULL) { + gAudioContext.audioErrorFlags = ((fontId << 8) + drumId) + 0x5000000; + } + + return drum; +} + +SoundFontSound* AudioPlayback_GetSfx(s32 fontId, s32 sfxId) { + SoundFontSound* sfx; + + if (fontId == 0xFF) { + return NULL; + } + + if (!AudioLoad_IsFontLoadComplete(fontId)) { + gAudioContext.audioErrorFlags = fontId + 0x10000000; + return NULL; + } + + if (sfxId >= gAudioContext.soundFonts[fontId].numSfx) { + gAudioContext.audioErrorFlags = ((fontId << 8) + sfxId) + 0x4000000; + return NULL; + } + + if ((u32)gAudioContext.soundFonts[fontId].soundEffects < 0x80000000) { + return NULL; + } + + sfx = &gAudioContext.soundFonts[fontId].soundEffects[sfxId]; + + if (sfx == NULL) { + gAudioContext.audioErrorFlags = ((fontId << 8) + sfxId) + 0x5000000; + } + + if (sfx->sample == NULL) { + return NULL; + } + + return sfx; +} + +s32 AudioPlayback_SetFontInstrument(s32 instrumentType, s32 fontId, s32 index, void* value) { + if (fontId == 0xFF) { + return -1; + } + + if (!AudioLoad_IsFontLoadComplete(fontId)) { + return -2; + } + + switch (instrumentType) { + case 0: + if (index >= gAudioContext.soundFonts[fontId].numDrums) { + return -3; + } + gAudioContext.soundFonts[fontId].drums[index] = value; + break; + + case 1: + if (index >= gAudioContext.soundFonts[fontId].numSfx) { + return -3; + } + gAudioContext.soundFonts[fontId].soundEffects[index] = *(SoundFontSound*)value; + break; + + default: + if (index >= gAudioContext.soundFonts[fontId].numInstruments) { + return -3; + } + gAudioContext.soundFonts[fontId].instruments[index] = value; + break; + } + + return 0; +} + +void AudioPlayback_SeqLayerDecayRelease(SequenceLayer* layer, s32 target) { + Note* note; + NoteAttributes* attrs; + SequenceChannel* chan; + s32 i; + + if (layer == NO_LAYER) { + return; + } + + layer->bit3 = false; + + if (layer->note == NULL) { + return; + } + + note = layer->note; + attrs = ¬e->playbackState.attributes; + + if (note->playbackState.wantedParentLayer == layer) { + note->playbackState.wantedParentLayer = NO_LAYER; + } + + if (note->playbackState.parentLayer != layer) { + if (note->playbackState.parentLayer == NO_LAYER && note->playbackState.wantedParentLayer == NO_LAYER && + note->playbackState.prevParentLayer == layer && target != ADSR_STATE_DECAY) { + note->playbackState.adsr.fadeOutVel = gAudioContext.audioBufferParameters.updatesPerFrameInv; + note->playbackState.adsr.action.s.release = true; + } + return; + } + + if (note->playbackState.adsr.action.s.state != ADSR_STATE_DECAY) { + attrs->freqScale = layer->noteFreqScale; + attrs->velocity = layer->noteVelocity; + attrs->pan = layer->notePan; + + if (layer->channel != NULL) { + chan = layer->channel; + + if (layer->unk_0A.s.bit_2 == 1) { + attrs->reverb = chan->reverb; + } else { + attrs->reverb = layer->unk_09; + } + + if (layer->unk_08 == 0x80) { + attrs->unk_3 = chan->unk_10; + } else { + attrs->unk_3 = layer->unk_08; + } + + if (layer->unk_0A.s.bit_9 == 1) { + attrs->unk_1 = chan->unk_0C; + } else { + attrs->unk_1 = 0; + } + + attrs->filter = chan->filter; + + if (attrs->filter != NULL) { + for (i = 0; i < 8; i++) { + attrs->filterBuf[i] = attrs->filter[i]; + } + attrs->filter = attrs->filterBuf; + } + + attrs->unk_6 = chan->unk_20; + attrs->unk_4 = chan->unk_0F; + if (chan->seqPlayer->muted && (chan->muteBehavior & 8)) { + note->noteSubEu.bitField0.finished = true; + } + + if (layer->stereo.asByte == 0) { + attrs->stereo = chan->stereo; + } else { + attrs->stereo = layer->stereo; + } + note->playbackState.priority = chan->someOtherPriority; + } else { + attrs->stereo = layer->stereo; + note->playbackState.priority = 1; + } + + note->playbackState.prevParentLayer = note->playbackState.parentLayer; + note->playbackState.parentLayer = NO_LAYER; + if (target == ADSR_STATE_RELEASE) { + note->playbackState.adsr.fadeOutVel = gAudioContext.audioBufferParameters.updatesPerFrameInv; + note->playbackState.adsr.action.s.release = true; + note->playbackState.unk_04 = 2; + } else { + note->playbackState.unk_04 = 1; + note->playbackState.adsr.action.s.decay = true; + if (layer->adsr.releaseRate == 0) { + note->playbackState.adsr.fadeOutVel = gAudioContext.unk_3520[layer->channel->adsr.releaseRate]; + } else { + note->playbackState.adsr.fadeOutVel = gAudioContext.unk_3520[layer->adsr.releaseRate]; + } + note->playbackState.adsr.sustain = + ((f32)(s32)(layer->channel->adsr.sustain) * note->playbackState.adsr.current) / 256.0f; + } + } + + if (target == ADSR_STATE_DECAY) { + AudioPlayback_AudioListRemove(¬e->listItem); + AudioPlayback_AudioListPushFront(¬e->listItem.pool->decaying, ¬e->listItem); + } +} + +void AudioPlayback_SeqLayerNoteDecay(SequenceLayer* layer) { + AudioPlayback_SeqLayerDecayRelease(layer, ADSR_STATE_DECAY); +} + +void AudioPlayback_SeqLayerNoteRelease(SequenceLayer* layer) { + AudioPlayback_SeqLayerDecayRelease(layer, ADSR_STATE_RELEASE); +} + +s32 AudioPlayback_BuildSyntheticWave(Note* note, SequenceLayer* layer, s32 waveId) { + f32 freqScale; + f32 ratio; + u8 sampleCountIndex; + + if (waveId < 128) { + waveId = 128; + } + + freqScale = layer->freqScale; + if (layer->portamento.mode != 0 && 0.0f < layer->portamento.extent) { + freqScale *= (layer->portamento.extent + 1.0f); + } + if (freqScale < 0.99999f) { + sampleCountIndex = 0; + ratio = 1.0465f; + } else if (freqScale < 1.99999f) { + sampleCountIndex = 1; + ratio = 0.52325f; + } else if (freqScale < 3.99999f) { + sampleCountIndex = 2; + ratio = 0.26263f; + } else { + sampleCountIndex = 3; + ratio = 0.13081f; + } + layer->freqScale *= ratio; + note->playbackState.waveId = waveId; + note->playbackState.sampleCountIndex = sampleCountIndex; + + note->noteSubEu.sound.samples = &gWaveSamples[waveId - 128][sampleCountIndex * 64]; + + return sampleCountIndex; +} + +void AudioPlayback_InitSyntheticWave(Note* note, SequenceLayer* layer) { + s32 sampleCountIndex; + s32 waveSampleCountIndex; + s32 waveId = layer->instOrWave; + + if (waveId == 0xFF) { + waveId = layer->channel->instOrWave; + } + + sampleCountIndex = note->playbackState.sampleCountIndex; + waveSampleCountIndex = AudioPlayback_BuildSyntheticWave(note, layer, waveId); + + if (waveSampleCountIndex != sampleCountIndex) { + note->noteSubEu.unk_06 = waveSampleCountIndex * 4 + sampleCountIndex; + } +} + +void AudioPlayback_InitNoteList(AudioListItem* list) { + list->prev = list; + list->next = list; + list->u.count = 0; +} + +void AudioPlayback_InitNoteLists(NotePool* pool) { + AudioPlayback_InitNoteList(&pool->disabled); + AudioPlayback_InitNoteList(&pool->decaying); + AudioPlayback_InitNoteList(&pool->releasing); + AudioPlayback_InitNoteList(&pool->active); + pool->disabled.pool = pool; + pool->decaying.pool = pool; + pool->releasing.pool = pool; + pool->active.pool = pool; +} + +void AudioPlayback_InitNoteFreeList(void) { + s32 i; + + AudioPlayback_InitNoteLists(&gAudioContext.noteFreeLists); + for (i = 0; i < gAudioContext.numNotes; i++) { + gAudioContext.notes[i].listItem.u.value = &gAudioContext.notes[i]; + gAudioContext.notes[i].listItem.prev = NULL; + AudioSeq_AudioListPushBack(&gAudioContext.noteFreeLists.disabled, &gAudioContext.notes[i].listItem); + } +} + +void AudioPlayback_NotePoolClear(NotePool* pool) { + s32 i; + AudioListItem* source; + AudioListItem* cur; + AudioListItem* dest; + + for (i = 0; i < 4; i++) { + switch (i) { + case 0: + source = &pool->disabled; + dest = &gAudioContext.noteFreeLists.disabled; + break; + + case 1: + source = &pool->decaying; + dest = &gAudioContext.noteFreeLists.decaying; + break; + + case 2: + source = &pool->releasing; + dest = &gAudioContext.noteFreeLists.releasing; + break; + + case 3: + source = &pool->active; + dest = &gAudioContext.noteFreeLists.active; + break; + } + + for (;;) { + cur = source->next; + if (cur == source || cur == NULL) { + break; + } + AudioPlayback_AudioListRemove(cur); + AudioSeq_AudioListPushBack(dest, cur); + } + } +} + +void AudioPlayback_NotePoolFill(NotePool* pool, s32 count) { + s32 i; + s32 j; + Note* note; + AudioListItem* source; + AudioListItem* dest; + + AudioPlayback_NotePoolClear(pool); + + for (i = 0, j = 0; j < count; i++) { + if (i == 4) { + return; + } + + switch (i) { + case 0: + source = &gAudioContext.noteFreeLists.disabled; + dest = &pool->disabled; + break; + + case 1: + source = &gAudioContext.noteFreeLists.decaying; + dest = &pool->decaying; + break; + + case 2: + source = &gAudioContext.noteFreeLists.releasing; + dest = &pool->releasing; + break; + + case 3: + source = &gAudioContext.noteFreeLists.active; + dest = &pool->active; + break; + } + + while (j < count) { + note = AudioSeq_AudioListPopBack(source); + if (note == NULL) { + break; + } + AudioSeq_AudioListPushBack(dest, ¬e->listItem); + j++; + } + } +} + +void AudioPlayback_AudioListPushFront(AudioListItem* list, AudioListItem* item) { + // add 'item' to the front of the list given by 'list', if it's not in any list + if (item->prev == NULL) { + item->prev = list; + item->next = list->next; + list->next->prev = item; + list->next = item; + list->u.count++; + item->pool = list->pool; + } +} + +void AudioPlayback_AudioListRemove(AudioListItem* item) { + // remove 'item' from the list it's in, if any + if (item->prev != NULL) { + item->prev->next = item->next; + item->next->prev = item->prev; + item->prev = NULL; + } +} + +Note* AudioPlayback_FindNodeWithPrioLessThan(AudioListItem* list, s32 limit) { + AudioListItem* cur = list->next; + AudioListItem* best; + + if (cur == list) { + return NULL; + } + + for (best = cur; cur != list; cur = cur->next) { + if (((Note*)best->u.value)->playbackState.priority >= ((Note*)cur->u.value)->playbackState.priority) { + best = cur; + } + } + + if (best == NULL) { + return NULL; + } + + if (limit <= ((Note*)best->u.value)->playbackState.priority) { + return NULL; + } + + return best->u.value; +} + +void AudioPlayback_NoteInitForLayer(Note* note, SequenceLayer* layer) { + s32 pad[3]; + s16 instId; + SequenceChannel* channel = layer->channel; + NotePlaybackState* playbackState = ¬e->playbackState; + NoteSubEu* noteSubEu = ¬e->noteSubEu; + + playbackState->prevParentLayer = NO_LAYER; + playbackState->parentLayer = layer; + playbackState->priority = channel->notePriority; + layer->notePropertiesNeedInit = true; + layer->bit3 = true; + layer->note = note; + channel->noteUnused = note; + channel->layerUnused = layer; + layer->noteVelocity = 0.0f; + AudioPlayback_NoteInit(note); + instId = layer->instOrWave; + + if (instId == 0xFF) { + instId = channel->instOrWave; + } + noteSubEu->sound.soundFontSound = layer->sound; + + if (instId >= 0x80 && instId < 0xC0) { + noteSubEu->bitField1.isSyntheticWave = true; + } else { + noteSubEu->bitField1.isSyntheticWave = false; + } + + if (noteSubEu->bitField1.isSyntheticWave) { + AudioPlayback_BuildSyntheticWave(note, layer, instId); + } else if (channel->unk_DC == 1) { + playbackState->unk_84 = noteSubEu->sound.soundFontSound->sample->loop->start; + } else { + playbackState->unk_84 = channel->unk_DC; + if (playbackState->unk_84 >= noteSubEu->sound.soundFontSound->sample->loop->end) { + playbackState->unk_84 = 0; + } + } + + playbackState->fontId = channel->fontId; + playbackState->stereoHeadsetEffects = channel->stereoHeadsetEffects; + noteSubEu->bitField1.reverbIndex = channel->reverbIndex & 3; +} + +void func_801963E8(Note* note, SequenceLayer* layer) { + // similar to Audio_NoteReleaseAndTakeOwnership, hard to say what the difference is + AudioPlayback_SeqLayerNoteRelease(note->playbackState.parentLayer); + note->playbackState.wantedParentLayer = layer; +} + +void AudioPlayback_NoteReleaseAndTakeOwnership(Note* note, SequenceLayer* layer) { + note->playbackState.wantedParentLayer = layer; + note->playbackState.priority = layer->channel->notePriority; + + note->playbackState.adsr.fadeOutVel = gAudioContext.audioBufferParameters.updatesPerFrameInv; + note->playbackState.adsr.action.s.release = true; +} + +Note* AudioPlayback_AllocNoteFromDisabled(NotePool* pool, SequenceLayer* layer) { + Note* note = AudioSeq_AudioListPopBack(&pool->disabled); + if (note != NULL) { + AudioPlayback_NoteInitForLayer(note, layer); + AudioPlayback_AudioListPushFront(&pool->active, ¬e->listItem); + } + return note; +} + +Note* AudioPlayback_AllocNoteFromDecaying(NotePool* pool, SequenceLayer* layer) { + Note* note = AudioPlayback_FindNodeWithPrioLessThan(&pool->decaying, layer->channel->notePriority); + + if (note != NULL) { + AudioPlayback_NoteReleaseAndTakeOwnership(note, layer); + AudioPlayback_AudioListRemove(¬e->listItem); + AudioSeq_AudioListPushBack(&pool->releasing, ¬e->listItem); + } + return note; +} + +Note* AudioPlayback_AllocNoteFromActive(NotePool* pool, SequenceLayer* layer) { + Note* rNote; + Note* aNote; + s32 rPriority; + s32 aPriority; + + rPriority = aPriority = 0x10; + rNote = AudioPlayback_FindNodeWithPrioLessThan(&pool->releasing, layer->channel->notePriority); + + if (rNote != NULL) { + rPriority = rNote->playbackState.priority; + } + + aNote = AudioPlayback_FindNodeWithPrioLessThan(&pool->active, layer->channel->notePriority); + + if (aNote != NULL) { + aPriority = aNote->playbackState.priority; + } + + if (rNote == NULL && aNote == NULL) { + return NULL; + } + + if (aPriority < rPriority) { + AudioPlayback_AudioListRemove(&aNote->listItem); + func_801963E8(aNote, layer); + AudioSeq_AudioListPushBack(&pool->releasing, &aNote->listItem); + aNote->playbackState.priority = layer->channel->notePriority; + return aNote; + } + rNote->playbackState.wantedParentLayer = layer; + rNote->playbackState.priority = layer->channel->notePriority; + return rNote; +} + +Note* AudioPlayback_AllocNote(SequenceLayer* layer) { + Note* note; + u32 policy = layer->channel->noteAllocPolicy; + + if (policy & 1) { + note = layer->note; + if (note != NULL && note->playbackState.prevParentLayer == layer && + note->playbackState.wantedParentLayer == NO_LAYER) { + AudioPlayback_NoteReleaseAndTakeOwnership(note, layer); + AudioPlayback_AudioListRemove(¬e->listItem); + AudioSeq_AudioListPushBack(¬e->listItem.pool->releasing, ¬e->listItem); + return note; + } + } + + if (policy & 2) { + if (!(note = AudioPlayback_AllocNoteFromDisabled(&layer->channel->notePool, layer)) && + !(note = AudioPlayback_AllocNoteFromDecaying(&layer->channel->notePool, layer)) && + !(note = AudioPlayback_AllocNoteFromActive(&layer->channel->notePool, layer))) { + goto null_return; + } + return note; + } + + if (policy & 4) { + if (!(note = AudioPlayback_AllocNoteFromDisabled(&layer->channel->notePool, layer)) && + !(note = AudioPlayback_AllocNoteFromDisabled(&layer->channel->seqPlayer->notePool, layer)) && + !(note = AudioPlayback_AllocNoteFromDecaying(&layer->channel->notePool, layer)) && + !(note = AudioPlayback_AllocNoteFromDecaying(&layer->channel->seqPlayer->notePool, layer)) && + !(note = AudioPlayback_AllocNoteFromActive(&layer->channel->notePool, layer)) && + !(note = AudioPlayback_AllocNoteFromActive(&layer->channel->seqPlayer->notePool, layer))) { + goto null_return; + } + return note; + } + + if (policy & 8) { + if (!(note = AudioPlayback_AllocNoteFromDisabled(&gAudioContext.noteFreeLists, layer)) && + !(note = AudioPlayback_AllocNoteFromDecaying(&gAudioContext.noteFreeLists, layer)) && + !(note = AudioPlayback_AllocNoteFromActive(&gAudioContext.noteFreeLists, layer))) { + goto null_return; + } + return note; + } + + if (!(note = AudioPlayback_AllocNoteFromDisabled(&layer->channel->notePool, layer)) && + !(note = AudioPlayback_AllocNoteFromDisabled(&layer->channel->seqPlayer->notePool, layer)) && + !(note = AudioPlayback_AllocNoteFromDisabled(&gAudioContext.noteFreeLists, layer)) && + !(note = AudioPlayback_AllocNoteFromDecaying(&layer->channel->notePool, layer)) && + !(note = AudioPlayback_AllocNoteFromDecaying(&layer->channel->seqPlayer->notePool, layer)) && + !(note = AudioPlayback_AllocNoteFromDecaying(&gAudioContext.noteFreeLists, layer)) && + !(note = AudioPlayback_AllocNoteFromActive(&layer->channel->notePool, layer)) && + !(note = AudioPlayback_AllocNoteFromActive(&layer->channel->seqPlayer->notePool, layer)) && + !(note = AudioPlayback_AllocNoteFromActive(&gAudioContext.noteFreeLists, layer))) { + goto null_return; + } + return note; + +null_return: + layer->bit3 = true; + return NULL; +} + +void AudioPlayback_NoteInitAll(void) { + Note* note; + s32 i; + + for (i = 0; i < gAudioContext.numNotes; i++) { + note = &gAudioContext.notes[i]; + note->noteSubEu = gZeroNoteSub; + note->playbackState.priority = 0; + note->playbackState.unk_04 = 0; + note->playbackState.parentLayer = NO_LAYER; + note->playbackState.wantedParentLayer = NO_LAYER; + note->playbackState.prevParentLayer = NO_LAYER; + note->playbackState.waveId = 0; + note->playbackState.attributes.velocity = 0.0f; + note->playbackState.adsrVolScaleUnused = 0; + note->playbackState.adsr.action.asByte = 0; + note->playbackState.vibratoState.active = false; + note->playbackState.portamento.cur = 0; + note->playbackState.portamento.speed = 0; + note->playbackState.stereoHeadsetEffects = false; + note->playbackState.unk_84 = 0; + note->synthesisState.synthesisBuffers = AudioHeap_AllocDmaMemory(&gAudioContext.notesAndBuffersPool, 0x2E0); + note->playbackState.attributes.filterBuf = AudioHeap_AllocDmaMemory(&gAudioContext.notesAndBuffersPool, 0x10); + } +} diff --git a/src/code/audio/audio_seqplayer.c b/src/code/audio/audio_seqplayer.c index ec43757967..56d8ac9516 100644 --- a/src/code/audio/audio_seqplayer.c +++ b/src/code/audio/audio_seqplayer.c @@ -12,7 +12,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197A54.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197AA4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_SequenceChannelDisable.s") #pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197B14.s") @@ -24,9 +24,9 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerDisable.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197E08.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_AudioListPushBack.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197E48.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_AudioListPopBack.s") #pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197E88.s") diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 6a2ea013a2..b8ef4b8f78 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -3555,7 +3555,7 @@ 0x8018B4F8:("func_8018B4F8",), 0x8018B520:("func_8018B520",), 0x8018B578:("func_8018B578",), - 0x8018B5D0:("func_8018B5D0",), + 0x8018B5D0:("AudioHeap_AllocDmaMemory",), 0x8018B608:("func_8018B608",), 0x8018B640:("func_8018B640",), 0x8018B69C:("func_8018B69C",), @@ -3604,7 +3604,7 @@ 0x8018EB60:("func_8018EB60",), 0x8018EC4C:("func_8018EC4C",), 0x8018EF88:("func_8018EF88",), - 0x8018F220:("func_8018F220",), + 0x8018F220:("AudioLoad_IsFontLoadComplete",), 0x8018F298:("func_8018F298",), 0x8018F310:("func_8018F310",), 0x8018F388:("func_8018F388",), @@ -3726,37 +3726,37 @@ 0x80194804:("func_80194804",), 0x80194840:("func_80194840",), 0x801948B0:("func_801948B0",), - 0x80194930:("func_80194930",), - 0x80194DB0:("func_80194DB0",), - 0x80194E60:("func_80194E60",), - 0x80194F20:("func_80194F20",), - 0x80194F84:("func_80194F84",), - 0x801954CC:("func_801954CC",), - 0x80195508:("func_80195508",), - 0x801955DC:("func_801955DC",), - 0x801956C0:("func_801956C0",), - 0x801957B4:("func_801957B4",), - 0x801958F8:("func_801958F8",), - 0x80195C40:("func_80195C40",), - 0x80195C60:("func_80195C60",), - 0x80195C80:("func_80195C80",), - 0x80195D84:("func_80195D84",), - 0x80195DDC:("func_80195DDC",), - 0x80195DEC:("func_80195DEC",), - 0x80195E3C:("func_80195E3C",), - 0x80195EE0:("func_80195EE0",), - 0x80196040:("func_80196040",), - 0x8019617C:("func_8019617C",), - 0x801961BC:("func_801961BC",), - 0x801961E8:("func_801961E8",), - 0x80196268:("func_80196268",), + 0x80194930:("AudioPlayback_InitNoteSub",), + 0x80194DB0:("AudioPlayback_NoteSetResamplingRate",), + 0x80194E60:("AudioPlayback_NoteInit",), + 0x80194F20:("AudioPlayback_NoteDisable",), + 0x80194F84:("AudioPlayback_ProcessNotes",), + 0x801954CC:("AudioPlayback_InstrumentGetSound",), + 0x80195508:("AudioPlayback_GetInstrumentInner",), + 0x801955DC:("AudioPlayback_GetDrum",), + 0x801956C0:("AudioPlayback_GetSfx",), + 0x801957B4:("AudioPlayback_SetFontInstrument",), + 0x801958F8:("AudioPlayback_SeqLayerDecayRelease",), + 0x80195C40:("AudioPlayback_SeqLayerNoteDecay",), + 0x80195C60:("AudioPlayback_SeqLayerNoteRelease",), + 0x80195C80:("AudioPlayback_BuildSyntheticWave",), + 0x80195D84:("AudioPlayback_InitSyntheticWave",), + 0x80195DDC:("AudioPlayback_InitNoteList",), + 0x80195DEC:("AudioPlayback_InitNoteLists",), + 0x80195E3C:("AudioPlayback_InitNoteFreeList",), + 0x80195EE0:("AudioPlayback_NotePoolClear",), + 0x80196040:("AudioPlayback_NotePoolFill",), + 0x8019617C:("AudioPlayback_AudioListPushFront",), + 0x801961BC:("AudioPlayback_AudioListRemove",), + 0x801961E8:("AudioPlayback_FindNodeWithPrioLessThan",), + 0x80196268:("AudioPlayback_NoteInitForLayer",), 0x801963E8:("func_801963E8",), - 0x8019641C:("func_8019641C",), - 0x80196448:("func_80196448",), - 0x80196494:("func_80196494",), - 0x801964F8:("func_801964F8",), - 0x801965F0:("func_801965F0",), - 0x801968C4:("func_801968C4",), + 0x8019641C:("AudioPlayback_NoteReleaseAndTakeOwnership",), + 0x80196448:("AudioPlayback_AllocNoteFromDisabled",), + 0x80196494:("AudioPlayback_AllocNoteFromDecaying",), + 0x801964F8:("AudioPlayback_AllocNoteFromActive",), + 0x801965F0:("AudioPlayback_AllocNote",), + 0x801968C4:("AudioPlayback_NoteInitAll",), 0x80196A00:("AudioEffects_SequenceChannelProcessSound",), 0x80196BC8:("AudioEffects_SequencePlayerProcessSound",), 0x80196D20:("AudioEffects_GetPortamentoFreqScale",), @@ -3773,14 +3773,14 @@ 0x80197880:("func_80197880",), 0x801979D8:("func_801979D8",), 0x80197A54:("func_80197A54",), - 0x80197AA4:("func_80197AA4",), + 0x80197AA4:("AudioSeq_SequenceChannelDisable",), 0x80197B14:("func_80197B14",), 0x80197C0C:("func_80197C0C",), 0x80197C8C:("func_80197C8C",), 0x80197D24:("func_80197D24",), 0x80197D4C:("AudioSeq_SequencePlayerDisable",), - 0x80197E08:("func_80197E08",), - 0x80197E48:("func_80197E48",), + 0x80197E08:("AudioSeq_AudioListPushBack",), + 0x80197E48:("AudioSeq_AudioListPopBack",), 0x80197E88:("func_80197E88",), 0x80197F28:("func_80197F28",), 0x80197F3C:("func_80197F3C",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index aedb3d7195..daca51393c 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -2270,14 +2270,14 @@ 0x801D57B4:("D_801D57B4","UNK_TYPE1","",0x1), 0x801D57C4:("D_801D57C4","UNK_TYPE1","",0x1), 0x801D57D4:("D_801D57D4","UNK_TYPE1","",0x1), - 0x801D57E4:("D_801D57E4","UNK_TYPE4","",0x4), - 0x801D5804:("D_801D5804","UNK_TYPE4","",0x4), - 0x801D5824:("D_801D5824","UNK_TYPE2","",0x2), + 0x801D57E4:("gZeroNoteSub","UNK_TYPE4","",0x4), + 0x801D5804:("gDefaultNoteSub","UNK_TYPE4","",0x4), + 0x801D5824:("gHeadsetPanQuantization","UNK_TYPE2","",0x2), 0x801D58A2:("D_801D58A2","UNK_TYPE2","",0x2), 0x801D58AA:("D_801D58AA","UNK_TYPE1","",0x1), - 0x801D5928:("D_801D5928","f32","[128]",0x200), - 0x801D5B28:("D_801D5B28","f32","[128]",0x200), - 0x801D5D28:("D_801D5D28","f32","[128]",0x200), + 0x801D5928:("gHeadsetPanVolume","f32","[128]",0x200), + 0x801D5B28:("gStereoPanVolume","f32","[128]",0x200), + 0x801D5D28:("gDefaultPanVolume","f32","[128]",0x200), 0x801D5F28:("D_801D5F28","s16","[64]",0x80), 0x801D5FB0:("D_801D5FB0","UNK_TYPE4","",0x4), 0x801D5FB4:("D_801D5FB4","UNK_TYPE4","",0x4), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 3ce371c04d..b631f72c1e 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -3073,7 +3073,7 @@ asm/non_matchings/code/audio_heap/func_8018B474.s,func_8018B474,0x8018B474,0x21 asm/non_matchings/code/audio_heap/func_8018B4F8.s,func_8018B4F8,0x8018B4F8,0xA asm/non_matchings/code/audio_heap/func_8018B520.s,func_8018B520,0x8018B520,0x16 asm/non_matchings/code/audio_heap/func_8018B578.s,func_8018B578,0x8018B578,0x16 -asm/non_matchings/code/audio_heap/func_8018B5D0.s,func_8018B5D0,0x8018B5D0,0xE +asm/non_matchings/code/audio_heap/AudioHeap_AllocDmaMemory.s,AudioHeap_AllocDmaMemory,0x8018B5D0,0xE asm/non_matchings/code/audio_heap/func_8018B608.s,func_8018B608,0x8018B608,0xE asm/non_matchings/code/audio_heap/func_8018B640.s,func_8018B640,0x8018B640,0x17 asm/non_matchings/code/audio_heap/func_8018B69C.s,func_8018B69C,0x8018B69C,0x13 @@ -3122,7 +3122,7 @@ asm/non_matchings/code/audio_heap/func_8018E8C8.s,func_8018E8C8,0x8018E8C8,0xA6 asm/non_matchings/code/audio_load/func_8018EB60.s,func_8018EB60,0x8018EB60,0x3B asm/non_matchings/code/audio_load/func_8018EC4C.s,func_8018EC4C,0x8018EC4C,0xCF asm/non_matchings/code/audio_load/func_8018EF88.s,func_8018EF88,0x8018EF88,0xA6 -asm/non_matchings/code/audio_load/func_8018F220.s,func_8018F220,0x8018F220,0x1E +asm/non_matchings/code/audio_load/AudioLoad_IsFontLoadComplete.s,AudioLoad_IsFontLoadComplete,0x8018F220,0x1E asm/non_matchings/code/audio_load/func_8018F298.s,func_8018F298,0x8018F298,0x1E asm/non_matchings/code/audio_load/func_8018F310.s,func_8018F310,0x8018F310,0x1E asm/non_matchings/code/audio_load/func_8018F388.s,func_8018F388,0x8018F388,0xC @@ -3244,37 +3244,37 @@ asm/non_matchings/code/code_80194710/func_80194790.s,func_80194790,0x80194790,0x asm/non_matchings/code/code_80194710/func_80194804.s,func_80194804,0x80194804,0xF asm/non_matchings/code/code_80194710/func_80194840.s,func_80194840,0x80194840,0x1C asm/non_matchings/code/code_80194710/func_801948B0.s,func_801948B0,0x801948B0,0x20 -asm/non_matchings/code/audio_playback/func_80194930.s,func_80194930,0x80194930,0x120 -asm/non_matchings/code/audio_playback/func_80194DB0.s,func_80194DB0,0x80194DB0,0x2C -asm/non_matchings/code/audio_playback/func_80194E60.s,func_80194E60,0x80194E60,0x30 -asm/non_matchings/code/audio_playback/func_80194F20.s,func_80194F20,0x80194F20,0x19 -asm/non_matchings/code/audio_playback/func_80194F84.s,func_80194F84,0x80194F84,0x152 -asm/non_matchings/code/audio_playback/func_801954CC.s,func_801954CC,0x801954CC,0xF -asm/non_matchings/code/audio_playback/func_80195508.s,func_80195508,0x80195508,0x35 -asm/non_matchings/code/audio_playback/func_801955DC.s,func_801955DC,0x801955DC,0x39 -asm/non_matchings/code/audio_playback/func_801956C0.s,func_801956C0,0x801956C0,0x3D -asm/non_matchings/code/audio_playback/func_801957B4.s,func_801957B4,0x801957B4,0x51 -asm/non_matchings/code/audio_playback/func_801958F8.s,func_801958F8,0x801958F8,0xD2 -asm/non_matchings/code/audio_playback/func_80195C40.s,func_80195C40,0x80195C40,0x8 -asm/non_matchings/code/audio_playback/func_80195C60.s,func_80195C60,0x80195C60,0x8 -asm/non_matchings/code/audio_playback/func_80195C80.s,func_80195C80,0x80195C80,0x41 -asm/non_matchings/code/audio_playback/func_80195D84.s,func_80195D84,0x80195D84,0x16 -asm/non_matchings/code/audio_playback/func_80195DDC.s,func_80195DDC,0x80195DDC,0x4 -asm/non_matchings/code/audio_playback/func_80195DEC.s,func_80195DEC,0x80195DEC,0x14 -asm/non_matchings/code/audio_playback/func_80195E3C.s,func_80195E3C,0x80195E3C,0x29 -asm/non_matchings/code/audio_playback/func_80195EE0.s,func_80195EE0,0x80195EE0,0x58 -asm/non_matchings/code/audio_playback/func_80196040.s,func_80196040,0x80196040,0x4F -asm/non_matchings/code/audio_playback/func_8019617C.s,func_8019617C,0x8019617C,0x10 -asm/non_matchings/code/audio_playback/func_801961BC.s,func_801961BC,0x801961BC,0xB -asm/non_matchings/code/audio_playback/func_801961E8.s,func_801961E8,0x801961E8,0x20 -asm/non_matchings/code/audio_playback/func_80196268.s,func_80196268,0x80196268,0x60 +asm/non_matchings/code/audio_playback/AudioPlayback_InitNoteSub.s,AudioPlayback_InitNoteSub,0x80194930,0x120 +asm/non_matchings/code/audio_playback/AudioPlayback_NoteSetResamplingRate.s,AudioPlayback_NoteSetResamplingRate,0x80194DB0,0x2C +asm/non_matchings/code/audio_playback/AudioPlayback_NoteInit.s,AudioPlayback_NoteInit,0x80194E60,0x30 +asm/non_matchings/code/audio_playback/AudioPlayback_NoteDisable.s,AudioPlayback_NoteDisable,0x80194F20,0x19 +asm/non_matchings/code/audio_playback/AudioPlayback_ProcessNotes.s,AudioPlayback_ProcessNotes,0x80194F84,0x152 +asm/non_matchings/code/audio_playback/AudioPlayback_InstrumentGetSound.s,AudioPlayback_InstrumentGetSound,0x801954CC,0xF +asm/non_matchings/code/audio_playback/AudioPlayback_GetInstrumentInner.s,AudioPlayback_GetInstrumentInner,0x80195508,0x35 +asm/non_matchings/code/audio_playback/AudioPlayback_GetDrum.s,AudioPlayback_GetDrum,0x801955DC,0x39 +asm/non_matchings/code/audio_playback/AudioPlayback_GetSfx.s,AudioPlayback_GetSfx,0x801956C0,0x3D +asm/non_matchings/code/audio_playback/AudioPlayback_SetFontInstrument.s,AudioPlayback_SetFontInstrument,0x801957B4,0x51 +asm/non_matchings/code/audio_playback/AudioPlayback_SeqLayerDecayRelease.s,AudioPlayback_SeqLayerDecayRelease,0x801958F8,0xD2 +asm/non_matchings/code/audio_playback/AudioPlayback_SeqLayerNoteDecay.s,AudioPlayback_SeqLayerNoteDecay,0x80195C40,0x8 +asm/non_matchings/code/audio_playback/AudioPlayback_SeqLayerNoteRelease.s,AudioPlayback_SeqLayerNoteRelease,0x80195C60,0x8 +asm/non_matchings/code/audio_playback/AudioPlayback_BuildSyntheticWave.s,AudioPlayback_BuildSyntheticWave,0x80195C80,0x41 +asm/non_matchings/code/audio_playback/AudioPlayback_InitSyntheticWave.s,AudioPlayback_InitSyntheticWave,0x80195D84,0x16 +asm/non_matchings/code/audio_playback/AudioPlayback_InitNoteList.s,AudioPlayback_InitNoteList,0x80195DDC,0x4 +asm/non_matchings/code/audio_playback/AudioPlayback_InitNoteLists.s,AudioPlayback_InitNoteLists,0x80195DEC,0x14 +asm/non_matchings/code/audio_playback/AudioPlayback_InitNoteFreeList.s,AudioPlayback_InitNoteFreeList,0x80195E3C,0x29 +asm/non_matchings/code/audio_playback/AudioPlayback_NotePoolClear.s,AudioPlayback_NotePoolClear,0x80195EE0,0x58 +asm/non_matchings/code/audio_playback/AudioPlayback_NotePoolFill.s,AudioPlayback_NotePoolFill,0x80196040,0x4F +asm/non_matchings/code/audio_playback/AudioPlayback_AudioListPushFront.s,AudioPlayback_AudioListPushFront,0x8019617C,0x10 +asm/non_matchings/code/audio_playback/AudioPlayback_AudioListRemove.s,AudioPlayback_AudioListRemove,0x801961BC,0xB +asm/non_matchings/code/audio_playback/AudioPlayback_FindNodeWithPrioLessThan.s,AudioPlayback_FindNodeWithPrioLessThan,0x801961E8,0x20 +asm/non_matchings/code/audio_playback/AudioPlayback_NoteInitForLayer.s,AudioPlayback_NoteInitForLayer,0x80196268,0x60 asm/non_matchings/code/audio_playback/func_801963E8.s,func_801963E8,0x801963E8,0xD -asm/non_matchings/code/audio_playback/func_8019641C.s,func_8019641C,0x8019641C,0xB -asm/non_matchings/code/audio_playback/func_80196448.s,func_80196448,0x80196448,0x13 -asm/non_matchings/code/audio_playback/func_80196494.s,func_80196494,0x80196494,0x19 -asm/non_matchings/code/audio_playback/func_801964F8.s,func_801964F8,0x801964F8,0x3E -asm/non_matchings/code/audio_playback/func_801965F0.s,func_801965F0,0x801965F0,0xB5 -asm/non_matchings/code/audio_playback/func_801968C4.s,func_801968C4,0x801968C4,0x4F +asm/non_matchings/code/audio_playback/AudioPlayback_NoteReleaseAndTakeOwnership.s,AudioPlayback_NoteReleaseAndTakeOwnership,0x8019641C,0xB +asm/non_matchings/code/audio_playback/AudioPlayback_AllocNoteFromDisabled.s,AudioPlayback_AllocNoteFromDisabled,0x80196448,0x13 +asm/non_matchings/code/audio_playback/AudioPlayback_AllocNoteFromDecaying.s,AudioPlayback_AllocNoteFromDecaying,0x80196494,0x19 +asm/non_matchings/code/audio_playback/AudioPlayback_AllocNoteFromActive.s,AudioPlayback_AllocNoteFromActive,0x801964F8,0x3E +asm/non_matchings/code/audio_playback/AudioPlayback_AllocNote.s,AudioPlayback_AllocNote,0x801965F0,0xB5 +asm/non_matchings/code/audio_playback/AudioPlayback_NoteInitAll.s,AudioPlayback_NoteInitAll,0x801968C4,0x4F asm/non_matchings/code/audio_effects/AudioEffects_SequenceChannelProcessSound.s,AudioEffects_SequenceChannelProcessSound,0x80196A00,0x72 asm/non_matchings/code/audio_effects/AudioEffects_SequencePlayerProcessSound.s,AudioEffects_SequencePlayerProcessSound,0x80196BC8,0x56 asm/non_matchings/code/audio_effects/AudioEffects_GetPortamentoFreqScale.s,AudioEffects_GetPortamentoFreqScale,0x80196D20,0x17 @@ -3291,14 +3291,14 @@ asm/non_matchings/code/audio_seqplayer/func_80197714.s,func_80197714,0x80197714, asm/non_matchings/code/audio_seqplayer/func_80197880.s,func_80197880,0x80197880,0x56 asm/non_matchings/code/audio_seqplayer/func_801979D8.s,func_801979D8,0x801979D8,0x1F asm/non_matchings/code/audio_seqplayer/func_80197A54.s,func_80197A54,0x80197A54,0x14 -asm/non_matchings/code/audio_seqplayer/func_80197AA4.s,func_80197AA4,0x80197AA4,0x1C +asm/non_matchings/code/audio_seqplayer/AudioSeq_SequenceChannelDisable.s,AudioSeq_SequenceChannelDisable,0x80197AA4,0x1C asm/non_matchings/code/audio_seqplayer/func_80197B14.s,func_80197B14,0x80197B14,0x3E asm/non_matchings/code/audio_seqplayer/func_80197C0C.s,func_80197C0C,0x80197C0C,0x20 asm/non_matchings/code/audio_seqplayer/func_80197C8C.s,func_80197C8C,0x80197C8C,0x26 asm/non_matchings/code/audio_seqplayer/func_80197D24.s,func_80197D24,0x80197D24,0xA asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerDisable.s,AudioSeq_SequencePlayerDisable,0x80197D4C,0x2F -asm/non_matchings/code/audio_seqplayer/func_80197E08.s,func_80197E08,0x80197E08,0x10 -asm/non_matchings/code/audio_seqplayer/func_80197E48.s,func_80197E48,0x80197E48,0x10 +asm/non_matchings/code/audio_seqplayer/AudioSeq_AudioListPushBack.s,AudioSeq_AudioListPushBack,0x80197E08,0x10 +asm/non_matchings/code/audio_seqplayer/AudioSeq_AudioListPopBack.s,AudioSeq_AudioListPopBack,0x80197E48,0x10 asm/non_matchings/code/audio_seqplayer/func_80197E88.s,func_80197E88,0x80197E88,0x28 asm/non_matchings/code/audio_seqplayer/func_80197F28.s,func_80197F28,0x80197F28,0x5 asm/non_matchings/code/audio_seqplayer/func_80197F3C.s,func_80197F3C,0x80197F3C,0xE