1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-04 15:04:31 +00:00

audio_synthesis OK + partially documented (#920)

* Match func_800DDB64

* Match func_800DC910

* remove stack comments

* Move nop padding to ucode_disas

* Partially label audio_synthesis

To some extent copied from sm64.

* cleanup

* Reverb and ReverbBits have nothing to do with reverbs

* review

* naming

* Undo changes to permuter_settings.toml

Co-authored-by: zelda2774 <zelda2774@invalid>
This commit is contained in:
zelda2774 2021-09-01 00:53:35 +02:00 committed by GitHub
parent 430a172183
commit 4444c5ea35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 934 additions and 2123 deletions

View file

@ -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;
}
}
}
@ -898,8 +898,8 @@ void Audio_InitHeap(void) {
reverb->unk_14 = settings->unk_6 * 64;
reverb->unk_16 = settings->unk_8;
reverb->unk_18 = 0;
reverb->unk_10 = settings->unk_C;
reverb->unk_12 = settings->unk_E;
reverb->leakRtl = settings->leakRtl;
reverb->leakLtr = settings->leakLtr;
reverb->unk_05 = settings->unk_10;
reverb->unk_08 = settings->unk_12;
reverb->useReverb = 8;
@ -914,8 +914,8 @@ void Audio_InitHeap(void) {
reverb->sound.sample = &reverb->sample;
reverb->sample.loop = &reverb->loop;
reverb->sound.tuning = 1.0f;
reverb->sample.bits4 = 4;
reverb->sample.bits2 = 0;
reverb->sample.codec = 4;
reverb->sample.medium = 0;
reverb->sample.size = reverb->windowSize * 2;
reverb->sample.sampleAddr = (u8*)reverb->leftRingBuf;
reverb->loop.start = 0;
@ -939,19 +939,19 @@ void Audio_InitHeap(void) {
}
if (settings->unk_14 != 0) {
reverb->unk_278 = Audio_AllocDmaMemoryZeroed(&gAudioContext.notesAndBuffersPool, 0x40);
reverb->unk_270 = Audio_AllocDmaMemory(&gAudioContext.notesAndBuffersPool, 8 * sizeof(s16));
func_800DF5DC(reverb->unk_270, settings->unk_14);
reverb->filterLeftState = Audio_AllocDmaMemoryZeroed(&gAudioContext.notesAndBuffersPool, 0x40);
reverb->filterLeft = Audio_AllocDmaMemory(&gAudioContext.notesAndBuffersPool, 8 * sizeof(s16));
func_800DF5DC(reverb->filterLeft, settings->unk_14);
} else {
reverb->unk_270 = NULL;
reverb->filterLeft = NULL;
}
if (settings->unk_16 != 0) {
reverb->unk_27C = Audio_AllocDmaMemoryZeroed(&gAudioContext.notesAndBuffersPool, 0x40);
reverb->unk_274 = Audio_AllocDmaMemory(&gAudioContext.notesAndBuffersPool, 8 * sizeof(s16));
func_800DF5DC(reverb->unk_274, settings->unk_16);
reverb->filterRightState = Audio_AllocDmaMemoryZeroed(&gAudioContext.notesAndBuffersPool, 0x40);
reverb->filterRight = Audio_AllocDmaMemory(&gAudioContext.notesAndBuffersPool, 8 * sizeof(s16));
func_800DF5DC(reverb->filterRight, settings->unk_16);
} else {
reverb->unk_274 = NULL;
reverb->filterRight = NULL;
}
}
@ -1181,7 +1181,7 @@ void func_800E0BB4(UnkHeapEntry* entry, AudioBankSample* sample) {
if (sample != NULL) {
if (sample->sampleAddr == entry->unk_08) {
sample->sampleAddr = entry->unk_0C;
sample->bits2 = entry->unk_01;
sample->medium = entry->unk_01;
}
}
}
@ -1251,7 +1251,7 @@ void func_800E0E0C(Struct_800E0E0C* arg0, AudioBankSample* sample) {
u8* sampleAddr = sample->sampleAddr;
if (start <= sampleAddr && sampleAddr < end) {
sample->sampleAddr = sampleAddr - start + arg0->unk_4;
sample->bits2 = arg0->unk_C & 0xFF;
sample->medium = arg0->unk_C & 0xFF;
}
}
}

