1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-03 22:44:30 +00:00

audio_seqplayer, the easy half (#369)

* func_800E9340

* Audio_SequenceChannelDisable

* Audio_SeqChannelLayerFree

* Audio_SeqChannelLayerDisable

* Rename functions

* Audio_SeqChannelSetLayer

* Move gSequenceChannelNone into gAudioContext

* Audio_SequenceChannelInit

* Name functions

* Audio_M64ReadU8

* Audio_M64ReadS16

* Audio_M64ReadCompressedU16

* Audio_AudioListPopBack

* Audio_AudioListPushBack

* Audio_InitLayerFreelist

* Audio_SequencePlayerDisableAsFinished

* incomplete Audio_SequencePlayerDisable

* Audio_SequenceChannelEnable

* Audio_SequencePlayerDisableChannels

* Audio_SequencePlayerInitChannels

* struct fixes

* func_800E9ED8

* Name more functions

* Audio_SequenceChannelSetVolume

* Audio_SetInstrument

* Audio_GetInstrument

* confirm structs

* Audio_ResetSequencePlayer

* Audio_InitSequencePlayer

* Audio_InitSequencePlayers

* func_800EC734

* Find the right Audio_SoundAlloc

* Prune functions.h

* Move global vars into gAudioContext

* func_800EAEF4

* Audio_SeqChannelLayerProcessScript

* Audio_HandleScriptFlowControl

* func_800E9F64

* func_800EA0C0

* func_800EA440

* func_800EAAE0

* unbreak audio_effects

* Audio_ProcessSequence

* Audio_ProcessSequences

* Some audio_heap struct work and function naming

* Audio_SequencePlayerDisable

* ? instead of ! in z64audio.h

* Revert makefile change

* Formatting, player -> seqPlayerIndex

* Index -> Idx

Co-authored-by: zelda2774 <zelda2774@invalid>
This commit is contained in:
zelda2774 2020-09-01 23:23:30 +02:00 committed by GitHub
parent b8da64ee01
commit c033b4b28e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
137 changed files with 2447 additions and 4327 deletions

View file

@ -29,7 +29,7 @@ void Audio_SequenceChannelProcessSound(SequenceChannel* seqChannel, s32 recalcul
if (layer != NULL && layer->enabled && layer->note != NULL) {
if (layer->notePropertiesNeedInit) {
layer->noteFreqScale = layer->freqScale * chanFreqScale;
layer->noteVelocity = layer->velocitySquare * seqChannel->appliedVolume;
layer->noteVelocity = layer->velocitySquare2 * seqChannel->appliedVolume;
layer->notePan = (seqChannel->pan + layer->pan * (0x80 - seqChannel->panChannelWeight)) >> 7;
layer->notePropertiesNeedInit = 0;
} else {
@ -37,7 +37,7 @@ void Audio_SequenceChannelProcessSound(SequenceChannel* seqChannel, s32 recalcul
layer->noteFreqScale = layer->freqScale * chanFreqScale;
}
if (seqChannel->changes.s.volume || recalculateVolume) {
layer->noteVelocity = layer->velocitySquare * seqChannel->appliedVolume;
layer->noteVelocity = layer->velocitySquare2 * seqChannel->appliedVolume;
}
if (seqChannel->changes.s.pan) {
layer->notePan = (seqChannel->pan + layer->pan * (0x80 - seqChannel->panChannelWeight)) >> 7;
@ -258,7 +258,7 @@ f32 Audio_AdsrUpdate(AdsrState* adsr) {
break;
default:
adsr->delay *= D_801719EC;
adsr->delay *= gAudioContext.unk_286C;
if (adsr->delay == 0) {
adsr->delay = 1;
}

View file

@ -19,35 +19,35 @@
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE2B0.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/Audio_SoundAlloc.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/Audio_AllocDmaMemory.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE344.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE380.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/Audio_AllocZeroed.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE3DC.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/Audio_Alloc.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE434.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/Audio_SoundAllocPoolInit.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE45C.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/Audio_PersistentPoolClear.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE470.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/Audio_TemporaryPoolClear.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE4A0.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE4B0.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE5F0.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/Audio_InitMainPools.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE650.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/Audio_SessionPoolsInit.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE6D4.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/Audio_SeqAndBankPoolInit.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE758.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/Audio_PersistentPoolsInit.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE81C.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/Audio_TemporaryPoolsInit.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE8E0.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/Audio_AllocBankOrSeq.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DF074.s")

View file

@ -31,7 +31,7 @@ void Audio_NoteSetVelPanReverb(Note* note, NoteSubEu* sub, Reverb* reverb) {
sub->bitField0.s.stereoStrongLeft = 0;
sub->bitField0.s.stereoHeadsetEffects = sp24.stereoHeadsetEffects;
sub->bitField0.s.usesHeadsetPanEffects = sp24.usesHeadsetPanEffects;
if (stereoHeadsetEffects && gSoundMode == 1) {
if (stereoHeadsetEffects && gAudioContext.gSoundMode == 1) {
smallPanIndex = pan >> 1;
if (smallPanIndex > 0x3f) {
smallPanIndex = 0x3f;
@ -43,7 +43,7 @@ void Audio_NoteSetVelPanReverb(Note* note, NoteSubEu* sub, Reverb* reverb) {
volLeft = gHeadsetPanVolume[pan];
volRight = gHeadsetPanVolume[0x7f - pan];
} else if (stereoHeadsetEffects && gSoundMode == 0) {
} else if (stereoHeadsetEffects && gAudioContext.gSoundMode == 0) {
strongLeft = strongRight = 0;
sub->headsetPanRight = 0;
sub->headsetPanLeft = 0;
@ -77,7 +77,7 @@ void Audio_NoteSetVelPanReverb(Note* note, NoteSubEu* sub, Reverb* reverb) {
break;
}
} else if (gSoundMode == 3) {
} else if (gAudioContext.gSoundMode == 3) {
sub->bitField0.s.stereoHeadsetEffects = 0;
sub->bitField0.s.usesHeadsetPanEffects = 0;
volLeft = 0.707f;
@ -229,7 +229,7 @@ void Audio_ProcessNotes(void) {
}
} else {
if (playbackState->parentLayer != NO_LAYER) {
playbackState->parentLayer->ignoreDrumPan = 1; // wrong field name
playbackState->parentLayer->bit1 = 1;
}
Audio_NoteDisable(note);
Audio_AudioListRemove(&note->listItem);
@ -239,7 +239,7 @@ void Audio_ProcessNotes(void) {
}
} else if (playbackState->adsr.action.s.state == ADSR_STATE_DISABLED) {
if (playbackState->parentLayer != NO_LAYER) {
playbackState->parentLayer->ignoreDrumPan = 1; // wrong field name
playbackState->parentLayer->bit1 = 1;
}
Audio_NoteDisable(note);
Audio_AudioListRemove(&note->listItem);
@ -315,7 +315,7 @@ Instrument* Audio_GetInstrumentInner(s32 bankId, s32 instId) {
return NULL;
}
if (func_800E18B0(bankId) == 0) {
if (!Audio_IsBankLoadComplete(bankId)) {
gAudioContext.gAudioErrorFlags = bankId + 0x10000000;
return NULL;
}
@ -341,7 +341,7 @@ Drum* Audio_GetDrum(s32 bankId, s32 drumId) {
return NULL;
}
if (func_800E18B0(bankId) == 0) {
if (!Audio_IsBankLoadComplete(bankId)) {
gAudioContext.gAudioErrorFlags = bankId + 0x10000000;
return NULL;
}
@ -369,7 +369,7 @@ UnkInstrument* Audio_GetUnkInstrument(s32 bankId, s32 unkInstrumentId) {
return NULL;
}
if (func_800E18B0(bankId) == 0) {
if (!Audio_IsBankLoadComplete(bankId)) {
gAudioContext.gAudioErrorFlags = bankId + 0x10000000;
return NULL;
}
@ -401,27 +401,27 @@ s32 func_800E7744(s32 instrument, s32 bankId, s32 instId, UnkInstrument* arg3) {
return -1;
}
if (func_800E18B0(bankId) == 0) {
if (!Audio_IsBankLoadComplete(bankId)) {
return -2;
}
switch (instrument) {
case 0:
if (instId >= (gAudioContext.gCtlEntries[bankId].numDrums)) {
if (instId >= gAudioContext.gCtlEntries[bankId].numDrums) {
return -3;
}
gAudioContext.gCtlEntries[bankId].drums[instId] = (void*)arg3;
break;
case 1:
if (instId >= (gAudioContext.gCtlEntries[bankId].numUnkInstruments)) {
if (instId >= gAudioContext.gCtlEntries[bankId].numUnkInstruments) {
return -3;
}
gAudioContext.gCtlEntries[bankId].unkInstruments[instId] = *arg3;
break;
default:
if (instId >= (gAudioContext.gCtlEntries[bankId].numInstruments)) {
if (instId >= gAudioContext.gCtlEntries[bankId].numInstruments) {
return -3;
}
gAudioContext.gCtlEntries[bankId].instruments[instId] = (void*)arg3;
@ -441,7 +441,7 @@ void Audio_SeqChanLayerDecayRelease(SequenceChannelLayer* seqLayer, s32 target)
return;
}
seqLayer->unusedEu0b8 = 0;
seqLayer->bit3 = 0;
if (seqLayer->note == NULL) {
return;
@ -508,9 +508,9 @@ void Audio_SeqChanLayerDecayRelease(SequenceChannelLayer* seqLayer, s32 target)
note->playbackState.unk_04 = 1;
note->playbackState.adsr.action.s.decay = 1;
if (seqLayer->adsr.releaseRate == 0) {
note->playbackState.adsr.fadeOutVel = D_801726A0[seqLayer->seqChannel->adsr.releaseRate];
note->playbackState.adsr.fadeOutVel = gAudioContext.unk_3520[seqLayer->seqChannel->adsr.releaseRate];
} else {
note->playbackState.adsr.fadeOutVel = D_801726A0[seqLayer->adsr.releaseRate];
note->playbackState.adsr.fadeOutVel = gAudioContext.unk_3520[seqLayer->adsr.releaseRate];
}
note->playbackState.adsr.sustain =
((f32)(s32)(seqLayer->seqChannel->adsr.sustain) * note->playbackState.adsr.current) / 256.0f;
@ -754,7 +754,7 @@ void Audio_NoteInitForLayer(Note* note, SequenceChannelLayer* seqLayer) {
note->playbackState.parentLayer = seqLayer;
playback->priority = seqLayer->seqChannel->notePriority;
seqLayer->notePropertiesNeedInit = 1;
seqLayer->unusedEu0b8 = 1;
seqLayer->bit3 = 1;
seqLayer->note = note;
seqLayer->seqChannel->noteUnused = note;
seqLayer->seqChannel->layerUnused = seqLayer;
@ -906,7 +906,7 @@ Note* Audio_AllocNote(SequenceChannelLayer* seqLayer) {
return ret;
null_return:
seqLayer->unusedEu0b8 = 1;
seqLayer->bit3 = 1;
return NULL;
}
@ -931,6 +931,6 @@ void Audio_NoteInitAll(void) {
note->portamento.speed = 0;
note->playbackState.stereoHeadsetEffects = 0;
note->unk_BC = 0;
note->synthesisState.synthesisBuffers = Audio_SoundAlloc(&gAudioContext.gNotesAndBuffersPool, 0x1E0);
note->synthesisState.synthesisBuffers = Audio_AllocDmaMemory(&gAudioContext.gNotesAndBuffersPool, 0x1E0);
}
}

File diff suppressed because it is too large Load diff

View file

@ -9,15 +9,15 @@
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E11F0/func_800E1618.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E11F0/func_800E18B0.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E11F0/Audio_IsBankLoadComplete.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E11F0/func_800E1928.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E11F0/Audio_IsSeqLoadComplete.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E11F0/func_800E19A0.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E11F0/func_800E1A18.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E11F0/Audio_SetBankLoadStatus.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E11F0/func_800E1A48.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E11F0/Audio_SetSeqLoadStatus.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E11F0/func_800E1A78.s")