mirror of
https://github.com/zeldaret/mm.git
synced 2026-05-28 08:24:55 -04:00
audio_seqplayer.c OK and partial docs (#833)
* Import audio_seqplayer progress from main audio branch * cleanup * Better docs * Small fix * More * Cleanup and update * PR Suggestions * PR Suggestions * mute flags
This commit is contained in:
@@ -850,11 +850,11 @@ u8 gDefaultShortNoteGateTimeTable[] = {
|
||||
229, 203, 177, 151, 139, 126, 113, 100, 87, 74, 61, 48, 36, 23, 10, 0,
|
||||
};
|
||||
|
||||
AdsrEnvelope gDefaultEnvelope[] = {
|
||||
EnvelopePoint gDefaultEnvelope[] = {
|
||||
{ 1, 32000 },
|
||||
{ 1000, 32000 },
|
||||
{ -1, 0 },
|
||||
{ 0, 0 },
|
||||
{ ADSR_HANG, 0 },
|
||||
{ ADSR_DISABLE, 0 },
|
||||
};
|
||||
|
||||
NoteSubEu gZeroNoteSub = { 0 };
|
||||
|
||||
@@ -7,7 +7,7 @@ void AudioEffects_SequenceChannelProcessSound(SequenceChannel* channel, s32 reca
|
||||
|
||||
if (channel->changes.s.volume || recalculateVolume) {
|
||||
channelVolume = channel->volume * channel->volumeScale * channel->seqPlayer->appliedFadeVolume;
|
||||
if (channel->seqPlayer->muted && (channel->muteBehavior & 0x20)) {
|
||||
if (channel->seqPlayer->muted && (channel->muteFlags & MUTE_FLAGS_SOFTEN)) {
|
||||
channelVolume = channel->seqPlayer->muteVolumeScale * channelVolume;
|
||||
}
|
||||
channel->appliedVolume = channelVolume * channelVolume;
|
||||
@@ -218,7 +218,7 @@ void AudioEffects_NotePortamentoInit(Note* note) {
|
||||
note->playbackState.portamento = note->playbackState.parentLayer->portamento;
|
||||
}
|
||||
|
||||
void AudioEffects_AdsrInit(AdsrState* adsr, AdsrEnvelope* envelope, s16* volOut) {
|
||||
void AudioEffects_AdsrInit(AdsrState* adsr, EnvelopePoint* envelope, s16* volOut) {
|
||||
adsr->action.asByte = 0;
|
||||
adsr->delay = 0;
|
||||
adsr->envelope = envelope;
|
||||
|
||||
+42
-42
@@ -21,45 +21,45 @@ f32 func_8018B0F0(f32 arg0) {
|
||||
void func_8018B10C(void) {
|
||||
s32 i;
|
||||
|
||||
gAudioContext.unk_3520[255] = func_8018B0F0(0.25f);
|
||||
gAudioContext.unk_3520[254] = func_8018B0F0(0.33f);
|
||||
gAudioContext.unk_3520[253] = func_8018B0F0(0.5f);
|
||||
gAudioContext.unk_3520[252] = func_8018B0F0(0.66f);
|
||||
gAudioContext.unk_3520[251] = func_8018B0F0(0.75f);
|
||||
gAudioContext.adsrDecayTable[255] = func_8018B0F0(0.25f);
|
||||
gAudioContext.adsrDecayTable[254] = func_8018B0F0(0.33f);
|
||||
gAudioContext.adsrDecayTable[253] = func_8018B0F0(0.5f);
|
||||
gAudioContext.adsrDecayTable[252] = func_8018B0F0(0.66f);
|
||||
gAudioContext.adsrDecayTable[251] = func_8018B0F0(0.75f);
|
||||
|
||||
for (i = 128; i < 251; i++) {
|
||||
gAudioContext.unk_3520[i] = func_8018B0F0(251 - i);
|
||||
gAudioContext.adsrDecayTable[i] = func_8018B0F0(251 - i);
|
||||
}
|
||||
|
||||
for (i = 16; i < 128; i++) {
|
||||
gAudioContext.unk_3520[i] = func_8018B0F0(4 * (143 - i));
|
||||
gAudioContext.adsrDecayTable[i] = func_8018B0F0(4 * (143 - i));
|
||||
}
|
||||
|
||||
for (i = 1; i < 16; i++) {
|
||||
gAudioContext.unk_3520[i] = func_8018B0F0(60 * (23 - i));
|
||||
gAudioContext.adsrDecayTable[i] = func_8018B0F0(60 * (23 - i));
|
||||
}
|
||||
|
||||
gAudioContext.unk_3520[0] = 0.0f;
|
||||
gAudioContext.adsrDecayTable[0] = 0.0f;
|
||||
}
|
||||
|
||||
void AudioHeap_ResetLoadStatus(void) {
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(gAudioContext.fontLoadStatus); i++) {
|
||||
if (gAudioContext.fontLoadStatus[i] != LOAD_STATUS_5) {
|
||||
gAudioContext.fontLoadStatus[i] = LOAD_STATUS_0;
|
||||
if (gAudioContext.fontLoadStatus[i] != LOAD_STATUS_PERMANENT) {
|
||||
gAudioContext.fontLoadStatus[i] = LOAD_STATUS_NOT_LOADED;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(gAudioContext.sampleFontLoadStatus); i++) {
|
||||
if (gAudioContext.sampleFontLoadStatus[i] != LOAD_STATUS_5) {
|
||||
gAudioContext.sampleFontLoadStatus[i] = LOAD_STATUS_0;
|
||||
if (gAudioContext.sampleFontLoadStatus[i] != LOAD_STATUS_PERMANENT) {
|
||||
gAudioContext.sampleFontLoadStatus[i] = LOAD_STATUS_NOT_LOADED;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(gAudioContext.seqLoadStatus); i++) {
|
||||
if (gAudioContext.seqLoadStatus[i] != LOAD_STATUS_5) {
|
||||
gAudioContext.seqLoadStatus[i] = LOAD_STATUS_0;
|
||||
if (gAudioContext.seqLoadStatus[i] != LOAD_STATUS_PERMANENT) {
|
||||
gAudioContext.seqLoadStatus[i] = LOAD_STATUS_NOT_LOADED;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -302,7 +302,7 @@ void AudioHeap_PopCache(s32 tableType) {
|
||||
AudioHeap_DiscardFont(persistent->entries[persistent->numEntries - 1].id);
|
||||
}
|
||||
|
||||
loadStatus[persistent->entries[persistent->numEntries - 1].id] = LOAD_STATUS_0;
|
||||
loadStatus[persistent->entries[persistent->numEntries - 1].id] = LOAD_STATUS_NOT_LOADED;
|
||||
persistent->numEntries--;
|
||||
}
|
||||
|
||||
@@ -409,12 +409,12 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) {
|
||||
}
|
||||
|
||||
loadStatusEntry0 =
|
||||
(temporaryCache->entries[0].id == -1) ? LOAD_STATUS_0 : loadStatus[temporaryCache->entries[0].id];
|
||||
(temporaryCache->entries[0].id == -1) ? LOAD_STATUS_NOT_LOADED : loadStatus[temporaryCache->entries[0].id];
|
||||
loadStatusEntry1 =
|
||||
(temporaryCache->entries[1].id == -1) ? LOAD_STATUS_0 : loadStatus[temporaryCache->entries[1].id];
|
||||
(temporaryCache->entries[1].id == -1) ? LOAD_STATUS_NOT_LOADED : loadStatus[temporaryCache->entries[1].id];
|
||||
|
||||
if (tableType == FONT_TABLE) {
|
||||
if (loadStatusEntry0 == LOAD_STATUS_4) {
|
||||
if (loadStatusEntry0 == LOAD_STATUS_MAYBE_DISCARDABLE) {
|
||||
for (i = 0; i < gAudioContext.numNotes; i++) {
|
||||
if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[0].id) &&
|
||||
gAudioContext.notes[i].noteSubEu.bitField0.enabled) {
|
||||
@@ -423,12 +423,12 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) {
|
||||
}
|
||||
|
||||
if (i == gAudioContext.numNotes) {
|
||||
AudioLoad_SetFontLoadStatus(temporaryCache->entries[0].id, LOAD_STATUS_3);
|
||||
loadStatusEntry0 = LOAD_STATUS_3;
|
||||
AudioLoad_SetFontLoadStatus(temporaryCache->entries[0].id, LOAD_STATUS_DISCARDABLE);
|
||||
loadStatusEntry0 = LOAD_STATUS_DISCARDABLE;
|
||||
}
|
||||
}
|
||||
|
||||
if (loadStatusEntry1 == LOAD_STATUS_4) {
|
||||
if (loadStatusEntry1 == LOAD_STATUS_MAYBE_DISCARDABLE) {
|
||||
for (i = 0; i < gAudioContext.numNotes; i++) {
|
||||
if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[1].id) &&
|
||||
gAudioContext.notes[i].noteSubEu.bitField0.enabled) {
|
||||
@@ -437,26 +437,26 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) {
|
||||
}
|
||||
|
||||
if (i == gAudioContext.numNotes) {
|
||||
AudioLoad_SetFontLoadStatus(temporaryCache->entries[1].id, LOAD_STATUS_3);
|
||||
loadStatusEntry1 = LOAD_STATUS_3;
|
||||
AudioLoad_SetFontLoadStatus(temporaryCache->entries[1].id, LOAD_STATUS_DISCARDABLE);
|
||||
loadStatusEntry1 = LOAD_STATUS_DISCARDABLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (loadStatusEntry0 == LOAD_STATUS_0) {
|
||||
if (loadStatusEntry0 == LOAD_STATUS_NOT_LOADED) {
|
||||
temporaryCache->nextSide = 0;
|
||||
} else if (loadStatusEntry1 == LOAD_STATUS_0) {
|
||||
} else if (loadStatusEntry1 == LOAD_STATUS_NOT_LOADED) {
|
||||
temporaryCache->nextSide = 1;
|
||||
} else if ((loadStatusEntry0 == LOAD_STATUS_3) && (loadStatusEntry1 == LOAD_STATUS_3)) {
|
||||
} else if ((loadStatusEntry0 == LOAD_STATUS_DISCARDABLE) && (loadStatusEntry1 == LOAD_STATUS_DISCARDABLE)) {
|
||||
// Use the opposite side from last time.
|
||||
} else if (loadStatusEntry0 == LOAD_STATUS_3) {
|
||||
} else if (loadStatusEntry0 == LOAD_STATUS_DISCARDABLE) {
|
||||
temporaryCache->nextSide = 0;
|
||||
} else if (loadStatusEntry1 == LOAD_STATUS_3) {
|
||||
} else if (loadStatusEntry1 == LOAD_STATUS_DISCARDABLE) {
|
||||
temporaryCache->nextSide = 1;
|
||||
} else {
|
||||
// Check if there is a side which isn't in active use, if so, evict that one.
|
||||
if (tableType == SEQUENCE_TABLE) {
|
||||
if (loadStatusEntry0 == LOAD_STATUS_2) {
|
||||
if (loadStatusEntry0 == LOAD_STATUS_COMPLETE) {
|
||||
for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) {
|
||||
if (gAudioContext.seqPlayers[i].enabled &&
|
||||
gAudioContext.seqPlayers[i].seqId == temporaryCache->entries[0].id) {
|
||||
@@ -470,7 +470,7 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) {
|
||||
}
|
||||
}
|
||||
|
||||
if (loadStatusEntry1 == LOAD_STATUS_2) {
|
||||
if (loadStatusEntry1 == LOAD_STATUS_COMPLETE) {
|
||||
for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) {
|
||||
if (gAudioContext.seqPlayers[i].enabled &&
|
||||
gAudioContext.seqPlayers[i].seqId == temporaryCache->entries[1].id) {
|
||||
@@ -484,7 +484,7 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) {
|
||||
}
|
||||
}
|
||||
} else if (tableType == FONT_TABLE) {
|
||||
if (loadStatusEntry0 == LOAD_STATUS_2) {
|
||||
if (loadStatusEntry0 == LOAD_STATUS_COMPLETE) {
|
||||
for (i = 0; i < gAudioContext.numNotes; i++) {
|
||||
if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[0].id) &&
|
||||
gAudioContext.notes[i].noteSubEu.bitField0.enabled) {
|
||||
@@ -497,7 +497,7 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) {
|
||||
}
|
||||
}
|
||||
|
||||
if (loadStatusEntry1 == LOAD_STATUS_2) {
|
||||
if (loadStatusEntry1 == LOAD_STATUS_COMPLETE) {
|
||||
for (i = 0; i < gAudioContext.numNotes; i++) {
|
||||
if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[1].id) &&
|
||||
gAudioContext.notes[i].noteSubEu.bitField0.enabled) {
|
||||
@@ -514,15 +514,15 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) {
|
||||
// No such luck. Evict the side that wasn't chosen last time, except
|
||||
// if it is being loaded into.
|
||||
if (temporaryCache->nextSide == 0) {
|
||||
if (loadStatusEntry0 == LOAD_STATUS_1) {
|
||||
if (loadStatusEntry1 == LOAD_STATUS_1) {
|
||||
if (loadStatusEntry0 == LOAD_STATUS_IN_PROGRESS) {
|
||||
if (loadStatusEntry1 == LOAD_STATUS_IN_PROGRESS) {
|
||||
goto fail;
|
||||
}
|
||||
temporaryCache->nextSide = 1;
|
||||
}
|
||||
} else {
|
||||
if (loadStatusEntry1 == LOAD_STATUS_1) {
|
||||
if (loadStatusEntry0 == LOAD_STATUS_1) {
|
||||
if (loadStatusEntry1 == LOAD_STATUS_IN_PROGRESS) {
|
||||
if (loadStatusEntry0 == LOAD_STATUS_IN_PROGRESS) {
|
||||
goto fail;
|
||||
}
|
||||
temporaryCache->nextSide = 0;
|
||||
@@ -544,7 +544,7 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) {
|
||||
AudioHeap_DiscardSampleBank(temporaryCache->entries[side].id);
|
||||
}
|
||||
|
||||
loadStatus[temporaryCache->entries[side].id] = LOAD_STATUS_0;
|
||||
loadStatus[temporaryCache->entries[side].id] = LOAD_STATUS_NOT_LOADED;
|
||||
|
||||
if (tableType == FONT_TABLE) {
|
||||
AudioHeap_DiscardFont(temporaryCache->entries[side].id);
|
||||
@@ -564,7 +564,7 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) {
|
||||
AudioHeap_DiscardSampleBank(temporaryCache->entries[1].id);
|
||||
}
|
||||
|
||||
loadStatus[temporaryCache->entries[1].id] = LOAD_STATUS_0;
|
||||
loadStatus[temporaryCache->entries[1].id] = LOAD_STATUS_NOT_LOADED;
|
||||
|
||||
switch (tableType) {
|
||||
case SEQUENCE_TABLE:
|
||||
@@ -594,7 +594,7 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) {
|
||||
AudioHeap_DiscardSampleBank(temporaryCache->entries[0].id);
|
||||
}
|
||||
|
||||
loadStatus[temporaryCache->entries[0].id] = LOAD_STATUS_0;
|
||||
loadStatus[temporaryCache->entries[0].id] = LOAD_STATUS_NOT_LOADED;
|
||||
|
||||
switch (tableType) {
|
||||
case SEQUENCE_TABLE:
|
||||
@@ -1042,8 +1042,8 @@ void AudioHeap_Init(void) {
|
||||
AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.miscPool, gAudioContext.maxAudioCmds * sizeof(u64));
|
||||
}
|
||||
|
||||
// Initialize unk_3520 (fadeOutVelocities for ADSR)
|
||||
gAudioContext.unk_3520 = AudioHeap_Alloc(&gAudioContext.miscPool, 0x100 * sizeof(f32));
|
||||
// Initialize adsrDecayTable (fadeOutVelocities for ADSR)
|
||||
gAudioContext.adsrDecayTable = AudioHeap_Alloc(&gAudioContext.miscPool, 0x100 * sizeof(f32));
|
||||
func_8018B10C();
|
||||
|
||||
// Initialize reverbs
|
||||
|
||||
+38
-37
@@ -29,7 +29,7 @@ typedef struct {
|
||||
} AudioRelocInfo; // size = 0x18
|
||||
|
||||
void AudioLoad_DiscardFont(s32 fontId);
|
||||
s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2);
|
||||
s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIndex, s32 seqId, s32 arg2);
|
||||
u8* AudioLoad_SyncLoadSeq(s32 seqId);
|
||||
u32 AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad);
|
||||
SoundFontData* AudioLoad_SyncLoadFont(u32 fontId);
|
||||
@@ -301,9 +301,9 @@ void AudioLoad_InitSampleDmaBuffers(s32 numNotes) {
|
||||
s32 AudioLoad_IsFontLoadComplete(s32 fontId) {
|
||||
if (fontId == 0xFF) {
|
||||
return true;
|
||||
} else if (gAudioContext.fontLoadStatus[fontId] >= LOAD_STATUS_2) {
|
||||
} else if (gAudioContext.fontLoadStatus[fontId] >= LOAD_STATUS_COMPLETE) {
|
||||
return true;
|
||||
} else if (gAudioContext.fontLoadStatus[AudioLoad_GetRealTableIndex(FONT_TABLE, fontId)] >= LOAD_STATUS_2) {
|
||||
} else if (gAudioContext.fontLoadStatus[AudioLoad_GetRealTableIndex(FONT_TABLE, fontId)] >= LOAD_STATUS_COMPLETE) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -313,9 +313,10 @@ s32 AudioLoad_IsFontLoadComplete(s32 fontId) {
|
||||
s32 AudioLoad_IsSeqLoadComplete(s32 seqId) {
|
||||
if (seqId == 0xFF) {
|
||||
return true;
|
||||
} else if (gAudioContext.seqLoadStatus[seqId] >= LOAD_STATUS_2) {
|
||||
} else if (gAudioContext.seqLoadStatus[seqId] >= LOAD_STATUS_COMPLETE) {
|
||||
return true;
|
||||
} else if (gAudioContext.seqLoadStatus[AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId)] >= LOAD_STATUS_2) {
|
||||
} else if (gAudioContext.seqLoadStatus[AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId)] >=
|
||||
LOAD_STATUS_COMPLETE) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -325,10 +326,10 @@ s32 AudioLoad_IsSeqLoadComplete(s32 seqId) {
|
||||
s32 AudioLoad_IsSampleLoadComplete(s32 sampleBankId) {
|
||||
if (sampleBankId == 0xFF) {
|
||||
return true;
|
||||
} else if (gAudioContext.sampleFontLoadStatus[sampleBankId] >= LOAD_STATUS_2) {
|
||||
} else if (gAudioContext.sampleFontLoadStatus[sampleBankId] >= LOAD_STATUS_COMPLETE) {
|
||||
return true;
|
||||
} else if (gAudioContext.sampleFontLoadStatus[AudioLoad_GetRealTableIndex(SAMPLE_TABLE, sampleBankId)] >=
|
||||
LOAD_STATUS_2) {
|
||||
LOAD_STATUS_COMPLETE) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -336,32 +337,32 @@ s32 AudioLoad_IsSampleLoadComplete(s32 sampleBankId) {
|
||||
}
|
||||
|
||||
void AudioLoad_SetFontLoadStatus(s32 fontId, s32 loadStatus) {
|
||||
if ((fontId != 0xFF) && (gAudioContext.fontLoadStatus[fontId] != LOAD_STATUS_5)) {
|
||||
if ((fontId != 0xFF) && (gAudioContext.fontLoadStatus[fontId] != LOAD_STATUS_PERMANENT)) {
|
||||
gAudioContext.fontLoadStatus[fontId] = loadStatus;
|
||||
}
|
||||
}
|
||||
|
||||
void AudioLoad_SetSeqLoadStatus(s32 seqId, s32 loadStatus) {
|
||||
if ((seqId != 0xFF) && (gAudioContext.seqLoadStatus[seqId] != LOAD_STATUS_5)) {
|
||||
if ((seqId != 0xFF) && (gAudioContext.seqLoadStatus[seqId] != LOAD_STATUS_PERMANENT)) {
|
||||
gAudioContext.seqLoadStatus[seqId] = loadStatus;
|
||||
}
|
||||
}
|
||||
|
||||
void AudioLoad_SetSampleFontLoadStatusAndApplyCaches(s32 sampleBankId, s32 loadStatus) {
|
||||
if (sampleBankId != 0xFF) {
|
||||
if (gAudioContext.sampleFontLoadStatus[sampleBankId] != LOAD_STATUS_5) {
|
||||
if (gAudioContext.sampleFontLoadStatus[sampleBankId] != LOAD_STATUS_PERMANENT) {
|
||||
gAudioContext.sampleFontLoadStatus[sampleBankId] = loadStatus;
|
||||
}
|
||||
|
||||
if ((gAudioContext.sampleFontLoadStatus[sampleBankId] == LOAD_STATUS_5) ||
|
||||
(gAudioContext.sampleFontLoadStatus[sampleBankId] == LOAD_STATUS_2)) {
|
||||
if ((gAudioContext.sampleFontLoadStatus[sampleBankId] == LOAD_STATUS_PERMANENT) ||
|
||||
(gAudioContext.sampleFontLoadStatus[sampleBankId] == LOAD_STATUS_COMPLETE)) {
|
||||
AudioHeap_ApplySampleBankCache(sampleBankId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AudioLoad_SetSampleFontLoadStatus(s32 sampleBankId, s32 loadStatus) {
|
||||
if ((sampleBankId != 0xFF) && (gAudioContext.sampleFontLoadStatus[sampleBankId] != LOAD_STATUS_5)) {
|
||||
if ((sampleBankId != 0xFF) && (gAudioContext.sampleFontLoadStatus[sampleBankId] != LOAD_STATUS_PERMANENT)) {
|
||||
gAudioContext.sampleFontLoadStatus[sampleBankId] = loadStatus;
|
||||
}
|
||||
}
|
||||
@@ -510,7 +511,7 @@ void AudioLoad_DiscardSeqFonts(s32 seqId) {
|
||||
fontId = AudioLoad_GetRealTableIndex(FONT_TABLE, gAudioContext.sequenceFontTable[index++]);
|
||||
if (AudioHeap_SearchPermanentCache(FONT_TABLE, fontId) == NULL) {
|
||||
AudioLoad_DiscardFont(fontId);
|
||||
AudioLoad_SetFontLoadStatus(fontId, LOAD_STATUS_0);
|
||||
AudioLoad_SetFontLoadStatus(fontId, LOAD_STATUS_NOT_LOADED);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -553,31 +554,31 @@ void func_8018FA60(u32 tableType, u32 id, s32 type, s32 data) {
|
||||
}
|
||||
}
|
||||
|
||||
s32 AudioLoad_SyncInitSeqPlayer(s32 playerIdx, s32 seqId, s32 arg2) {
|
||||
s32 AudioLoad_SyncInitSeqPlayer(s32 playerIndex, s32 seqId, s32 arg2) {
|
||||
if (gAudioContext.resetTimer != 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
gAudioContext.seqPlayers[playerIdx].skipTicks = 0;
|
||||
AudioLoad_SyncInitSeqPlayerInternal(playerIdx, seqId, arg2);
|
||||
gAudioContext.seqPlayers[playerIndex].skipTicks = 0;
|
||||
AudioLoad_SyncInitSeqPlayerInternal(playerIndex, seqId, arg2);
|
||||
// Intentionally missing return. Returning the result of the above function
|
||||
// call matches but is UB because it too is missing a return, and using the
|
||||
// result of a non-void function that has failed to return a value is UB.
|
||||
// The callers of this function do not use the return value, so it's fine.
|
||||
}
|
||||
|
||||
s32 AudioLoad_SyncInitSeqPlayerSkipTicks(s32 playerIdx, s32 seqId, s32 skipTicks) {
|
||||
s32 AudioLoad_SyncInitSeqPlayerSkipTicks(s32 playerIndex, s32 seqId, s32 skipTicks) {
|
||||
if (gAudioContext.resetTimer != 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
gAudioContext.seqPlayers[playerIdx].skipTicks = skipTicks;
|
||||
AudioLoad_SyncInitSeqPlayerInternal(playerIdx, seqId, 0);
|
||||
gAudioContext.seqPlayers[playerIndex].skipTicks = skipTicks;
|
||||
AudioLoad_SyncInitSeqPlayerInternal(playerIndex, seqId, 0);
|
||||
// Missing return, see above.
|
||||
}
|
||||
|
||||
s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2) {
|
||||
SequencePlayer* seqPlayer = &gAudioContext.seqPlayers[playerIdx];
|
||||
s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIndex, s32 seqId, s32 arg2) {
|
||||
SequencePlayer* seqPlayer = &gAudioContext.seqPlayers[playerIndex];
|
||||
u8* seqData;
|
||||
s32 index;
|
||||
s32 numFonts;
|
||||
@@ -620,7 +621,7 @@ s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2) {
|
||||
seqPlayer->scriptState.depth = 0;
|
||||
seqPlayer->delay = 0;
|
||||
seqPlayer->finished = false;
|
||||
seqPlayer->playerIdx = playerIdx;
|
||||
seqPlayer->playerIndex = playerIndex;
|
||||
//! @bug missing return (but the return value is not used so it's not UB)
|
||||
}
|
||||
|
||||
@@ -628,7 +629,7 @@ u8* AudioLoad_SyncLoadSeq(s32 seqId) {
|
||||
s32 pad;
|
||||
s32 didAllocate;
|
||||
|
||||
if (gAudioContext.seqLoadStatus[AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId)] == LOAD_STATUS_1) {
|
||||
if (gAudioContext.seqLoadStatus[AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId)] == LOAD_STATUS_IN_PROGRESS) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -649,8 +650,8 @@ u32 AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad
|
||||
|
||||
addr = AudioLoad_SearchCaches(SAMPLE_TABLE, realTableId);
|
||||
if (addr != NULL) {
|
||||
if (gAudioContext.sampleFontLoadStatus[realTableId] != LOAD_STATUS_1) {
|
||||
AudioLoad_SetSampleFontLoadStatus(realTableId, LOAD_STATUS_2);
|
||||
if (gAudioContext.sampleFontLoadStatus[realTableId] != LOAD_STATUS_IN_PROGRESS) {
|
||||
AudioLoad_SetSampleFontLoadStatus(realTableId, LOAD_STATUS_COMPLETE);
|
||||
}
|
||||
|
||||
*outMedium = MEDIUM_RAM;
|
||||
@@ -682,7 +683,7 @@ SoundFontData* AudioLoad_SyncLoadFont(u32 fontId) {
|
||||
AudioRelocInfo relocInfo;
|
||||
s32 realFontId = AudioLoad_GetRealTableIndex(FONT_TABLE, fontId);
|
||||
|
||||
if (gAudioContext.fontLoadStatus[realFontId] == LOAD_STATUS_1) {
|
||||
if (gAudioContext.fontLoadStatus[realFontId] == LOAD_STATUS_IN_PROGRESS) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -730,7 +731,7 @@ void* AudioLoad_SyncLoad(s32 tableType, u32 id, s32* didAllocate) {
|
||||
ramAddr = AudioLoad_SearchCaches(tableType, realId);
|
||||
if (ramAddr != NULL) {
|
||||
*didAllocate = false;
|
||||
loadStatus = LOAD_STATUS_2;
|
||||
loadStatus = LOAD_STATUS_COMPLETE;
|
||||
} else {
|
||||
table = AudioLoad_GetLoadTable(tableType);
|
||||
size = table->entries[realId].size;
|
||||
@@ -793,7 +794,7 @@ void* AudioLoad_SyncLoad(s32 tableType, u32 id, s32* didAllocate) {
|
||||
AudioLoad_SyncDma(romAddr, ramAddr, size, medium);
|
||||
}
|
||||
|
||||
loadStatus = (cachePolicy == CACHE_LOAD_PERMANENT) ? LOAD_STATUS_5 : LOAD_STATUS_2;
|
||||
loadStatus = (cachePolicy == CACHE_LOAD_PERMANENT) ? LOAD_STATUS_PERMANENT : LOAD_STATUS_COMPLETE;
|
||||
}
|
||||
|
||||
switch (tableType) {
|
||||
@@ -1032,19 +1033,19 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData,
|
||||
|
||||
switch (tableType) {
|
||||
case SEQUENCE_TABLE:
|
||||
if (gAudioContext.seqLoadStatus[realId] == LOAD_STATUS_1) {
|
||||
if (gAudioContext.seqLoadStatus[realId] == LOAD_STATUS_IN_PROGRESS) {
|
||||
return NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case FONT_TABLE:
|
||||
if (gAudioContext.fontLoadStatus[realId] == LOAD_STATUS_1) {
|
||||
if (gAudioContext.fontLoadStatus[realId] == LOAD_STATUS_IN_PROGRESS) {
|
||||
return NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case SAMPLE_TABLE:
|
||||
if (gAudioContext.sampleFontLoadStatus[realId] == LOAD_STATUS_1) {
|
||||
if (gAudioContext.sampleFontLoadStatus[realId] == LOAD_STATUS_IN_PROGRESS) {
|
||||
return NULL;
|
||||
}
|
||||
break;
|
||||
@@ -1052,8 +1053,8 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData,
|
||||
|
||||
ramAddr = AudioLoad_SearchCaches(tableType, realId);
|
||||
if (ramAddr != NULL) {
|
||||
loadStatus = LOAD_STATUS_2;
|
||||
osSendMesg(retQueue, MK_ASYNC_MSG(retData, 0, 0, LOAD_STATUS_0), OS_MESG_NOBLOCK);
|
||||
loadStatus = LOAD_STATUS_COMPLETE;
|
||||
osSendMesg(retQueue, MK_ASYNC_MSG(retData, 0, 0, LOAD_STATUS_NOT_LOADED), OS_MESG_NOBLOCK);
|
||||
} else {
|
||||
table = AudioLoad_GetLoadTable(tableType);
|
||||
size = table->entries[realId].size;
|
||||
@@ -1061,7 +1062,7 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData,
|
||||
medium = table->entries[id].medium;
|
||||
cachePolicy = table->entries[id].cachePolicy;
|
||||
romAddr = table->entries[realId].romAddr;
|
||||
loadStatus = LOAD_STATUS_2;
|
||||
loadStatus = LOAD_STATUS_COMPLETE;
|
||||
|
||||
switch (cachePolicy) {
|
||||
case CACHE_LOAD_PERMANENT:
|
||||
@@ -1069,7 +1070,7 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData,
|
||||
if (ramAddr == NULL) {
|
||||
return ramAddr;
|
||||
}
|
||||
loadStatus = LOAD_STATUS_5;
|
||||
loadStatus = LOAD_STATUS_PERMANENT;
|
||||
break;
|
||||
|
||||
case CACHE_LOAD_PERSISTENT:
|
||||
@@ -1119,7 +1120,7 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData,
|
||||
MK_ASYNC_MSG(retData, tableType, realId, loadStatus));
|
||||
}
|
||||
|
||||
loadStatus = LOAD_STATUS_1;
|
||||
loadStatus = LOAD_STATUS_IN_PROGRESS;
|
||||
}
|
||||
|
||||
switch (tableType) {
|
||||
|
||||
@@ -98,7 +98,7 @@ void AudioPlayback_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* at
|
||||
sub->targetVolLeft = (s32)((vel * volLeft) * (0x1000 - 0.001f));
|
||||
sub->targetVolRight = (s32)((vel * volRight) * (0x1000 - 0.001f));
|
||||
|
||||
sub->unk_2 = attrs->unk_1;
|
||||
sub->gain = attrs->gain;
|
||||
sub->filter = attrs->filter;
|
||||
sub->unk_07 = attrs->unk_14;
|
||||
sub->unk_0E = attrs->unk_16;
|
||||
@@ -125,7 +125,7 @@ void AudioPlayback_NoteSetResamplingRate(NoteSubEu* noteSubEu, f32 resamplingRat
|
||||
}
|
||||
|
||||
void AudioPlayback_NoteInit(Note* note) {
|
||||
if (note->playbackState.parentLayer->adsr.releaseRate == 0) {
|
||||
if (note->playbackState.parentLayer->adsr.decayIndex == 0) {
|
||||
AudioEffects_AdsrInit(¬e->playbackState.adsr, note->playbackState.parentLayer->channel->adsr.envelope,
|
||||
¬e->playbackState.adsrVolScaleUnused);
|
||||
} else {
|
||||
@@ -189,7 +189,7 @@ void AudioPlayback_ProcessNotes(void) {
|
||||
playbackState->unk_04 = 1;
|
||||
continue;
|
||||
} else if (playbackState->parentLayer->channel->seqPlayer->muted &&
|
||||
(playbackState->parentLayer->channel->muteBehavior & 0x40)) {
|
||||
(playbackState->parentLayer->channel->muteFlags & MUTE_FLAGS_STOP_NOTES)) {
|
||||
// do nothing
|
||||
} else {
|
||||
goto out;
|
||||
@@ -257,7 +257,7 @@ void AudioPlayback_ProcessNotes(void) {
|
||||
subAttrs.pan = attrs->pan;
|
||||
subAttrs.reverbVol = attrs->reverb;
|
||||
subAttrs.stereo = attrs->stereo;
|
||||
subAttrs.unk_1 = attrs->unk_1;
|
||||
subAttrs.gain = attrs->gain;
|
||||
subAttrs.filter = attrs->filter;
|
||||
subAttrs.unk_14 = attrs->unk_4;
|
||||
subAttrs.unk_16 = attrs->unk_6;
|
||||
@@ -290,9 +290,9 @@ void AudioPlayback_ProcessNotes(void) {
|
||||
}
|
||||
|
||||
if (layer->unk_0A.s.bit_9 == 1) {
|
||||
subAttrs.unk_1 = channel->unk_0C;
|
||||
subAttrs.gain = channel->gain;
|
||||
} else {
|
||||
subAttrs.unk_1 = 0;
|
||||
subAttrs.gain = 0;
|
||||
if (1) {}
|
||||
}
|
||||
|
||||
@@ -301,7 +301,7 @@ void AudioPlayback_ProcessNotes(void) {
|
||||
subAttrs.unk_16 = channel->unk_20;
|
||||
bookOffset = channel->bookOffset & 0x7;
|
||||
|
||||
if (channel->seqPlayer->muted && (channel->muteBehavior & 8)) {
|
||||
if (channel->seqPlayer->muted && (channel->muteFlags & MUTE_FLAGS_3)) {
|
||||
subAttrs.frequency = 0.0f;
|
||||
subAttrs.velocity = 0.0f;
|
||||
}
|
||||
@@ -506,9 +506,9 @@ void AudioPlayback_SeqLayerDecayRelease(SequenceLayer* layer, s32 target) {
|
||||
}
|
||||
|
||||
if (layer->unk_0A.s.bit_9 == 1) {
|
||||
attrs->unk_1 = chan->unk_0C;
|
||||
attrs->gain = chan->gain;
|
||||
} else {
|
||||
attrs->unk_1 = 0;
|
||||
attrs->gain = 0;
|
||||
}
|
||||
|
||||
attrs->filter = chan->filter;
|
||||
@@ -522,7 +522,7 @@ void AudioPlayback_SeqLayerDecayRelease(SequenceLayer* layer, s32 target) {
|
||||
|
||||
attrs->unk_6 = chan->unk_20;
|
||||
attrs->unk_4 = chan->unk_0F;
|
||||
if (chan->seqPlayer->muted && (chan->muteBehavior & 8)) {
|
||||
if (chan->seqPlayer->muted && (chan->muteFlags & MUTE_FLAGS_3)) {
|
||||
note->noteSubEu.bitField0.finished = true;
|
||||
}
|
||||
|
||||
@@ -546,10 +546,10 @@ void AudioPlayback_SeqLayerDecayRelease(SequenceLayer* layer, s32 target) {
|
||||
} 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];
|
||||
if (layer->adsr.decayIndex == 0) {
|
||||
note->playbackState.adsr.fadeOutVel = gAudioContext.adsrDecayTable[layer->channel->adsr.decayIndex];
|
||||
} else {
|
||||
note->playbackState.adsr.fadeOutVel = gAudioContext.unk_3520[layer->adsr.releaseRate];
|
||||
note->playbackState.adsr.fadeOutVel = gAudioContext.adsrDecayTable[layer->adsr.decayIndex];
|
||||
}
|
||||
note->playbackState.adsr.sustain =
|
||||
((f32)(s32)(layer->channel->adsr.sustain) * note->playbackState.adsr.current) / 256.0f;
|
||||
|
||||
+2275
-36
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user