summaryrefslogtreecommitdiff
path: root/src/audio
diff options
context:
space:
mode:
authorKiritoDv <kiritodev01@gmail.com>2024-11-17 19:41:45 -0600
committerKiritoDv <kiritodev01@gmail.com>2024-11-17 19:41:45 -0600
commit090f31cc5a9a63f11029dbc52cf434cd1a44cd24 (patch)
tree5019284098ff38a634c551096e800e1535d76e89 /src/audio
parentcfc24c205f624ba673475fc110a60eaf95510b80 (diff)
Ported some code from 2ship and documented codec macros on ProcessNote
Diffstat (limited to 'src/audio')
-rw-r--r--src/audio/audio_synthesis.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/audio/audio_synthesis.c b/src/audio/audio_synthesis.c
index 9e097358..507719a3 100644
--- a/src/audio/audio_synthesis.c
+++ b/src/audio/audio_synthesis.c
@@ -1026,27 +1026,44 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSub, NoteSynthesisSta
}
}
switch (bookSample->codec) {
- case 0:
+ case CODEC_ADPCM:
frameSize = 9;
skipInitialSamples = 0x10;
sampleDmaStart = 0;
break;
- case 1:
+ case CODEC_S8:
frameSize = 0x10;
skipInitialSamples = 0x10;
sampleDmaStart = 0;
break;
- case 2:
- temp = func_800097A8(bookSample, numSamplesToLoadAdj, flags,
- &synthState->synthesisBuffers->unk_40);
- aLoadBuffer(aList++, OS_K0_TO_PHYSICAL(temp), 0x5F0, (numSamplesToLoadAdj + 0x10) * 2);
- flags = 0;
+ case CODEC_S16_INMEMORY:
skipBytes = 0;
numSamplesProcessed = numSamplesToLoadAdj;
dmemUncompressedAddrOffset1 = numSamplesToLoadAdj;
goto skip;
+
+ case CODEC_S16:
+ skipBytes = 0;
+ numSamplesProcessed += numSamplesToLoadAdj;
+ dmemUncompressedAddrOffset1 = numSamplesToLoadAdj;
+ size_t bytesToRead;
+
+ if (((synthState->samplePosInt * 2) + (numSamplesToLoadAdj + SAMPLES_PER_FRAME) * SAMPLE_SIZE) < bookSample->size) {
+ bytesToRead = (numSamplesToLoadAdj + SAMPLES_PER_FRAME) * SAMPLE_SIZE;
+ } else {
+ bytesToRead = bookSample->size - (synthState->samplePosInt * 2);
+ }
+ // @port [Custom audio]
+ // TLDR samples are loaded async and might be null the first time they are played.
+ // See note in AudioSampleFactory.cpp
+ if (sampleAddr != NULL) {
+ aLoadBuffer(cmd++, sampleAddr + (synthState->samplePosInt * 2), DMEM_UNCOMPRESSED_NOTE,
+ bytesToRead);
+ }
+
+ goto skip;
}
aligned = ALIGN16((nFramesToDecode * frameSize) + 0x10);