mirror of
https://github.com/zeldaret/mm.git
synced 2026-06-28 02:13:03 -04:00
[Audio 6/?] Build Soundfonts and the Soundfont Table (#1675)
* [Audio 6/?] Build Soundfonts and the Soundfont Table * Fix bss * Maybe fix warnings * Improve lots of error messages * Suggested changes from OoT PR * Suggested changes * Make soundfont_table.h generation depend on the samplebank xmls since they are read, report from which soundfont the invalid pointer indirect warning originates from
This commit is contained in:
@@ -1694,9 +1694,9 @@ void AudioHeap_InitReverb(s32 reverbIndex, ReverbSettings* settings, s32 isFirst
|
||||
reverb->sample.medium = MEDIUM_RAM;
|
||||
reverb->sample.size = reverb->delayNumSamples * SAMPLE_SIZE;
|
||||
reverb->sample.sampleAddr = (u8*)reverb->leftReverbBuf;
|
||||
reverb->loop.start = 0;
|
||||
reverb->loop.count = 1;
|
||||
reverb->loop.loopEnd = reverb->delayNumSamples;
|
||||
reverb->loop.header.start = 0;
|
||||
reverb->loop.header.count = 1;
|
||||
reverb->loop.header.loopEnd = reverb->delayNumSamples;
|
||||
|
||||
AudioHeap_SetReverbData(reverbIndex, REVERB_DATA_TYPE_FILTER_LEFT, settings->lowPassFilterCutoffLeft, isFirstInit);
|
||||
AudioHeap_SetReverbData(reverbIndex, REVERB_DATA_TYPE_FILTER_RIGHT, settings->lowPassFilterCutoffRight,
|
||||
|
||||
@@ -1302,7 +1302,7 @@ void AudioLoad_Init(void* heap, size_t heapSize) {
|
||||
|
||||
// Connect audio tables to their tables in memory
|
||||
gAudioCtx.sequenceTable = (AudioTable*)gSequenceTable;
|
||||
gAudioCtx.soundFontTable = (AudioTable*)gSoundFontTable;
|
||||
gAudioCtx.soundFontTable = &gSoundFontTable;
|
||||
gAudioCtx.sampleBankTable = &gSampleBankTable;
|
||||
gAudioCtx.sequenceFontTable = gSequenceFontTable;
|
||||
|
||||
|
||||
@@ -861,10 +861,10 @@ void AudioPlayback_NoteInitForLayer(Note* note, SequenceLayer* layer) {
|
||||
if (noteSampleState->bitField1.isSyntheticWave) {
|
||||
AudioPlayback_BuildSyntheticWave(note, layer, instId);
|
||||
} else if (channel->startSamplePos == 1) {
|
||||
playbackState->startSamplePos = noteSampleState->tunedSample->sample->loop->start;
|
||||
playbackState->startSamplePos = noteSampleState->tunedSample->sample->loop->header.start;
|
||||
} else {
|
||||
playbackState->startSamplePos = channel->startSamplePos;
|
||||
if (playbackState->startSamplePos >= noteSampleState->tunedSample->sample->loop->loopEnd) {
|
||||
if (playbackState->startSamplePos >= noteSampleState->tunedSample->sample->loop->header.loopEnd) {
|
||||
playbackState->startSamplePos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -980,7 +980,7 @@ s32 AudioScript_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) {
|
||||
|
||||
if (layer->delay == 0) {
|
||||
if (layer->tunedSample != NULL) {
|
||||
time = layer->tunedSample->sample->loop->loopEnd;
|
||||
time = layer->tunedSample->sample->loop->header.loopEnd;
|
||||
} else {
|
||||
time = 0.0f;
|
||||
}
|
||||
|
||||
@@ -985,10 +985,10 @@ Acmd* AudioSynth_ProcessSample(s32 noteIndex, NoteSampleState* sampleState, Note
|
||||
synthState->stopLoop = true;
|
||||
}
|
||||
|
||||
if ((loopInfo->count == 2) && synthState->stopLoop) {
|
||||
sampleEndPos = loopInfo->sampleEnd;
|
||||
if ((loopInfo->header.count == 2) && synthState->stopLoop) {
|
||||
sampleEndPos = loopInfo->header.sampleEnd;
|
||||
} else {
|
||||
sampleEndPos = loopInfo->loopEnd;
|
||||
sampleEndPos = loopInfo->header.loopEnd;
|
||||
}
|
||||
|
||||
sampleAddr = sample->sampleAddr;
|
||||
@@ -1028,7 +1028,7 @@ Acmd* AudioSynth_ProcessSample(s32 noteIndex, NoteSampleState* sampleState, Note
|
||||
break;
|
||||
}
|
||||
|
||||
numEntries = SAMPLES_PER_FRAME * sample->book->order * sample->book->numPredictors;
|
||||
numEntries = SAMPLES_PER_FRAME * sample->book->header.order * sample->book->header.numPredictors;
|
||||
aLoadADPCM(cmd++, numEntries, gAudioCtx.adpcmCodeBook);
|
||||
}
|
||||
}
|
||||
@@ -1066,8 +1066,8 @@ Acmd* AudioSynth_ProcessSample(s32 noteIndex, NoteSampleState* sampleState, Note
|
||||
numSamplesInFirstFrame = numSamplesUntilEnd;
|
||||
}
|
||||
numFramesToDecode = (numSamplesToDecode + SAMPLES_PER_FRAME - 1) / SAMPLES_PER_FRAME;
|
||||
if (loopInfo->count != 0) {
|
||||
if ((loopInfo->count == 2) && synthState->stopLoop) {
|
||||
if (loopInfo->header.count != 0) {
|
||||
if ((loopInfo->header.count == 2) && synthState->stopLoop) {
|
||||
sampleFinished = true;
|
||||
} else {
|
||||
// Loop around and restart
|
||||
@@ -1293,7 +1293,7 @@ Acmd* AudioSynth_ProcessSample(s32 noteIndex, NoteSampleState* sampleState, Note
|
||||
break; // break out of the for-loop
|
||||
} else if (loopToPoint) {
|
||||
synthState->atLoopPoint = true;
|
||||
synthState->samplePosInt = loopInfo->start;
|
||||
synthState->samplePosInt = loopInfo->header.start;
|
||||
} else {
|
||||
synthState->samplePosInt += numSamplesToProcess;
|
||||
}
|
||||
|
||||
@@ -903,7 +903,7 @@ s32 AudioThread_GetSamplePos(s32 seqPlayerIndex, s32 channelIndex, s32 layerInde
|
||||
if (tunedSample == NULL) {
|
||||
return false;
|
||||
}
|
||||
*loopEnd = tunedSample->sample->loop->loopEnd;
|
||||
*loopEnd = tunedSample->sample->loop->header.loopEnd;
|
||||
*samplePosInt = note->synthesisState.samplePosInt;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
#include "attributes.h"
|
||||
#include "z64audio.h"
|
||||
|
||||
// Symbol definition
|
||||
|
||||
extern AudioTable gSoundFontTable;
|
||||
#pragma weak gSoundFontTable = sSoundFontTableHeader
|
||||
|
||||
// Externs for table
|
||||
|
||||
#define DEFINE_SOUNDFONT(name, medium, cachePolicy, sampleBankNormal, sampleBankDD, nInstruments, nDrums, nSfx) \
|
||||
extern u8 name##_Start[]; \
|
||||
extern u8 name##_Size[];
|
||||
|
||||
#include "assets/audio/soundfont_table.h"
|
||||
|
||||
#undef DEFINE_SOUNDFONT
|
||||
|
||||
// Table header
|
||||
|
||||
NO_REORDER AudioTableHeader sSoundFontTableHeader = {
|
||||
// The table contains the number of soundfonts, count them with the preprocessor
|
||||
#define DEFINE_SOUNDFONT(name, medium, cachePolicy, sampleBankNormal, sampleBankDD, nInstruments, nDrums, nSfx) 1 +
|
||||
|
||||
#include "assets/audio/soundfont_table.h"
|
||||
|
||||
#undef DEFINE_SOUNDFONT
|
||||
0,
|
||||
|
||||
0,
|
||||
0x00000000,
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
};
|
||||
|
||||
// Table body
|
||||
|
||||
NO_REORDER AudioTableEntry sSoundFontTableEntries[] = {
|
||||
#define DEFINE_SOUNDFONT(name, medium, cachePolicy, sampleBankNormal, sampleBankDD, nInstruments, nDrums, nSfx) \
|
||||
{ (u32)name##_Start, \
|
||||
(u32)name##_Size, \
|
||||
(medium), \
|
||||
(cachePolicy), \
|
||||
((sampleBankNormal) << 8) | (sampleBankDD), \
|
||||
((nInstruments) << 8) | (nDrums), \
|
||||
(nSfx) },
|
||||
|
||||
#include "assets/audio/soundfont_table.h"
|
||||
|
||||
#undef DEFINE_SOUNDFONT
|
||||
};
|
||||
@@ -1,4 +1,3 @@
|
||||
#include "prevent_bss_reordering.h"
|
||||
#include "global.h"
|
||||
#include "z64pause_menu.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user