View file

@ -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);
@ -72,7 +72,7 @@ void func_800E11F0(void) {
gAudioContext.unk_2628 = 0;
}
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_800E12DC.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/Audio_DmaSampleData.s")
void func_800E1618(s32 arg0) {
SampleDmaReq* temp_s0;
@ -268,18 +268,18 @@ s32 func_800E1C78(AudioBankSample* sample, s32 arg1) {
void* sampleAddr;
if (sample->unk_bits25 == 1) {
if (sample->bits2 != 0) {
sampleAddr = func_800E05C4(sample->size, arg1, (void*)sample->sampleAddr, sample->bits2, 1);
if (sample->medium != 0) {
sampleAddr = func_800E05C4(sample->size, arg1, (void*)sample->sampleAddr, sample->medium, 1);
if (sampleAddr == NULL) {
return -1;
}
if (sample->bits2 == 1) {
if (sample->medium == 1) {
func_800E2BCC(sample->sampleAddr, sampleAddr, sample->size, gAudioContext.audioTable->header.unk_02);
} else {
Audio_DMAFastCopy(sample->sampleAddr, sampleAddr, sample->size, sample->bits2);
Audio_DMAFastCopy(sample->sampleAddr, sampleAddr, sample->size, sample->medium);
}
sample->bits2 = 0;
sample->medium = 0;
sample->sampleAddr = sampleAddr;
}
}
@ -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);
}
@ -1055,7 +1055,7 @@ s32 Audio_SyncLoadSample(s32 arg0, s32 arg1, u8* isDone) {
return -1;
}
if (sample->bits2 == 0) {
if (sample->medium == 0) {
*isDone = 2;
return 0;
}
@ -1067,10 +1067,10 @@ s32 Audio_SyncLoadSample(s32 arg0, s32 arg1, u8* isDone) {
syncLoad->sample = *sample;
syncLoad->isDone = isDone;
syncLoad->ramAddr = func_800E05C4(sample->size, arg0, sample->sampleAddr, sample->bits2, 0);
syncLoad->ramAddr = func_800E05C4(sample->size, arg0, sample->sampleAddr, sample->medium, 0);
if (syncLoad->ramAddr == NULL) {
if (sample->bits2 == 1 || sample->bits4 == 2) {
if (sample->medium == 1 || sample->codec == 2) {
*isDone = 0;
return -1;
} else {
@ -1083,7 +1083,7 @@ s32 Audio_SyncLoadSample(s32 arg0, s32 arg1, u8* isDone) {
syncLoad->size = ALIGN16(sample->size);
syncLoad->unk_10 = syncLoad->ramAddr;
syncLoad->devAddr = sample->sampleAddr;
syncLoad->unk_00 = sample->bits2;
syncLoad->unk_00 = sample->medium;
syncLoad->unk_01 = arg0;
syncLoad->unk_02 = arg1;
if (syncLoad->unk_00 == 1) {
@ -1136,7 +1136,7 @@ void func_800E3678(AudioSyncLoad* syncLoad) {
syncLoad->sample = *sample;
sample->sampleAddr = syncLoad->unk_10;
sample->bits2 = 0;
sample->medium = 0;
}
void Audio_ProcessSyncLoads(s32 resetStatus) {
@ -1430,14 +1430,14 @@ void Audio_SampleReloc(AudioBankSound* sound, u32 arg1, RelocInfo* arg2) {
if (sample->size != 0 && sample->unk_bits25 != 1) {
sample->loop = RELOC(sample->loop, arg1);
sample->book = RELOC(sample->book, arg1);
switch (sample->bits2) {
switch (sample->medium) {
case 0:
sample->sampleAddr = RELOC(sample->sampleAddr, arg2->unk_08);
sample->bits2 = arg2->unk_10;
sample->medium = arg2->unk_10;
break;
case 1:
sample->sampleAddr = RELOC(sample->sampleAddr, arg2->unk_0C);
sample->bits2 = arg2->unk_14;
sample->medium = arg2->unk_14;
break;
case 2:
case 3:
@ -1445,7 +1445,7 @@ void Audio_SampleReloc(AudioBankSound* sound, u32 arg1, RelocInfo* arg2) {
}
sample->unk_bits25 = 1;
if (sample->unk_bits26 && (sample->bits2 != 0)) {
if (sample->unk_bits26 && (sample->medium != 0)) {
gAudioContext.unk_B68[gAudioContext.unk_1768++] = sample;
}
}
@ -1477,10 +1477,10 @@ s32 func_800E4590(s32 resetStatus) {
if (item->isFree == false) {
sample = item->sample;
key = (u32)sample->sampleAddr + sample->size + sample->bits2;
key = (u32)sample->sampleAddr + sample->size + sample->medium;
if (key == item->endAndMediumKey) {
sample->sampleAddr = item->ramAddr;
sample->bits2 = 0;
sample->medium = 0;
}
item->isFree = true;
}
@ -1497,12 +1497,12 @@ s32 func_800E4590(s32 resetStatus) {
sample = item->sample;
unk = (sample->size >> 12) + 1;
key = (u32)sample->sampleAddr + sample->size + sample->bits2;
key = (u32)sample->sampleAddr + sample->size + sample->medium;
if (key != item->endAndMediumKey) {
item->isFree = true;
gAudioContext.unk_176C--;
} else {
Audio_InitAsyncReq((u32)sample->sampleAddr, item->ramAddr, sample->size, sample->bits2, unk,
Audio_InitAsyncReq((u32)sample->sampleAddr, item->ramAddr, sample->size, sample->medium, unk,
&gAudioContext.unk_1E78, item->encodedInfo);
break;
}
@ -1563,7 +1563,7 @@ s32 func_800E478C(s32 bankId, AudioBankSample** sampleList) {
void func_800E48C0(AudioBankSound* sound) {
AudioBankSample* sample = sound->sample;
if ((sample->size != 0) && (sample->unk_bits26) && (sample->bits2)) {
if ((sample->size != 0) && (sample->unk_bits26) && (sample->medium)) {
gAudioContext.unk_B68[gAudioContext.unk_1768++] = sample;
}
}

View file

@ -1,6 +1,6 @@
#include "global.h"
void Audio_NoteSetVelPanReverb(Note* note, NoteSubEu* sub, Reverb* reverb) {
void Audio_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* attrs) {
f32 volRight, volLeft;
s32 smallPanIndex;
u64 pad;
@ -9,20 +9,20 @@ void Audio_NoteSetVelPanReverb(Note* note, NoteSubEu* sub, Reverb* reverb) {
f32 vel;
u8 pan;
u8 reverbVol;
ReverbBitsData sp24;
StereoData sp24;
s32 stereoHeadsetEffects = note->playbackState.stereoHeadsetEffects;
vel = reverb->velocity;
pan = reverb->pan;
reverbVol = reverb->reverb;
sp24 = reverb->reverbBits.s;
vel = attrs->velocity;
pan = attrs->pan;
reverbVol = attrs->reverbVol;
sp24 = attrs->stereo.s;
sub->bitField0.s = note->noteSubEu.bitField0.s;
sub->bitField1.s = note->noteSubEu.bitField1.s;
sub->sound.samples = note->noteSubEu.sound.samples;
sub->unk_06 = note->noteSubEu.unk_06;
Audio_NoteSetResamplingRate(sub, reverb->frequency);
Audio_NoteSetResamplingRate(sub, attrs->frequency);
pan &= 0x7F;
@ -38,7 +38,7 @@ void Audio_NoteSetVelPanReverb(Note* note, NoteSubEu* sub, Reverb* reverb) {
sub->headsetPanLeft = gHeadsetPanQuantization[smallPanIndex];
sub->headsetPanRight = gHeadsetPanQuantization[0x3f - smallPanIndex];
sub->bitField1.s.hasTwoAdpcmParts = true;
sub->bitField1.s.usesHeadsetPanEffects2 = true;
volLeft = gHeadsetPanVolume[pan];
volRight = gHeadsetPanVolume[0x7f - pan];
@ -46,7 +46,7 @@ void Audio_NoteSetVelPanReverb(Note* note, NoteSubEu* sub, Reverb* reverb) {
strongLeft = strongRight = 0;
sub->headsetPanRight = 0;
sub->headsetPanLeft = 0;
sub->bitField1.s.hasTwoAdpcmParts = false;
sub->bitField1.s.usesHeadsetPanEffects2 = false;
volLeft = gStereoPanVolume[pan];
volRight = gStereoPanVolume[0x7f - pan];
@ -94,10 +94,10 @@ void Audio_NoteSetVelPanReverb(Note* note, NoteSubEu* sub, Reverb* reverb) {
sub->targetVolLeft = (s32)((vel * volLeft) * 4095.999f);
sub->targetVolRight = (s32)((vel * volRight) * 4095.999f);
sub->unk_2 = reverb->unk_1;
sub->unk_14 = reverb->unk_10;
sub->unk_07 = reverb->unk_14;
sub->unk_10 = reverb->unk_16;
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;
}
@ -105,7 +105,7 @@ void Audio_NoteSetResamplingRate(NoteSubEu* noteSubEu, f32 resamplingRateInput)
f32 resamplingRate = 0.0f;
if (resamplingRateInput < 2.0f) {
noteSubEu->bitField1.s.isSyntheticWave = false;
noteSubEu->bitField1.s.hasTwoAdpcmParts = false;
if (1.99998f < resamplingRateInput) {
resamplingRate = 1.99998f;
@ -114,7 +114,7 @@ void Audio_NoteSetResamplingRate(NoteSubEu* noteSubEu, f32 resamplingRateInput)
}
} else {
noteSubEu->bitField1.s.isSyntheticWave = true;
noteSubEu->bitField1.s.hasTwoAdpcmParts = true;
if (3.99996f < resamplingRateInput) {
resamplingRate = 1.99998f;
} else {
@ -154,12 +154,12 @@ void Audio_NoteDisable(Note* note) {
void Audio_ProcessNotes(void) {
s32 pad[2];
NoteAttributes* attributes;
NoteAttributes* attrs;
NoteSubEu* noteSubEu2;
NoteSubEu* noteSubEu;
Note* note;
NotePlaybackState* playbackState;
Reverb reverb;
NoteSubAttributes subAttrs;
u8 bookOffset;
f32 scale;
s32 i;
@ -248,47 +248,47 @@ void Audio_ProcessNotes(void) {
scale = Audio_AdsrUpdate(&playbackState->adsr);
Audio_NoteVibratoUpdate(note);
attributes = &playbackState->attributes;
attrs = &playbackState->attributes;
if (playbackState->unk_04 == 1 || playbackState->unk_04 == 2) {
reverb.frequency = attributes->freqScale;
reverb.velocity = attributes->velocity;
reverb.pan = attributes->pan;
reverb.reverb = attributes->reverb;
reverb.reverbBits = attributes->reverbBits;
reverb.unk_1 = attributes->unk_1;
reverb.unk_10 = attributes->unk_10;
reverb.unk_14 = attributes->unk_4;
reverb.unk_16 = attributes->unk_6;
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;
bookOffset = noteSubEu->bitField1.s.bookOffset;
} else {
SequenceChannelLayer* layer = playbackState->parentLayer;
SequenceChannel* channel = layer->seqChannel;
reverb.frequency = layer->noteFreqScale;
reverb.velocity = layer->noteVelocity;
reverb.pan = layer->notePan;
if (layer->reverbBits.asByte == 0) {
reverb.reverbBits = channel->reverbBits;
subAttrs.frequency = layer->noteFreqScale;
subAttrs.velocity = layer->noteVelocity;
subAttrs.pan = layer->notePan;
if (layer->stereo.asByte == 0) {
subAttrs.stereo = channel->stereo;
} else {
reverb.reverbBits = layer->reverbBits;
subAttrs.stereo = layer->stereo;
}
reverb.reverb = channel->reverb;
reverb.unk_1 = channel->unk_0C;
reverb.unk_10 = channel->unk_CC;
reverb.unk_14 = channel->unk_0F;
reverb.unk_16 = channel->unk_20;
subAttrs.reverbVol = channel->reverb;
subAttrs.unk_1 = channel->unk_0C;
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)) {
reverb.frequency = 0.0f;
reverb.velocity = 0.0f;
subAttrs.frequency = 0.0f;
subAttrs.velocity = 0.0f;
}
}
reverb.frequency *= playbackState->vibratoFreqScale * playbackState->portamentoFreqScale;
reverb.frequency *= gAudioContext.audioBufferParameters.resampleRate;
reverb.velocity *= scale;
Audio_NoteSetVelPanReverb(note, noteSubEu2, &reverb);
subAttrs.frequency *= playbackState->vibratoFreqScale * playbackState->portamentoFreqScale;
subAttrs.frequency *= gAudioContext.audioBufferParameters.resampleRate;
subAttrs.velocity *= scale;
Audio_InitNoteSub(note, noteSubEu2, &subAttrs);
noteSubEu->bitField1.s.bookOffset = bookOffset;
skip:;
}
@ -432,7 +432,7 @@ s32 func_800E7744(s32 instrument, s32 bankId, s32 instId, void* arg3) {
void Audio_SeqChanLayerDecayRelease(SequenceChannelLayer* seqLayer, s32 target) {
Note* note;
NoteAttributes* attributes;
NoteAttributes* attrs;
SequenceChannel* chan;
s32 i;
@ -447,7 +447,7 @@ void Audio_SeqChanLayerDecayRelease(SequenceChannelLayer* seqLayer, s32 target)
}
note = seqLayer->note;
attributes = &note->playbackState.attributes;
attrs = &note->playbackState.attributes;
if (note->playbackState.wantedParentLayer == seqLayer) {
note->playbackState.wantedParentLayer = NO_LAYER;
@ -463,37 +463,37 @@ void Audio_SeqChanLayerDecayRelease(SequenceChannelLayer* seqLayer, s32 target)
}
if (note->playbackState.adsr.action.s.state != ADSR_STATE_DECAY) {
attributes->freqScale = seqLayer->noteFreqScale;
attributes->velocity = seqLayer->noteVelocity;
attributes->pan = seqLayer->notePan;
attrs->freqScale = seqLayer->noteFreqScale;
attrs->velocity = seqLayer->noteVelocity;
attrs->pan = seqLayer->notePan;
if (seqLayer->seqChannel != NULL) {
chan = seqLayer->seqChannel;
attributes->reverb = chan->reverb;
attributes->unk_1 = chan->unk_0C;
attributes->unk_10 = chan->unk_CC;
attrs->reverb = chan->reverb;
attrs->unk_1 = chan->unk_0C;
attrs->filter = chan->filter;
if (attributes->unk_10 != NULL) {
if (attrs->filter != NULL) {
for (i = 0; i < 8; i++) {
attributes->unk_14[i] = attributes->unk_10[i];
attrs->filterBuf[i] = attrs->filter[i];
}
attributes->unk_10 = attributes->unk_14;
attrs->filter = attrs->filterBuf;
}
attributes->unk_6 = chan->unk_20;
attributes->unk_4 = chan->unk_0F;
attrs->unk_6 = chan->unk_20;
attrs->unk_4 = chan->unk_0F;
if (chan->seqPlayer->muted && (chan->muteBehavior & 8)) {
note->noteSubEu.bitField0.s.finished = true;
}
if (seqLayer->reverbBits.asByte == 0) {
attributes->reverbBits = chan->reverbBits;
if (seqLayer->stereo.asByte == 0) {
attrs->stereo = chan->stereo;
} else {
attributes->reverbBits = seqLayer->reverbBits;
attrs->stereo = seqLayer->stereo;
}
note->playbackState.priority = chan->someOtherPriority;
} else {
attributes->reverbBits = seqLayer->reverbBits;
attrs->stereo = seqLayer->stereo;
note->playbackState.priority = 1;
}
@ -767,12 +767,12 @@ void Audio_NoteInitForLayer(Note* note, SequenceChannelLayer* seqLayer) {
sub->sound.audioBankSound = seqLayer->sound;
if (instId >= 0x80 && instId < 0xC0) {
sub->bitField1.s.bit2 = true;
sub->bitField1.s.isSyntheticWave = true;
} else {
sub->bitField1.s.bit2 = false;
sub->bitField1.s.isSyntheticWave = false;
}
if (sub->bitField1.s.bit2) {
if (sub->bitField1.s.isSyntheticWave) {
Audio_BuildSyntheticWave(note, seqLayer, instId);
}

View file

@ -120,7 +120,7 @@ void Audio_SequenceChannelInit(SequenceChannel* seqChannel) {
seqChannel->transposition = 0;
seqChannel->largeNotes = false;
seqChannel->bookOffset = 0;
seqChannel->reverbBits.asByte = 0;
seqChannel->stereo.asByte = 0;
seqChannel->changes.asByte = 0xFF;
seqChannel->scriptState.depth = 0;
seqChannel->newPan = 0x40;
@ -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;
@ -186,7 +186,7 @@ s32 Audio_SeqChannelSetLayer(SequenceChannel* seqChannel, s32 layerIdx) {
layer->ignoreDrumPan = false;
layer->bit1 = false;
layer->notePropertiesNeedInit = false;
layer->reverbBits.asByte = 0;
layer->stereo.asByte = 0;
layer->portamento.mode = 0;
layer->scriptState.depth = 0;
layer->noteDuration = 0x80;
@ -427,8 +427,8 @@ void func_800E9ED8(SequenceChannelLayer* layer) {
}
s32 func_800E9F64(SequenceChannelLayer* layer, s32 arg1) {
if (!layer->stopSomething && layer->sound != NULL && layer->sound->sample->bits4 == 2 &&
layer->sound->sample->bits2 != 0) {
if (!layer->stopSomething && layer->sound != NULL && layer->sound->sample->codec == 2 &&
layer->sound->sample->medium != 0) {
layer->stopSomething = true;
return -1;
}
@ -587,7 +587,7 @@ s32 func_800EA0C0(SequenceChannelLayer* layer) {
break;
case 0xCD:
layer->reverbBits.asByte = Audio_M64ReadU8(state);
layer->stereo.asByte = Audio_M64ReadU8(state);
break;
case 0xCE: {
@ -1212,7 +1212,7 @@ void Audio_SequenceChannelProcessScript(SequenceChannel* channel) {
} else {
channel->stereoHeadsetEffects = false;
}
channel->reverbBits.asByte = command & 0x7F;
channel->stereo.asByte = command & 0x7F;
break;
case 0xD1:
command = (u8)parameters[0];
@ -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;

File diff suppressed because it is too large Load diff

View file

@ -18,7 +18,7 @@ typedef enum {
CHAN_UPD_VIBE_X32, // 11
CHAN_UPD_UNK_0F, // 12
CHAN_UPD_UNK_20, // 13
CHAN_UPD_REVERB_FLG // 14
CHAN_UPD_STEREO // 14
} ChannelUpdateType;
void func_800E6300(SequenceChannel* channel, AudioCmd* arg1);
@ -704,8 +704,8 @@ void func_800E6300(SequenceChannel* channel, AudioCmd* cmd) {
case CHAN_UPD_UNK_20:
channel->unk_20 = cmd->asUShort;
return;
case CHAN_UPD_REVERB_FLG:
channel->reverbBits.asByte = cmd->asUbyte;
case CHAN_UPD_STEREO:
channel->stereo.asByte = cmd->asUbyte;
return;
}
}
@ -792,10 +792,10 @@ s32 func_800E66C0(s32 arg0) {
if (temp_a2->adsr.action.s.state != 0) {
if (arg0 >= 2) {
sound = temp_a3->sound.audioBankSound;
if (sound == NULL || temp_a3->bitField1.s.bit2) {
if (sound == NULL || temp_a3->bitField1.s.isSyntheticWave) {
continue;
}
if (sound->sample->bits2 == 0) {
if (sound->sample->medium == 0) {
continue;
}
}

View file

@ -6,7 +6,7 @@ typedef struct {
f32 freqScale;
s8 reverb;
s8 panSigned;
s8 reverbFlg;
s8 stereoBits;
u8 unk_0B;
u8 unk_0C;
} unk_s1;
@ -2754,7 +2754,7 @@ void Audio_SetSoundProperties(u8 bankIdx, u8 entryIdx, u8 channelIdx) {
s8 reverb = 0;
f32 freqScale = 1.0f;
s8 panSigned = 0x40;
u8 reverbFlg = 0;
u8 stereoBits = 0;
u8 sp39 = 0;
s8 sp38 = 0;
f32 sp34;
@ -2781,17 +2781,17 @@ void Audio_SetSoundProperties(u8 bankIdx, u8 entryIdx, u8 channelIdx) {
sp34 = D_801305C4[(entry->unk_26 & 0x400) >> 10];
if (!(entry->unk_26 & 0x800)) {
if (*entry->posZ < sp34) {
reverbFlg = 0x10;
stereoBits = 0x10;
}
if ((D_8016B8B8[channelIdx].reverbFlg ^ reverbFlg) & 0x10) {
if ((D_8016B8B8[channelIdx].stereoBits ^ stereoBits) & 0x10) {
if (panSigned < 0x40) {
reverbFlg = D_8016B8B8[channelIdx].reverbFlg ^ 0x14;
stereoBits = D_8016B8B8[channelIdx].stereoBits ^ 0x14;
} else {
reverbFlg = D_8016B8B8[channelIdx].reverbFlg ^ 0x18;
stereoBits = D_8016B8B8[channelIdx].stereoBits ^ 0x18;
}
} else {
reverbFlg = D_8016B8B8[channelIdx].reverbFlg;
stereoBits = D_8016B8B8[channelIdx].stereoBits;
}
}
}
@ -2828,9 +2828,9 @@ void Audio_SetSoundProperties(u8 bankIdx, u8 entryIdx, u8 channelIdx) {
Audio_QueueCmdF32(0x4020000 | (channelIdx << 8), freqScale);
D_8016B8B8[channelIdx].freqScale = freqScale;
}
if (reverbFlg != D_8016B8B8[channelIdx].reverbFlg) {
Audio_QueueCmdS8(0xE020000 | (channelIdx << 8), reverbFlg | 0x10);
D_8016B8B8[channelIdx].reverbFlg = reverbFlg;
if (stereoBits != D_8016B8B8[channelIdx].stereoBits) {
Audio_QueueCmdS8(0xE020000 | (channelIdx << 8), stereoBits | 0x10);
D_8016B8B8[channelIdx].stereoBits = stereoBits;
}
if (sp39 != D_8016B8B8[channelIdx].unk_0B) {
// CHAN_UPD_SCRIPT_IO (slot 3)
@ -2860,7 +2860,7 @@ void func_800F3ED4(void) {
t->freqScale = 1.0f;
t->reverb = 0;
t->panSigned = 0x40;
t->reverbFlg = 0;
t->stereoBits = 0;
t->unk_0B = 0xFF;
t->unk_0C = 0xFF;
}

View file

@ -283,3 +283,8 @@ void UCodeDisas_RegisterUCode(UCodeDisas* this, s32 count, UCodeInfo* ucodeArray
void UCodeDisas_SetCurUCode(UCodeDisas* this, void* ptr) {
UCodeDisas_SetCurUCodeImpl(this, ptr);
}
// 4 bytes of nops, separating this file from audio_synthesis and padding .text
// to a 32-byte boundary. Unclear what this comes from... maybe the audio
// library was built separately and aligned to 32 bytes?
#pragma GLOBAL_ASM("asm/non_matchings/code/ucode_disas/pad_800DACB0.s")