2021-07-27 23:44:58 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
2021-08-12 19:37:37 +00:00
|
|
|
#define SAMPLES_TO_OVERPRODUCE 0x10
|
|
|
|
#define EXTRA_BUFFERED_AI_SAMPLES_TARGET 0x80
|
|
|
|
|
2021-07-27 23:44:58 +00:00
|
|
|
typedef enum {
|
|
|
|
CHAN_UPD_UNK_0, // 0
|
|
|
|
CHAN_UPD_VOL_SCALE, // 1
|
|
|
|
CHAN_UPD_VOL, // 2
|
|
|
|
CHAN_UPD_PAN_SIGNED, // 3
|
|
|
|
CHAN_UPD_FREQ_SCALE, // 4
|
|
|
|
CHAN_UPD_REVERB, // 5
|
|
|
|
CHAN_UPD_SCRIPT_IO, // 6
|
|
|
|
CHAN_UPD_PAN_UNSIGNED, // 7
|
|
|
|
CHAN_UPD_STOP_SOMETHING2, // 8
|
|
|
|
CHAN_UPD_MUTE_BEHAVE, // 9
|
|
|
|
CHAN_UPD_VIBE_X8, // 10
|
|
|
|
CHAN_UPD_VIBE_X32, // 11
|
|
|
|
CHAN_UPD_UNK_0F, // 12
|
|
|
|
CHAN_UPD_UNK_20, // 13
|
2021-08-31 22:53:35 +00:00
|
|
|
CHAN_UPD_STEREO // 14
|
2021-07-27 23:44:58 +00:00
|
|
|
} ChannelUpdateType;
|
|
|
|
|
|
|
|
void func_800E6300(SequenceChannel* channel, AudioCmd* arg1);
|
|
|
|
void func_800E59AC(s32 playerIdx, s32 fadeTimer);
|
|
|
|
void Audio_InitMesgQueues(void);
|
|
|
|
AudioTask* func_800E5000(void);
|
|
|
|
void Audio_ProcessCmds(u32);
|
|
|
|
void func_800E6128(SequencePlayer* seqPlayer, AudioCmd* arg1);
|
|
|
|
void func_800E5958(s32 playerIdx, s32 fadeTimer);
|
|
|
|
s32 func_800E66C0(s32 arg0);
|
|
|
|
|
|
|
|
// AudioMgr_Retrace
|
|
|
|
AudioTask* func_800E4FE0(void) {
|
|
|
|
return func_800E5000();
|
|
|
|
}
|
|
|
|
|
2021-08-12 19:37:37 +00:00
|
|
|
extern u64 rspAspMainDataStart[];
|
|
|
|
extern u64 rspAspMainDataEnd[];
|
2021-07-27 23:44:58 +00:00
|
|
|
|
|
|
|
AudioTask* func_800E5000(void) {
|
2021-08-12 19:37:37 +00:00
|
|
|
static s32 sMaxAbiCmdCnt = 0x80;
|
|
|
|
static AudioTask* sWaitingAudioTask = NULL;
|
|
|
|
u32 samplesRemainingInAi;
|
2021-07-27 23:44:58 +00:00
|
|
|
s32 abiCmdCnt;
|
2021-08-12 19:37:37 +00:00
|
|
|
s32 pad;
|
|
|
|
s32 j;
|
2021-07-27 23:44:58 +00:00
|
|
|
s32 sp5C;
|
2021-09-20 19:24:24 +00:00
|
|
|
s16* currAiBuffer;
|
2021-08-12 19:37:37 +00:00
|
|
|
OSTask_t* task;
|
|
|
|
s32 index;
|
2021-07-27 23:44:58 +00:00
|
|
|
u32 sp4C;
|
|
|
|
s32 sp48;
|
|
|
|
s32 i;
|
|
|
|
|
|
|
|
gAudioContext.totalTaskCnt++;
|
2021-08-30 00:08:41 +00:00
|
|
|
if (gAudioContext.totalTaskCnt % (gAudioContext.audioBufferParameters.specUnk4) != 0) {
|
2021-08-12 19:37:37 +00:00
|
|
|
if (D_801755D0 != NULL) {
|
2021-07-27 23:44:58 +00:00
|
|
|
D_801755D0();
|
|
|
|
}
|
|
|
|
|
2021-08-30 00:08:41 +00:00
|
|
|
if ((gAudioContext.totalTaskCnt % gAudioContext.audioBufferParameters.specUnk4) + 1 ==
|
|
|
|
gAudioContext.audioBufferParameters.specUnk4) {
|
2021-08-12 19:37:37 +00:00
|
|
|
return sWaitingAudioTask;
|
2021-07-27 23:44:58 +00:00
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-12 19:37:37 +00:00
|
|
|
osSendMesg(gAudioContext.taskStartQueueP, gAudioContext.totalTaskCnt, OS_MESG_NOBLOCK);
|
2021-07-27 23:44:58 +00:00
|
|
|
gAudioContext.rspTaskIdx ^= 1;
|
|
|
|
gAudioContext.curAIBufIdx++;
|
|
|
|
gAudioContext.curAIBufIdx %= 3;
|
2021-08-12 19:37:37 +00:00
|
|
|
index = (gAudioContext.curAIBufIdx - 2 + 3) % 3;
|
|
|
|
samplesRemainingInAi = osAiGetLength() / 4;
|
|
|
|
|
2021-07-27 23:44:58 +00:00
|
|
|
if (gAudioContext.resetTimer < 16) {
|
2021-08-12 19:37:37 +00:00
|
|
|
if (gAudioContext.aiBufLengths[index] != 0) {
|
|
|
|
osAiSetNextBuffer(gAudioContext.aiBuffers[index], gAudioContext.aiBufLengths[index] * 4);
|
2021-09-20 19:24:24 +00:00
|
|
|
if (gAudioContext.aiBuffers[index]) {}
|
|
|
|
if (gAudioContext.aiBufLengths[index]) {}
|
2021-07-27 23:44:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (D_801755D0 != NULL) {
|
|
|
|
D_801755D0();
|
|
|
|
}
|
|
|
|
|
2021-09-07 18:14:09 +00:00
|
|
|
sp5C = gAudioContext.curAudioFrameDmaCount;
|
|
|
|
for (i = 0; i < gAudioContext.curAudioFrameDmaCount; i++) {
|
|
|
|
if (osRecvMesg(&gAudioContext.currAudioFrameDmaQueue, NULL, OS_MESG_NOBLOCK) == 0) {
|
2021-07-27 23:44:58 +00:00
|
|
|
sp5C--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sp5C != 0) {
|
|
|
|
for (i = 0; i < sp5C; i++) {
|
2021-09-07 18:14:09 +00:00
|
|
|
osRecvMesg(&gAudioContext.currAudioFrameDmaQueue, NULL, OS_MESG_BLOCK);
|
2021-07-27 23:44:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-07 18:14:09 +00:00
|
|
|
sp48 = gAudioContext.currAudioFrameDmaQueue.validCount;
|
2021-08-12 19:37:37 +00:00
|
|
|
if (sp48 != 0) {
|
2021-07-27 23:44:58 +00:00
|
|
|
for (i = 0; i < sp48; i++) {
|
2021-09-07 18:14:09 +00:00
|
|
|
osRecvMesg(&gAudioContext.currAudioFrameDmaQueue, NULL, OS_MESG_NOBLOCK);
|
2021-07-27 23:44:58 +00:00
|
|
|
}
|
|
|
|
}
|
2021-08-12 19:37:37 +00:00
|
|
|
|
2021-09-07 18:14:09 +00:00
|
|
|
gAudioContext.curAudioFrameDmaCount = 0;
|
2021-11-07 16:58:50 +00:00
|
|
|
AudioLoad_DecreaseSampleDmaTtls();
|
|
|
|
AudioLoad_ProcessLoads(gAudioContext.resetStatus);
|
|
|
|
AudioLoad_ProcessScriptLoads();
|
2021-07-27 23:44:58 +00:00
|
|
|
|
2021-08-12 19:37:37 +00:00
|
|
|
if (gAudioContext.resetStatus != 0) {
|
2021-11-07 16:58:50 +00:00
|
|
|
if (AudioHeap_ResetStep() == 0) {
|
2021-08-12 19:37:37 +00:00
|
|
|
if (gAudioContext.resetStatus == 0) {
|
2021-08-30 00:08:41 +00:00
|
|
|
osSendMesg(gAudioContext.audioResetQueueP, gAudioContext.audioResetSpecIdToLoad, OS_MESG_NOBLOCK);
|
2021-08-12 19:37:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sWaitingAudioTask = NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
2021-07-27 23:44:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (gAudioContext.resetTimer > 16) {
|
|
|
|
return NULL;
|
2021-08-12 19:37:37 +00:00
|
|
|
}
|
|
|
|
if (gAudioContext.resetTimer != 0) {
|
2021-07-27 23:44:58 +00:00
|
|
|
gAudioContext.resetTimer++;
|
|
|
|
}
|
|
|
|
|
|
|
|
gAudioContext.currTask = &gAudioContext.rspTask[gAudioContext.rspTaskIdx];
|
|
|
|
gAudioContext.curAbiCmdBuf = gAudioContext.abiCmdBufs[gAudioContext.rspTaskIdx];
|
2021-08-12 19:37:37 +00:00
|
|
|
|
|
|
|
index = gAudioContext.curAIBufIdx;
|
|
|
|
currAiBuffer = gAudioContext.aiBuffers[index];
|
|
|
|
|
|
|
|
gAudioContext.aiBufLengths[index] =
|
|
|
|
(s16)((((gAudioContext.audioBufferParameters.samplesPerFrameTarget - samplesRemainingInAi) +
|
|
|
|
EXTRA_BUFFERED_AI_SAMPLES_TARGET) &
|
|
|
|
~0xF) +
|
|
|
|
SAMPLES_TO_OVERPRODUCE);
|
|
|
|
if (gAudioContext.aiBufLengths[index] < gAudioContext.audioBufferParameters.minAiBufferLength) {
|
|
|
|
gAudioContext.aiBufLengths[index] = gAudioContext.audioBufferParameters.minAiBufferLength;
|
2021-07-27 23:44:58 +00:00
|
|
|
}
|
|
|
|
|
2021-08-12 19:37:37 +00:00
|
|
|
if (gAudioContext.aiBufLengths[index] > gAudioContext.audioBufferParameters.maxAiBufferLength) {
|
|
|
|
gAudioContext.aiBufLengths[index] = gAudioContext.audioBufferParameters.maxAiBufferLength;
|
2021-07-27 23:44:58 +00:00
|
|
|
}
|
|
|
|
|
2021-08-12 19:37:37 +00:00
|
|
|
j = 0;
|
2021-07-27 23:44:58 +00:00
|
|
|
if (gAudioContext.resetStatus == 0) {
|
|
|
|
// msg = 0000RREE R = read pos, E = End Pos
|
2021-08-12 19:37:37 +00:00
|
|
|
while (osRecvMesg(gAudioContext.cmdProcQueueP, (OSMesg*)&sp4C, OS_MESG_NOBLOCK) != -1) {
|
|
|
|
if (1) {}
|
|
|
|
if (1) {}
|
|
|
|
if (1) {}
|
2021-07-27 23:44:58 +00:00
|
|
|
Audio_ProcessCmds(sp4C);
|
2021-08-12 19:37:37 +00:00
|
|
|
j++;
|
2021-07-27 23:44:58 +00:00
|
|
|
}
|
2021-08-12 19:37:37 +00:00
|
|
|
if ((j == 0) && (gAudioContext.cmdQueueFinished)) {
|
2021-07-27 23:44:58 +00:00
|
|
|
Audio_ScheduleProcessCmds();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gAudioContext.curAbiCmdBuf =
|
2021-08-12 19:37:37 +00:00
|
|
|
AudioSynth_Update(gAudioContext.curAbiCmdBuf, &abiCmdCnt, currAiBuffer, gAudioContext.aiBufLengths[index]);
|
|
|
|
gAudioContext.audioRandom = (gAudioContext.audioRandom + gAudioContext.totalTaskCnt) * osGetCount();
|
|
|
|
gAudioContext.audioRandom =
|
|
|
|
gAudioContext.aiBuffers[index][gAudioContext.totalTaskCnt & 0xFF] + gAudioContext.audioRandom;
|
|
|
|
gWaveSamples[8] = (s16*)(((u8*)func_800E4FE0) + (gAudioContext.audioRandom & 0xFFF0));
|
|
|
|
|
|
|
|
index = gAudioContext.rspTaskIdx;
|
2021-07-27 23:44:58 +00:00
|
|
|
gAudioContext.currTask->taskQueue = NULL;
|
|
|
|
gAudioContext.currTask->unk_44 = NULL;
|
2021-08-12 19:37:37 +00:00
|
|
|
|
|
|
|
task = &gAudioContext.currTask->task.t;
|
|
|
|
task->type = M_AUDTASK;
|
|
|
|
task->flags = 0;
|
|
|
|
task->ucode_boot = D_801120C0;
|
|
|
|
task->ucode_boot_size = 0x1000;
|
|
|
|
task->ucode_data_size = ((rspAspMainDataEnd - rspAspMainDataStart) * sizeof(u64)) - 1;
|
|
|
|
task->ucode = D_801120C0;
|
|
|
|
task->ucode_data = rspAspMainDataStart;
|
|
|
|
task->ucode_size = 0x1000;
|
|
|
|
task->dram_stack = NULL;
|
|
|
|
task->dram_stack_size = 0;
|
|
|
|
task->output_buff = NULL;
|
|
|
|
task->output_buff_size = NULL;
|
2021-09-20 19:24:24 +00:00
|
|
|
if (1) {}
|
2021-08-12 19:37:37 +00:00
|
|
|
task->data_ptr = (u64*)gAudioContext.abiCmdBufs[index];
|
|
|
|
task->data_size = abiCmdCnt * sizeof(Acmd);
|
|
|
|
task->yield_data_ptr = NULL;
|
|
|
|
task->yield_data_size = 0;
|
|
|
|
|
|
|
|
if (sMaxAbiCmdCnt < abiCmdCnt) {
|
|
|
|
sMaxAbiCmdCnt = abiCmdCnt;
|
2021-07-27 23:44:58 +00:00
|
|
|
}
|
|
|
|
|
2021-08-30 00:08:41 +00:00
|
|
|
if (gAudioContext.audioBufferParameters.specUnk4 == 1) {
|
2021-07-27 23:44:58 +00:00
|
|
|
return gAudioContext.currTask;
|
2021-08-12 19:37:37 +00:00
|
|
|
} else {
|
|
|
|
sWaitingAudioTask = gAudioContext.currTask;
|
|
|
|
return NULL;
|
2021-07-27 23:44:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ACMD_SND_MDE ((u32)0xF0000000)
|
|
|
|
#define ACMD_MUTE ((u32)0xF1000000)
|
|
|
|
|
|
|
|
void func_800E5584(AudioCmd* cmd) {
|
|
|
|
s32 i;
|
|
|
|
s32 pad;
|
|
|
|
s32 pad2;
|
|
|
|
u32 temp_a1_5;
|
|
|
|
u32 temp_t7;
|
|
|
|
|
|
|
|
switch (cmd->op) {
|
|
|
|
case 0x81:
|
2021-11-07 16:58:50 +00:00
|
|
|
AudioLoad_SyncLoadSeqParts(cmd->arg1, cmd->arg2);
|
2021-07-27 23:44:58 +00:00
|
|
|
return;
|
|
|
|
case 0x82:
|
2021-11-07 16:58:50 +00:00
|
|
|
AudioLoad_SyncInitSeqPlayer(cmd->arg0, cmd->arg1, cmd->arg2);
|
2021-07-27 23:44:58 +00:00
|
|
|
func_800E59AC(cmd->arg0, cmd->data);
|
|
|
|
return;
|
|
|
|
case 0x85:
|
2021-11-07 16:58:50 +00:00
|
|
|
AudioLoad_SyncInitSeqPlayerSkipTicks(cmd->arg0, cmd->arg1, cmd->data);
|
2021-07-27 23:44:58 +00:00
|
|
|
return;
|
|
|
|
case 0x83:
|
|
|
|
if (gAudioContext.seqPlayers[cmd->arg0].enabled) {
|
|
|
|
if (cmd->asInt == 0) {
|
2021-11-07 16:58:50 +00:00
|
|
|
AudioSeq_SequencePlayerDisableAsFinished(&gAudioContext.seqPlayers[cmd->arg0]);
|
2021-07-27 23:44:58 +00:00
|
|
|
} else {
|
|
|
|
func_800E5958(cmd->arg0, cmd->asInt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
case 0xF0:
|
|
|
|
gAudioContext.soundMode = cmd->asUInt;
|
|
|
|
return;
|
|
|
|
case 0xF1:
|
|
|
|
for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) {
|
|
|
|
SequencePlayer* seqPlayer = &gAudioContext.seqPlayers[i];
|
|
|
|
seqPlayer->muted = 1;
|
|
|
|
seqPlayer->recalculateVolume = 1;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
case 0xF2:
|
|
|
|
if (cmd->asUInt == 1) {
|
2021-11-07 16:58:50 +00:00
|
|
|
for (i = 0; i < gAudioContext.numNotes; i++) {
|
2021-07-27 23:44:58 +00:00
|
|
|
Note* note = &gAudioContext.notes[i];
|
2021-08-12 19:37:37 +00:00
|
|
|
NoteSubEu* subEu = ¬e->noteSubEu;
|
2021-11-07 16:58:50 +00:00
|
|
|
if (subEu->bitField0.enabled && note->playbackState.unk_04 == 0) {
|
|
|
|
if (note->playbackState.parentLayer->channel->muteBehavior & 8) {
|
|
|
|
subEu->bitField0.finished = 1;
|
2021-07-27 23:44:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) {
|
|
|
|
SequencePlayer* seqPlayer = &gAudioContext.seqPlayers[i];
|
|
|
|
seqPlayer->muted = 0;
|
|
|
|
seqPlayer->recalculateVolume = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
case 0xF3:
|
2021-11-07 16:58:50 +00:00
|
|
|
AudioLoad_SyncLoadInstrument(cmd->arg0, cmd->arg1, cmd->arg2);
|
2021-07-27 23:44:58 +00:00
|
|
|
return;
|
|
|
|
case 0xF4:
|
2021-11-07 16:58:50 +00:00
|
|
|
AudioLoad_AsyncLoadSampleBank(cmd->arg0, cmd->arg1, cmd->arg2, &gAudioContext.externalLoadQueue);
|
2021-07-27 23:44:58 +00:00
|
|
|
return;
|
|
|
|
case 0xF5:
|
2021-11-07 16:58:50 +00:00
|
|
|
AudioLoad_AsyncLoadFont(cmd->arg0, cmd->arg1, cmd->arg2, &gAudioContext.externalLoadQueue);
|
2021-07-27 23:44:58 +00:00
|
|
|
return;
|
|
|
|
case 0xFC:
|
2021-11-07 16:58:50 +00:00
|
|
|
AudioLoad_AsyncLoadSeq(cmd->arg0, cmd->arg1, cmd->arg2, &gAudioContext.externalLoadQueue);
|
2021-07-27 23:44:58 +00:00
|
|
|
return;
|
|
|
|
case 0xF6:
|
2021-11-07 16:58:50 +00:00
|
|
|
AudioLoad_DiscardSeqFonts(cmd->arg1);
|
2021-07-27 23:44:58 +00:00
|
|
|
return;
|
|
|
|
case 0x90:
|
|
|
|
gAudioContext.unk_5BDC[cmd->arg0] = cmd->asUShort;
|
|
|
|
return;
|
|
|
|
case 0xF9:
|
|
|
|
gAudioContext.resetStatus = 5;
|
2021-08-30 00:08:41 +00:00
|
|
|
gAudioContext.audioResetSpecIdToLoad = cmd->asUInt;
|
2021-07-27 23:44:58 +00:00
|
|
|
return;
|
|
|
|
case 0xFB:
|
2021-08-12 19:37:37 +00:00
|
|
|
D_801755D0 = (void (*)(void))cmd->asUInt;
|
2021-07-27 23:44:58 +00:00
|
|
|
return;
|
|
|
|
case 0xE0:
|
|
|
|
case 0xE1:
|
|
|
|
case 0xE2:
|
2021-11-07 16:58:50 +00:00
|
|
|
Audio_SetFontInstrument(cmd->op - 0xE0, cmd->arg0, cmd->arg1, cmd->data);
|
2021-07-27 23:44:58 +00:00
|
|
|
return;
|
|
|
|
case 0xFE:
|
|
|
|
temp_t7 = cmd->asUInt;
|
|
|
|
if (temp_t7 == 1) {
|
|
|
|
for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) {
|
|
|
|
SequencePlayer* seqPlayer = &gAudioContext.seqPlayers[i];
|
|
|
|
if (seqPlayer->enabled) {
|
2021-11-07 16:58:50 +00:00
|
|
|
AudioSeq_SequencePlayerDisableAsFinished(seqPlayer);
|
2021-07-27 23:44:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func_800E66C0(temp_t7);
|
|
|
|
return;
|
|
|
|
case 0xE3:
|
2021-11-07 16:58:50 +00:00
|
|
|
AudioHeap_PopCache(cmd->asInt);
|
2021-07-27 23:44:58 +00:00
|
|
|
return;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetFadeOutTimer
|
|
|
|
void func_800E5958(s32 playerIdx, s32 fadeTimer) {
|
|
|
|
SequencePlayer* seqPlayer = &gAudioContext.seqPlayers[playerIdx];
|
|
|
|
|
|
|
|
if (fadeTimer == 0) {
|
|
|
|
fadeTimer = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
seqPlayer->fadeVelocity = -(seqPlayer->fadeVolume / fadeTimer);
|
|
|
|
seqPlayer->state = 2;
|
|
|
|
seqPlayer->fadeTimer = fadeTimer;
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetFadeInTimer
|
|
|
|
void func_800E59AC(s32 playerIdx, s32 fadeTimer) {
|
|
|
|
SequencePlayer* seqPlayer;
|
|
|
|
if (fadeTimer != 0) {
|
|
|
|
seqPlayer = &gAudioContext.seqPlayers[playerIdx];
|
|
|
|
seqPlayer->state = 1;
|
|
|
|
seqPlayer->fadeTimerUnkEu = fadeTimer;
|
|
|
|
seqPlayer->fadeTimer = fadeTimer;
|
|
|
|
seqPlayer->fadeVolume = 0.0f;
|
|
|
|
seqPlayer->fadeVelocity = 0.0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Audio_InitMesgQueuesInternal(void) {
|
|
|
|
gAudioContext.cmdWrPos = 0;
|
|
|
|
gAudioContext.cmdRdPos = 0;
|
|
|
|
gAudioContext.cmdQueueFinished = 0;
|
|
|
|
gAudioContext.taskStartQueueP = &gAudioContext.taskStartQueue;
|
|
|
|
gAudioContext.cmdProcQueueP = &gAudioContext.cmdProcQueue;
|
|
|
|
gAudioContext.audioResetQueueP = &gAudioContext.audioResetQueue;
|
|
|
|
osCreateMesgQueue(gAudioContext.taskStartQueueP, gAudioContext.taskStartMsgs,
|
|
|
|
ARRAY_COUNT(gAudioContext.taskStartMsgs));
|
|
|
|
osCreateMesgQueue(gAudioContext.cmdProcQueueP, gAudioContext.cmdProcMsgs, ARRAY_COUNT(gAudioContext.cmdProcMsgs));
|
|
|
|
osCreateMesgQueue(gAudioContext.audioResetQueueP, gAudioContext.audioResetMesgs,
|
|
|
|
ARRAY_COUNT(gAudioContext.audioResetMesgs));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Audio_QueueCmd(u32 opArgs, void** data) {
|
|
|
|
AudioCmd* cmd = &gAudioContext.cmdBuf[gAudioContext.cmdWrPos & 0xFF];
|
|
|
|
|
|
|
|
cmd->opArgs = opArgs;
|
|
|
|
cmd->data = *data;
|
|
|
|
|
|
|
|
gAudioContext.cmdWrPos++;
|
|
|
|
|
|
|
|
if (gAudioContext.cmdWrPos == gAudioContext.cmdRdPos) {
|
|
|
|
gAudioContext.cmdWrPos--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Audio_QueueCmdF32(u32 opArgs, f32 data) {
|
2021-09-07 17:50:50 +00:00
|
|
|
Audio_QueueCmd(opArgs, (void**)&data);
|
2021-07-27 23:44:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Audio_QueueCmdS32(u32 opArgs, s32 data) {
|
2021-09-07 17:50:50 +00:00
|
|
|
Audio_QueueCmd(opArgs, (void**)&data);
|
2021-07-27 23:44:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Audio_QueueCmdS8(u32 opArgs, s8 data) {
|
|
|
|
u32 uData = data << 0x18;
|
|
|
|
|
2021-09-07 17:50:50 +00:00
|
|
|
Audio_QueueCmd(opArgs, (void**)&uData);
|
2021-07-27 23:44:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Audio_QueueCmdU16(u32 opArgs, u16 data) {
|
|
|
|
u32 uData = data << 0x10;
|
|
|
|
|
2021-09-07 17:50:50 +00:00
|
|
|
Audio_QueueCmd(opArgs, (void**)&uData);
|
2021-07-27 23:44:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
s32 Audio_ScheduleProcessCmds(void) {
|
|
|
|
static s32 D_801304E8 = 0;
|
|
|
|
s32 ret;
|
|
|
|
|
|
|
|
if (D_801304E8 < (u8)((gAudioContext.cmdWrPos - gAudioContext.cmdRdPos) + 0x100)) {
|
|
|
|
D_801304E8 = (u8)((gAudioContext.cmdWrPos - gAudioContext.cmdRdPos) + 0x100);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret =
|
|
|
|
osSendMesg(gAudioContext.cmdProcQueueP,
|
|
|
|
(void*)(((gAudioContext.cmdRdPos & 0xFF) << 8) | (gAudioContext.cmdWrPos & 0xFF)), OS_MESG_NOBLOCK);
|
|
|
|
if (ret != -1) {
|
|
|
|
gAudioContext.cmdRdPos = gAudioContext.cmdWrPos;
|
|
|
|
ret = 0;
|
|
|
|
} else {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Audio_ResetCmdQueue(void) {
|
|
|
|
gAudioContext.cmdQueueFinished = 0;
|
|
|
|
gAudioContext.cmdRdPos = gAudioContext.cmdWrPos;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Audio_ProcessCmd(AudioCmd* cmd) {
|
|
|
|
SequencePlayer* seqPlayer;
|
|
|
|
u16 phi_v0;
|
|
|
|
s32 i;
|
|
|
|
|
|
|
|
if ((cmd->op & 0xF0) == 0xF0) {
|
|
|
|
func_800E5584(cmd);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cmd->arg0 < gAudioContext.audioBufferParameters.numSequencePlayers) {
|
|
|
|
seqPlayer = &gAudioContext.seqPlayers[cmd->arg0];
|
|
|
|
if (cmd->op & 0x80) {
|
|
|
|
func_800E5584(cmd);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (cmd->op & 0x40) {
|
|
|
|
func_800E6128(seqPlayer, cmd);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cmd->arg1 < 0x10) {
|
|
|
|
func_800E6300(seqPlayer->channels[cmd->arg1], cmd);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (cmd->arg1 == 0xFF) {
|
|
|
|
phi_v0 = gAudioContext.unk_5BDC[cmd->arg0];
|
|
|
|
for (i = 0; i < 0x10; i++) {
|
|
|
|
if (phi_v0 & 1) {
|
|
|
|
func_800E6300(seqPlayer->channels[i], cmd);
|
|
|
|
}
|
|
|
|
phi_v0 = phi_v0 >> 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Audio_ProcessCmds(u32 msg) {
|
|
|
|
static u8 curCmdRdPos = 0;
|
|
|
|
AudioCmd* cmd;
|
|
|
|
u8 endPos;
|
|
|
|
|
|
|
|
if (!gAudioContext.cmdQueueFinished) {
|
|
|
|
curCmdRdPos = msg >> 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
endPos = msg & 0xFF;
|
|
|
|
if (curCmdRdPos == endPos) {
|
|
|
|
gAudioContext.cmdQueueFinished = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd = &gAudioContext.cmdBuf[curCmdRdPos++ & 0xFF];
|
|
|
|
if (cmd->op == 0xF8) {
|
|
|
|
gAudioContext.cmdQueueFinished = 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Audio_ProcessCmd(cmd);
|
|
|
|
cmd->op = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-07 16:58:50 +00:00
|
|
|
u32 func_800E5E20(u32* out) {
|
2021-07-27 23:44:58 +00:00
|
|
|
u32 sp1C;
|
|
|
|
|
2021-11-07 16:58:50 +00:00
|
|
|
if (osRecvMesg(&gAudioContext.externalLoadQueue, (OSMesg*)&sp1C, OS_MESG_NOBLOCK) == -1) {
|
|
|
|
*out = 0;
|
2021-07-27 23:44:58 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2021-11-07 16:58:50 +00:00
|
|
|
*out = sp1C & 0xFFFFFF;
|
2021-07-27 23:44:58 +00:00
|
|
|
return sp1C >> 0x18;
|
|
|
|
}
|
|
|
|
|
|
|
|
u8* func_800E5E84(s32 arg0, u32* arg1) {
|
2021-11-07 16:58:50 +00:00
|
|
|
return AudioLoad_GetFontsForSequence(arg0, arg1);
|
2021-07-27 23:44:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void func_800E5EA4(s32 arg0, u32* arg1, u32* arg2) {
|
2021-11-07 16:58:50 +00:00
|
|
|
*arg1 = gAudioContext.soundFonts[arg0].sampleBankId1;
|
|
|
|
*arg2 = gAudioContext.soundFonts[arg0].sampleBankId2;
|
2021-07-27 23:44:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
s32 func_800E5EDC(void) {
|
|
|
|
s32 pad;
|
|
|
|
s32 sp18;
|
|
|
|
|
2021-08-12 19:37:37 +00:00
|
|
|
if (osRecvMesg(gAudioContext.audioResetQueueP, (OSMesg*)&sp18, OS_MESG_NOBLOCK) == -1) {
|
2021-07-27 23:44:58 +00:00
|
|
|
return 0;
|
2021-08-30 00:08:41 +00:00
|
|
|
} else if (gAudioContext.audioResetSpecIdToLoad != sp18) {
|
2021-07-27 23:44:58 +00:00
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void func_800E5F34(void) {
|
2021-07-28 21:59:52 +00:00
|
|
|
// macro?
|
|
|
|
// clang-format off
|
2021-08-12 19:37:37 +00:00
|
|
|
s32 chk = -1; s32 sp28; do {} while (osRecvMesg(gAudioContext.audioResetQueueP, (OSMesg*)&sp28, OS_MESG_NOBLOCK) != chk);
|
2021-07-28 21:59:52 +00:00
|
|
|
// clang-format on
|
2021-07-27 23:44:58 +00:00
|
|
|
}
|
|
|
|
|
2021-09-07 17:50:50 +00:00
|
|
|
s32 func_800E5F88(s32 resetPreloadID) {
|
2021-07-27 23:44:58 +00:00
|
|
|
s32 resetStatus;
|
|
|
|
OSMesg msg;
|
|
|
|
s32 pad;
|
|
|
|
|
|
|
|
func_800E5F34();
|
|
|
|
resetStatus = gAudioContext.resetStatus;
|
|
|
|
if (resetStatus != 0) {
|
|
|
|
Audio_ResetCmdQueue();
|
2021-08-30 00:08:41 +00:00
|
|
|
if (gAudioContext.audioResetSpecIdToLoad == resetPreloadID) {
|
2021-07-27 23:44:58 +00:00
|
|
|
return -2;
|
|
|
|
} else if (resetStatus > 2) {
|
2021-08-30 00:08:41 +00:00
|
|
|
gAudioContext.audioResetSpecIdToLoad = resetPreloadID;
|
2021-07-27 23:44:58 +00:00
|
|
|
return -3;
|
|
|
|
} else {
|
|
|
|
osRecvMesg(gAudioContext.audioResetQueueP, &msg, OS_MESG_BLOCK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func_800E5F34();
|
|
|
|
Audio_QueueCmdS32(0xF9000000, resetPreloadID);
|
|
|
|
|
|
|
|
return Audio_ScheduleProcessCmds();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Audio_PreNMIInternal(void) {
|
|
|
|
gAudioContext.resetTimer = 1;
|
|
|
|
if (gAudioContextInitalized) {
|
|
|
|
func_800E5F88(0);
|
|
|
|
gAudioContext.resetStatus = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
s8 func_800E6070(s32 playerIdx, s32 channelIdx, s32 scriptIdx) {
|
|
|
|
SequencePlayer* seqPlayer = &gAudioContext.seqPlayers[playerIdx];
|
|
|
|
SequenceChannel* channel;
|
|
|
|
if (seqPlayer->enabled) {
|
|
|
|
channel = seqPlayer->channels[channelIdx];
|
|
|
|
return channel->soundScriptIO[scriptIdx];
|
|
|
|
} else {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-30 18:47:09 +00:00
|
|
|
s8 func_800E60C4(s32 playerIdx, s32 arg1) {
|
|
|
|
return gAudioContext.seqPlayers[playerIdx].soundScriptIO[arg1];
|
2021-07-27 23:44:58 +00:00
|
|
|
}
|
|
|
|
|
2021-11-07 16:58:50 +00:00
|
|
|
void Audio_InitExternalPool(void* mem, u32 size) {
|
|
|
|
AudioHeap_AllocPoolInit(&gAudioContext.externalPool, mem, size);
|
2021-07-27 23:44:58 +00:00
|
|
|
}
|
|
|
|
|
2021-11-07 16:58:50 +00:00
|
|
|
void Audio_DestroyExternalPool(void) {
|
|
|
|
gAudioContext.externalPool.start = NULL;
|
2021-07-27 23:44:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void func_800E6128(SequencePlayer* seqPlayer, AudioCmd* cmd) {
|
|
|
|
f32 fadeVolume;
|
|
|
|
switch (cmd->op) {
|
|
|
|
case 0x41:
|
|
|
|
if (seqPlayer->fadeVolumeScale != cmd->asFloat) {
|
|
|
|
seqPlayer->fadeVolumeScale = cmd->asFloat;
|
|
|
|
seqPlayer->recalculateVolume = 1;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
case 0x47:
|
|
|
|
seqPlayer->tempo = cmd->asInt * 0x30;
|
|
|
|
return;
|
|
|
|
case 0x49:
|
|
|
|
seqPlayer->unk_0C = cmd->asInt * 0x30;
|
|
|
|
return;
|
|
|
|
case 0x4E:
|
|
|
|
seqPlayer->unk_0C = cmd->asInt;
|
|
|
|
return;
|
|
|
|
case 0x48:
|
|
|
|
seqPlayer->transposition = cmd->asSbyte;
|
|
|
|
return;
|
|
|
|
case 0x46:
|
2021-11-07 16:58:50 +00:00
|
|
|
seqPlayer->soundScriptIO[cmd->arg2] = cmd->asSbyte;
|
2021-07-27 23:44:58 +00:00
|
|
|
return;
|
|
|
|
case 0x4A:
|
|
|
|
fadeVolume = (s32)cmd->arg1 / 127.0f;
|
|
|
|
goto block_11;
|
|
|
|
case 0x4B:
|
|
|
|
fadeVolume = ((s32)cmd->arg1 / 100.0f) * seqPlayer->fadeVolume;
|
|
|
|
block_11:
|
|
|
|
if (seqPlayer->state != 2) {
|
|
|
|
seqPlayer->volume = seqPlayer->fadeVolume;
|
|
|
|
if (cmd->asInt == 0) {
|
|
|
|
seqPlayer->fadeVolume = fadeVolume;
|
|
|
|
} else {
|
|
|
|
s32 tmp = cmd->asInt;
|
|
|
|
seqPlayer->state = 0;
|
|
|
|
seqPlayer->fadeTimer = tmp;
|
|
|
|
seqPlayer->fadeVelocity = (fadeVolume - seqPlayer->fadeVolume) / tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
case 0x4C:
|
|
|
|
if (seqPlayer->state != 2) {
|
|
|
|
if (cmd->asInt == 0) {
|
|
|
|
seqPlayer->fadeVolume = seqPlayer->volume;
|
|
|
|
} else {
|
|
|
|
s32 tmp = cmd->asInt;
|
|
|
|
seqPlayer->state = 0;
|
|
|
|
seqPlayer->fadeTimer = tmp;
|
|
|
|
seqPlayer->fadeVelocity = (seqPlayer->volume - seqPlayer->fadeVolume) / tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
case 0x4D:
|
|
|
|
seqPlayer->unk_34 = cmd->asFloat;
|
|
|
|
if (seqPlayer->unk_34 == 1.0f) {
|
|
|
|
seqPlayer->unk_0b1 = 0;
|
|
|
|
} else {
|
|
|
|
seqPlayer->unk_0b1 = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void func_800E6300(SequenceChannel* channel, AudioCmd* cmd) {
|
|
|
|
switch (cmd->op) {
|
|
|
|
case CHAN_UPD_VOL_SCALE:
|
|
|
|
if (channel->volumeScale != cmd->asFloat) {
|
|
|
|
channel->volumeScale = cmd->asFloat;
|
|
|
|
channel->changes.s.volume = 1;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
case CHAN_UPD_VOL:
|
|
|
|
if (channel->volume != cmd->asFloat) {
|
|
|
|
channel->volume = cmd->asFloat;
|
|
|
|
channel->changes.s.volume = 1;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
case CHAN_UPD_PAN_SIGNED:
|
|
|
|
if (channel->newPan != cmd->asSbyte) {
|
|
|
|
channel->newPan = cmd->asSbyte;
|
|
|
|
channel->changes.s.pan = 1;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
case CHAN_UPD_PAN_UNSIGNED:
|
|
|
|
if (channel->newPan != cmd->asSbyte) {
|
|
|
|
channel->panChannelWeight = cmd->asSbyte;
|
|
|
|
channel->changes.s.pan = 1;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
case CHAN_UPD_FREQ_SCALE:
|
|
|
|
if (channel->freqScale != cmd->asFloat) {
|
|
|
|
channel->freqScale = cmd->asFloat;
|
|
|
|
channel->changes.s.freqScale = 1;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
case CHAN_UPD_REVERB:
|
|
|
|
if (channel->reverb != cmd->asSbyte) {
|
|
|
|
channel->reverb = cmd->asSbyte;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
case CHAN_UPD_SCRIPT_IO:
|
|
|
|
if (cmd->arg2 < 8) {
|
|
|
|
channel->soundScriptIO[cmd->arg2] = cmd->asSbyte;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
case CHAN_UPD_STOP_SOMETHING2:
|
|
|
|
channel->stopSomething2 = cmd->asSbyte;
|
|
|
|
return;
|
|
|
|
case CHAN_UPD_MUTE_BEHAVE:
|
|
|
|
channel->muteBehavior = cmd->asSbyte;
|
|
|
|
return;
|
|
|
|
case CHAN_UPD_VIBE_X8:
|
|
|
|
channel->vibratoExtentTarget = cmd->asUbyte * 8;
|
|
|
|
channel->vibratoExtentChangeDelay = 1;
|
|
|
|
return;
|
|
|
|
case CHAN_UPD_VIBE_X32:
|
|
|
|
channel->vibratoRateTarget = cmd->asUbyte * 32;
|
|
|
|
channel->vibratoRateChangeDelay = 1;
|
|
|
|
return;
|
|
|
|
case CHAN_UPD_UNK_0F:
|
|
|
|
channel->unk_0F = cmd->asUbyte;
|
|
|
|
return;
|
|
|
|
case CHAN_UPD_UNK_20:
|
|
|
|
channel->unk_20 = cmd->asUShort;
|
|
|
|
return;
|
2021-08-31 22:53:35 +00:00
|
|
|
case CHAN_UPD_STEREO:
|
|
|
|
channel->stereo.asByte = cmd->asUbyte;
|
2021-07-27 23:44:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void func_800E64B0(s32 arg0, s32 arg1, s32 arg2) {
|
|
|
|
Audio_QueueCmdS32(((arg0 & 0xFF) << 0x10) | 0xFA000000 | ((arg1 & 0xFF) << 8) | (arg2 & 0xFF), 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void func_800E64F8(void) {
|
|
|
|
Audio_QueueCmdS32(0xFA000000, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void func_800E651C(u32 arg0, s32 arg1) {
|
|
|
|
Audio_QueueCmdS32((arg1 & 0xFF) | 0xFD000000, arg0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Audio_WaitForAudioTask(void) {
|
|
|
|
osRecvMesg(gAudioContext.taskStartQueueP, NULL, OS_MESG_NOBLOCK);
|
|
|
|
osRecvMesg(gAudioContext.taskStartQueueP, NULL, OS_MESG_BLOCK);
|
|
|
|
}
|
|
|
|
|
2021-11-30 18:47:09 +00:00
|
|
|
s32 func_800E6590(s32 playerIdx, s32 arg1, s32 arg2) {
|
2021-07-27 23:44:58 +00:00
|
|
|
SequencePlayer* seqPlayer;
|
2021-11-07 16:58:50 +00:00
|
|
|
SequenceLayer* layer;
|
2021-08-12 19:37:37 +00:00
|
|
|
Note* note;
|
2021-11-07 16:58:50 +00:00
|
|
|
SoundFontSound* sound;
|
2021-08-12 19:37:37 +00:00
|
|
|
s32 loopEnd;
|
|
|
|
s32 samplePos;
|
2021-07-27 23:44:58 +00:00
|
|
|
|
2021-11-30 18:47:09 +00:00
|
|
|
seqPlayer = &gAudioContext.seqPlayers[playerIdx];
|
2021-07-27 23:44:58 +00:00
|
|
|
if (seqPlayer->enabled && seqPlayer->channels[arg1]->enabled) {
|
2021-08-12 19:37:37 +00:00
|
|
|
layer = seqPlayer->channels[arg1]->layers[arg2];
|
|
|
|
if (layer == NULL) {
|
2021-07-27 23:44:58 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-08-12 19:37:37 +00:00
|
|
|
if (layer->enabled) {
|
|
|
|
if (layer->note == NULL) {
|
2021-07-27 23:44:58 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-08-12 19:37:37 +00:00
|
|
|
if (!layer->bit3) {
|
2021-07-27 23:44:58 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-08-12 19:37:37 +00:00
|
|
|
note = layer->note;
|
|
|
|
if (layer == note->playbackState.parentLayer) {
|
2021-11-07 16:58:50 +00:00
|
|
|
sound = note->noteSubEu.sound.soundFontSound;
|
2021-08-12 19:37:37 +00:00
|
|
|
if (sound == NULL) {
|
2021-07-27 23:44:58 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2021-08-12 19:37:37 +00:00
|
|
|
loopEnd = sound->sample->loop->end;
|
|
|
|
samplePos = note->synthesisState.samplePosInt;
|
|
|
|
return loopEnd - samplePos;
|
2021-07-27 23:44:58 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 func_800E6680(void) {
|
|
|
|
return func_800E66C0(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void func_800E66A0(void) {
|
|
|
|
func_800E66C0(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 func_800E66C0(s32 arg0) {
|
|
|
|
s32 phi_v1;
|
|
|
|
NotePlaybackState* temp_a2;
|
|
|
|
NoteSubEu* temp_a3;
|
|
|
|
s32 i;
|
|
|
|
Note* note;
|
2021-11-07 16:58:50 +00:00
|
|
|
SoundFontSound* sound;
|
2021-07-27 23:44:58 +00:00
|
|
|
|
|
|
|
phi_v1 = 0;
|
2021-11-07 16:58:50 +00:00
|
|
|
for (i = 0; i < gAudioContext.numNotes; i++) {
|
2021-07-27 23:44:58 +00:00
|
|
|
note = &gAudioContext.notes[i];
|
|
|
|
temp_a2 = ¬e->playbackState;
|
2021-11-07 16:58:50 +00:00
|
|
|
if (note->noteSubEu.bitField0.enabled) {
|
2021-07-27 23:44:58 +00:00
|
|
|
temp_a3 = ¬e->noteSubEu;
|
|
|
|
if (temp_a2->adsr.action.s.state != 0) {
|
|
|
|
if (arg0 >= 2) {
|
2021-11-07 16:58:50 +00:00
|
|
|
sound = temp_a3->sound.soundFontSound;
|
|
|
|
if (sound == NULL || temp_a3->bitField1.isSyntheticWave) {
|
2021-07-27 23:44:58 +00:00
|
|
|
continue;
|
|
|
|
}
|
2021-11-07 16:58:50 +00:00
|
|
|
if (sound->sample->medium == MEDIUM_RAM) {
|
2021-07-27 23:44:58 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
phi_v1++;
|
|
|
|
if ((arg0 & 1) == 1) {
|
|
|
|
temp_a2->adsr.fadeOutVel = gAudioContext.audioBufferParameters.updatesPerFrameInv;
|
|
|
|
temp_a2->adsr.action.s.release = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return phi_v1;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 Audio_NextRandom(void) {
|
|
|
|
static u32 audRand = 0x12345678;
|
|
|
|
|
|
|
|
audRand = ((osGetCount() + 0x1234567) * (audRand + gAudioContext.totalTaskCnt));
|
|
|
|
audRand += gAudioContext.audioRandom;
|
|
|
|
return audRand;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Audio_InitMesgQueues(void) {
|
|
|
|
Audio_InitMesgQueuesInternal();
|
|
|
|
}
|