I tried with pole
Build libsm64 / Build libsm64 for linux (push) Successful in 31s
Build libsm64 / Build libsm64 for windows (push) Successful in 23s
Build libsm64 / Snapshot Release (push) Has been cancelled
Build libsm64 / Build libsm64 for windows (pull_request) Has been cancelled
Build libsm64 / Snapshot Release (pull_request) Has been cancelled
Build libsm64 / Build libsm64 for linux (pull_request) Has been cancelled
Build libsm64 / Build libsm64 for linux (push) Successful in 31s
Build libsm64 / Build libsm64 for windows (push) Successful in 23s
Build libsm64 / Snapshot Release (push) Has been cancelled
Build libsm64 / Build libsm64 for windows (pull_request) Has been cancelled
Build libsm64 / Snapshot Release (pull_request) Has been cancelled
Build libsm64 / Build libsm64 for linux (pull_request) Has been cancelled
This commit is contained in:
@@ -872,14 +872,12 @@ static void process_sound_request(u32 bits, f32 *pos)
|
||||
|
||||
if (soundId >= sNumSoundsPerBank[bank] || sSoundBankDisabled[bank])
|
||||
{
|
||||
//DEBUG_PRINT("process_sound_request: invalid soundId %d\n", soundId);
|
||||
return;
|
||||
}
|
||||
|
||||
u8 soundIndex = sSoundBanks[bank][0].next;
|
||||
while (soundIndex != 0xff && soundIndex != 0)
|
||||
{
|
||||
//DEBUG_PRINT("process_sound_request: soundIndex %d\n", soundIndex);
|
||||
// If an existing sound from the same source exists in the bank, then we should either
|
||||
// interrupt that sound and replace it with the new sound, or we should drop the new sound.
|
||||
if (sSoundBanks[bank][soundIndex].x == pos)
|
||||
@@ -930,7 +928,6 @@ static void process_sound_request(u32 bits, f32 *pos)
|
||||
// If free list has more than one element remaining
|
||||
if (sSoundBanks[bank][sSoundBankFreeListFront[bank]].next != 0xff && soundIndex != 0)
|
||||
{
|
||||
DEBUG_PRINT("process_sound_request2: soundIndex %d\n", soundIndex);
|
||||
// Allocate from free list
|
||||
soundIndex = sSoundBankFreeListFront[bank];
|
||||
|
||||
@@ -966,7 +963,6 @@ static void process_all_sound_requests(void)
|
||||
struct Sound *sound = &sSoundRequests[sNumProcessedSoundRequests];
|
||||
process_sound_request(sound->soundBits, sound->position);
|
||||
sNumProcessedSoundRequests++;
|
||||
//DEBUG_PRINT("processed sounds: %d\n", sNumProcessedSoundRequests);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -120,17 +120,10 @@ ALSeqFile *get_audio_file_header(s32 arg0);
|
||||
*/
|
||||
void audio_dma_copy_immediate(uintptr_t devAddr, void *vAddr, size_t nbytes)
|
||||
{
|
||||
DEBUG_PRINT("audio_dma_copy_immediate()");
|
||||
DEBUG_PRINT("- dev addr: %x", devAddr);
|
||||
DEBUG_PRINT("- vAddr: %x", vAddr);
|
||||
DEBUG_PRINT("- # bytes: %d", nbytes);
|
||||
eu_stubbed_printf_3("Romcopy %x -> %x ,size %x\n", devAddr, vAddr, nbytes);
|
||||
DEBUG_PRINT("- invalidate d cache");
|
||||
osInvalDCache(vAddr, nbytes);
|
||||
DEBUG_PRINT("- start dma");
|
||||
osPiStartDma(&gAudioDmaIoMesg, OS_MESG_PRI_HIGH, OS_READ, devAddr, vAddr, nbytes,
|
||||
&gAudioDmaMesgQueue);
|
||||
DEBUG_PRINT("- recv message");
|
||||
osRecvMesg(&gAudioDmaMesgQueue, NULL, OS_MESG_BLOCK);
|
||||
eu_stubbed_printf_0("Romcopyend\n");
|
||||
}
|
||||
@@ -646,43 +639,31 @@ void patch_audio_bank(struct AudioBank *mem, u8 *offset, u32 numInstruments, u32
|
||||
|
||||
struct AudioBank *bank_load_immediate(s32 bankId, s32 arg1)
|
||||
{
|
||||
DEBUG_PRINT("bank_load_immediate()");
|
||||
|
||||
UNUSED u32 pad1[4];
|
||||
u32 buf[4];
|
||||
|
||||
// (This is broken if the length is 1 (mod 16), but that never happens --
|
||||
// it's always divisible by 4.)
|
||||
DEBUG_PRINT("- getting alloc");
|
||||
s32 alloc = gAlCtlHeader->seqArray[bankId].len + 0xf;
|
||||
DEBUG_PRINT("- aligning");
|
||||
alloc = ALIGN16(alloc);
|
||||
alloc -= 0x10;
|
||||
DEBUG_PRINT("- getting ctl data for bank %d", bankId);
|
||||
u8 *ctlData = gAlCtlHeader->seqArray[bankId].offset;
|
||||
DEBUG_PRINT("- alloc bank or seq");
|
||||
struct AudioBank *ret = alloc_bank_or_seq(&gBankLoadedPool, 1, alloc, arg1, bankId);
|
||||
if (ret == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DEBUG_PRINT("- copying dma immediate 1");
|
||||
DEBUG_PRINT("- ctlData: %x", ctlData);
|
||||
audio_dma_copy_immediate((uintptr_t)ctlData, buf, 0x10);
|
||||
DEBUG_PRINT("- getting nums");
|
||||
u32 numInstruments = buf[0];
|
||||
u32 numDrums = buf[1];
|
||||
DEBUG_PRINT("- copying dma immediate 2");
|
||||
audio_dma_copy_immediate((uintptr_t)(ctlData + 0x10), ret, alloc);
|
||||
DEBUG_PRINT("- patching bank");
|
||||
patch_audio_bank(ret, gAlTbl->seqArray[bankId].offset, numInstruments, numDrums);
|
||||
DEBUG_PRINT("- setting ctl entries");
|
||||
gCtlEntries[bankId].numInstruments = (u8)numInstruments;
|
||||
gCtlEntries[bankId].numDrums = (u8)numDrums;
|
||||
gCtlEntries[bankId].instruments = ret->instruments;
|
||||
gCtlEntries[bankId].drums = ret->drums;
|
||||
DEBUG_PRINT("- setting load status");
|
||||
gBankLoadStatus[bankId] = SOUND_LOAD_STATUS_COMPLETE;
|
||||
return ret;
|
||||
}
|
||||
@@ -851,12 +832,10 @@ u8 get_missing_bank(u32 seqId, s32 *nonNullCount, s32 *nullCount)
|
||||
|
||||
struct AudioBank *load_banks_immediate(s32 seqId, u8 *outDefaultBank)
|
||||
{
|
||||
DEBUG_PRINT("load_banks_immediate()");
|
||||
void *ret;
|
||||
u32 bankId;
|
||||
u8 i;
|
||||
|
||||
DEBUG_PRINT("- getting offset");
|
||||
u16 offset = ((u16 *)gAlBankSets)[seqId];
|
||||
#ifdef VERSION_EU
|
||||
for (i = gAlBankSets[offset++]; i != 0; i--)
|
||||
@@ -864,21 +843,17 @@ struct AudioBank *load_banks_immediate(s32 seqId, u8 *outDefaultBank)
|
||||
bankId = gAlBankSets[offset++];
|
||||
#else
|
||||
offset++;
|
||||
DEBUG_PRINT("- looping through bank sets");
|
||||
for (i = gAlBankSets[offset - 1]; i != 0; i--)
|
||||
{
|
||||
offset++;
|
||||
DEBUG_PRINT("- getting bank id");
|
||||
bankId = gAlBankSets[offset - 1];
|
||||
#endif
|
||||
|
||||
DEBUG_PRINT("- checking if bank load is complete");
|
||||
if (IS_BANK_LOAD_COMPLETE(bankId) == TRUE)
|
||||
{
|
||||
#ifdef VERSION_EU
|
||||
ret = get_bank_or_seq(&gBankLoadedPool, 2, bankId);
|
||||
#else
|
||||
DEBUG_PRINT("- getting bank or seq");
|
||||
ret = get_bank_or_seq(&gBankLoadedPool, 2, gAlBankSets[offset - 1]);
|
||||
#endif
|
||||
}
|
||||
@@ -889,7 +864,6 @@ struct AudioBank *load_banks_immediate(s32 seqId, u8 *outDefaultBank)
|
||||
|
||||
if (ret == NULL)
|
||||
{
|
||||
DEBUG_PRINT("- bank load immediate");
|
||||
ret = bank_load_immediate(bankId, 2);
|
||||
}
|
||||
}
|
||||
@@ -899,7 +873,6 @@ struct AudioBank *load_banks_immediate(s32 seqId, u8 *outDefaultBank)
|
||||
|
||||
void preload_sequence(u32 seqId, u8 preloadMask)
|
||||
{
|
||||
DEBUG_PRINT("preload_sequence()");
|
||||
void *sequenceData;
|
||||
u8 temp;
|
||||
|
||||
@@ -911,25 +884,21 @@ void preload_sequence(u32 seqId, u8 preloadMask)
|
||||
gAudioLoadLock = AUDIO_LOCK_LOADING;
|
||||
if (preloadMask & PRELOAD_BANKS)
|
||||
{
|
||||
DEBUG_PRINT("- load banks immediate");
|
||||
load_banks_immediate(seqId, &temp);
|
||||
}
|
||||
|
||||
if (preloadMask & PRELOAD_SEQUENCE)
|
||||
{
|
||||
// @bug should be IS_SEQ_LOAD_COMPLETE
|
||||
DEBUG_PRINT("- checking if bank load immediate");
|
||||
if (IS_BANK_LOAD_COMPLETE(seqId) == TRUE)
|
||||
{
|
||||
eu_stubbed_printf_1("SEQ %d ALREADY CACHED\n", seqId);
|
||||
DEBUG_PRINT("- getting bank or seq");
|
||||
sequenceData = get_bank_or_seq(&gSeqLoadedPool, 2, seqId);
|
||||
}
|
||||
else
|
||||
{
|
||||
sequenceData = NULL;
|
||||
}
|
||||
DEBUG_PRINT("- checking dma immediate");
|
||||
if (sequenceData == NULL && sequence_dma_immediate(seqId, 2) == NULL)
|
||||
{
|
||||
gAudioLoadLock = AUDIO_LOCK_NOT_LOADING;
|
||||
@@ -1037,7 +1006,6 @@ void load_sequence_internal(u32 player, u32 seqId, s32 loadAsync)
|
||||
// (void) must be omitted from parameters to fix stack with -framepointer
|
||||
void audio_init()
|
||||
{
|
||||
DEBUG_PRINT("audio_init()");
|
||||
UNUSED s8 pad[32];
|
||||
u8 buf[0x10];
|
||||
s32 i, UNUSED k;
|
||||
@@ -1048,7 +1016,6 @@ void audio_init()
|
||||
|
||||
gAudioLoadLock = AUDIO_LOCK_UNINITIALIZED;
|
||||
|
||||
DEBUG_PRINT("- setting values in unused");
|
||||
s32 lim1 = gUnusedCount80333EE8;
|
||||
for (i = 0; i < lim1; i++)
|
||||
{
|
||||
@@ -1056,7 +1023,6 @@ void audio_init()
|
||||
gUnused80226E98[i] = 0;
|
||||
}
|
||||
|
||||
DEBUG_PRINT("- clearing audio heap");
|
||||
s32 lim2 = gAudioHeapSize;
|
||||
for (i = 0; i <= lim2 / 8 - 1; i++)
|
||||
{
|
||||
@@ -1114,39 +1080,22 @@ void audio_init()
|
||||
alSeqFileNew(gSeqFileHeader, data);
|
||||
|
||||
// Load header for CTL (instrument metadata)
|
||||
DEBUG_PRINT("- loading ctl header");
|
||||
gAlCtlHeader = (ALSeqFile *)buf;
|
||||
data = gSoundDataADSR;
|
||||
DEBUG_PRINT("- copying dma immediate");
|
||||
audio_dma_copy_immediate((uintptr_t)data, gAlCtlHeader, 0x10);
|
||||
size = gAlCtlHeader->seqCount * sizeof(ALSeqData) + 4;
|
||||
DEBUG_PRINT("- seq count: %d", gAlCtlHeader->seqCount);
|
||||
DEBUG_PRINT("- size after read: %d", size);
|
||||
size = ALIGN16(size);
|
||||
DEBUG_PRINT("- size after align: %d", size);
|
||||
gCtlEntries = soundAlloc(&gAudioInitPool, gAlCtlHeader->seqCount * sizeof(struct CtlEntry));
|
||||
gAlCtlHeader = soundAlloc(&gAudioInitPool, size);
|
||||
DEBUG_PRINT("@ copying data from sound data adsr to ctl header");
|
||||
DEBUG_PRINT("- data: %x", data);
|
||||
DEBUG_PRINT("- ctl header: %x", gAlCtlHeader);
|
||||
DEBUG_PRINT("- size: %d", size);
|
||||
audio_dma_copy_immediate((uintptr_t)data, gAlCtlHeader, size);
|
||||
DEBUG_PRINT("- creating new seq file for ctl");
|
||||
alSeqFileNew(gAlCtlHeader, data);
|
||||
|
||||
// Load header for TBL (raw sound data)
|
||||
DEBUG_PRINT("- loading tbl");
|
||||
gAlTbl = (ALSeqFile *)buf;
|
||||
DEBUG_PRINT("- copying dma");
|
||||
audio_dma_copy_immediate((uintptr_t)data, gAlTbl, 0x10);
|
||||
DEBUG_PRINT("- tbl seq count: %d", gAlTbl->seqCount);
|
||||
size = gAlTbl->seqCount * sizeof(ALSeqData) + 4;
|
||||
DEBUG_PRINT("- size: %d", size);
|
||||
size = ALIGN16(size);
|
||||
DEBUG_PRINT("- size after align: %d", size);
|
||||
gAlTbl = soundAlloc(&gAudioInitPool, size);
|
||||
DEBUG_PRINT("- tbl alloc at %x", gAlTbl);
|
||||
DEBUG_PRINT("- gSoundDataRaw at %x", gSoundDataRaw);
|
||||
audio_dma_copy_immediate((uintptr_t)gSoundDataRaw, gAlTbl, size);
|
||||
alSeqFileNew(gAlTbl, (u8 *)gSoundDataRaw);
|
||||
|
||||
|
||||
@@ -447,10 +447,7 @@ void init_layer_freelist(void)
|
||||
|
||||
u8 m64_read_u8(struct M64ScriptState *state)
|
||||
{
|
||||
DEBUG_PRINT("m64_read_u8()");
|
||||
DEBUG_PRINT("- state at %x", state);
|
||||
u8 *midiArg = state->pc++;
|
||||
DEBUG_PRINT("- read u8 (%d) at (%x)", *midiArg, midiArg);
|
||||
return *midiArg;
|
||||
}
|
||||
|
||||
@@ -1205,10 +1202,8 @@ s32 seq_channel_layer_process_script_part2(struct SequenceChannelLayer *layer)
|
||||
break;
|
||||
|
||||
case 0xc6: // layer_setinstr
|
||||
DEBUG_PRINT(" - cmd 0xc6, setinstr");
|
||||
|
||||
cmd = m64_read_u8(state);
|
||||
DEBUG_PRINT(" - read %d from state", cmd);
|
||||
|
||||
if (cmd >= 0x7f)
|
||||
{
|
||||
@@ -1552,8 +1547,6 @@ s32 seq_channel_layer_process_script_part3(struct SequenceChannelLayer *layer, s
|
||||
|
||||
u8 get_instrument(struct SequenceChannel *seqChannel, u8 instId, struct Instrument **instOut, struct AdsrSettings *adsr)
|
||||
{
|
||||
DEBUG_PRINT("@ get_instrument()");
|
||||
DEBUG_PRINT("- instrument id: %d", instId);
|
||||
|
||||
struct Instrument *inst;
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
@@ -1619,9 +1612,6 @@ u8 get_instrument(struct SequenceChannel *seqChannel, u8 instId, struct Instrume
|
||||
|
||||
void set_instrument(struct SequenceChannel *seqChannel, u8 instId)
|
||||
{
|
||||
DEBUG_PRINT("@ set_instrument()");
|
||||
DEBUG_PRINT("- bank id: %d", seqChannel->bankId);
|
||||
DEBUG_PRINT("- instrument id: %d", instId);
|
||||
|
||||
if (instId >= 0x80)
|
||||
{
|
||||
@@ -1658,7 +1648,6 @@ void sequence_channel_set_volume(struct SequenceChannel *seqChannel, u8 volume)
|
||||
|
||||
void sequence_channel_process_script(struct SequenceChannel *seqChannel)
|
||||
{
|
||||
DEBUG_PRINT("sequence_channel_process_script()");
|
||||
|
||||
s8 temp;
|
||||
u8 loBits;
|
||||
@@ -1702,7 +1691,6 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel)
|
||||
for (;;)
|
||||
{
|
||||
u8 cmd = m64_read_u8(state);
|
||||
DEBUG_PRINT("- handling command: %x", cmd);
|
||||
|
||||
#if !defined(VERSION_EU) && !defined(VERSION_SH)
|
||||
if (cmd == 0xff) // chan_end
|
||||
@@ -1895,10 +1883,8 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel)
|
||||
#endif
|
||||
|
||||
case 0xc1: // chan_setinstr ("set program"?)
|
||||
DEBUG_PRINT(" - cmd 0xc1, setinstr");
|
||||
|
||||
u8 instrId = m64_read_u8(state);
|
||||
DEBUG_PRINT(" - read %d from state", instrId);
|
||||
|
||||
set_instrument(seqChannel, instrId);
|
||||
break;
|
||||
@@ -2030,12 +2016,9 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel)
|
||||
break;
|
||||
|
||||
case 0xc6: // chan_setbank; switch bank within set
|
||||
DEBUG_PRINT(" - case 0xc6 - switch bank");
|
||||
|
||||
DEBUG_PRINT(" - seq id %d", seqPlayer->seqId);
|
||||
|
||||
cmd = m64_read_u8(state);
|
||||
DEBUG_PRINT(" - backwards bank id %d", cmd);
|
||||
|
||||
// Switch to the temp's (0-indexed) bank in this sequence's
|
||||
// bank set. Note that in the binary format (not in the JSON!)
|
||||
@@ -2362,8 +2345,6 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel)
|
||||
#else
|
||||
case 0x80: // chan_ioreadval; read data from audio lib
|
||||
#endif
|
||||
DEBUG_PRINT("- cmd 0x80, read data from audio lib");
|
||||
DEBUG_PRINT(" - reading index: %d", loBits);
|
||||
value = seqChannel->soundScriptIO[loBits];
|
||||
if (loBits < 4)
|
||||
{
|
||||
@@ -2463,7 +2444,6 @@ out:
|
||||
|
||||
void sequence_player_process_sequence(struct SequencePlayer *seqPlayer)
|
||||
{
|
||||
DEBUG_PRINT("sequence_player_process_sequence()");
|
||||
|
||||
u8 cmd;
|
||||
#ifdef VERSION_SH
|
||||
|
||||
@@ -28,13 +28,9 @@
|
||||
#define DMEM_ADDR_WET_RIGHT_CH 0x880
|
||||
|
||||
#define aSetLoadBufferPair(pkt, c, off) \
|
||||
DEBUG_PRINT("- (in set load buffer pair, set buffer 1) "); \
|
||||
aSetBuffer(pkt, 0, c + DMEM_ADDR_WET_LEFT_CH, 0, DEFAULT_LEN_1CH - c); \
|
||||
DEBUG_PRINT("- (in set load buffer pair, load buffer 1) "); \
|
||||
aLoadBuffer(pkt, VIRTUAL_TO_PHYSICAL2(gSynthesisReverb.ringBuffer.left + (off))); \
|
||||
DEBUG_PRINT("- (in set load buffer pair, set buffer 2) "); \
|
||||
aSetBuffer(pkt, 0, c + DMEM_ADDR_WET_RIGHT_CH, 0, DEFAULT_LEN_1CH - c); \
|
||||
DEBUG_PRINT("- (in set load buffer pair, load buffer 2) "); \
|
||||
aLoadBuffer(pkt, VIRTUAL_TO_PHYSICAL2(gSynthesisReverb.ringBuffer.right + (off)))
|
||||
|
||||
#define aSetSaveBufferPair(pkt, c, d, off) \
|
||||
@@ -362,7 +358,6 @@ aiBufPtr+= chunkLen;
|
||||
// bufLen will be divisible by 16
|
||||
u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, s16 *aiBuf, s32 bufLen)
|
||||
{
|
||||
DEBUG_PRINT("synthesis_execute()");
|
||||
s32 chunkLen;
|
||||
u32 *aiBufPtr = (u32 *)aiBuf;
|
||||
u64 *cmd = cmdBuf + 1;
|
||||
@@ -583,66 +578,51 @@ u64 *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, u64 *cmd, s32 updateI
|
||||
#else
|
||||
u64 *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, u64 *cmd, s32 updateIndex)
|
||||
{
|
||||
DEBUG_PRINT("synthesis_do_one_audio_update()");
|
||||
|
||||
UNUSED s32 pad1[1];
|
||||
UNUSED s32 pad[2];
|
||||
UNUSED s32 pad2[1];
|
||||
s16 temp;
|
||||
|
||||
DEBUG_PRINT("- curFrame: %d", gSynthesisReverb.curFrame);
|
||||
DEBUG_PRINT("- updateIndex: %d", updateIndex);
|
||||
|
||||
struct ReverbRingBufferItem *v1 = &gSynthesisReverb.items[gSynthesisReverb.curFrame][updateIndex];
|
||||
DEBUG_PRINT("- v1: %x", v1);
|
||||
|
||||
if (gSynthesisReverb.useReverb == 0)
|
||||
{
|
||||
DEBUG_PRINT("- w/o reverb");
|
||||
aClearBuffer(cmd++, DMEM_ADDR_LEFT_CH, DEFAULT_LEN_2CH);
|
||||
cmd = synthesis_process_notes(aiBuf, bufLen, cmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_PRINT("- w/ reverb");
|
||||
if (gReverbDownsampleRate == 1)
|
||||
{
|
||||
DEBUG_PRINT("- w/ reverb downsample");
|
||||
|
||||
// Put the oldest samples in the ring buffer into the wet channels
|
||||
DEBUG_PRINT("- set load buffer pair 1");
|
||||
DEBUG_PRINT("- startPos: %d", v1->startPos);
|
||||
aSetLoadBufferPair(cmd++, 0, v1->startPos);
|
||||
if (v1->lengthB != 0)
|
||||
{
|
||||
// Ring buffer wrapped
|
||||
DEBUG_PRINT("- set load buffer pair 2");
|
||||
aSetLoadBufferPair(cmd++, v1->lengthA, 0);
|
||||
temp = 0;
|
||||
}
|
||||
|
||||
// Use the reverb sound as initial sound for this audio update
|
||||
DEBUG_PRINT("- dmem move");
|
||||
aDMEMMove(cmd++, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_LEFT_CH, DEFAULT_LEN_2CH);
|
||||
|
||||
// (Hopefully) lower the volume of the wet channels. New reverb will later be mixed into
|
||||
// these channels.
|
||||
DEBUG_PRINT("- set buffer");
|
||||
aSetBuffer(cmd++, 0, 0, 0, DEFAULT_LEN_2CH);
|
||||
// 0x8000 here is -100%
|
||||
DEBUG_PRINT("- mix");
|
||||
aMix(cmd++, 0, /*gain*/ 0x8000 + gSynthesisReverb.reverbGain, /*in*/ DMEM_ADDR_WET_LEFT_CH,
|
||||
/*out*/ DMEM_ADDR_WET_LEFT_CH);
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_PRINT("- w/o reverb downsample");
|
||||
|
||||
// Same as above but upsample the previously downsampled samples used for reverb first
|
||||
temp = 0; //! jesus christ
|
||||
s16 t4 = (v1->startPos & 7) * 2;
|
||||
s16 ra = ALIGN(v1->lengthA + t4, 4);
|
||||
DEBUG_PRINT("- set load buffer pair");
|
||||
aSetLoadBufferPair(cmd++, 0, v1->startPos - t4 / 2);
|
||||
if (v1->lengthB != 0)
|
||||
{
|
||||
@@ -654,19 +634,12 @@ u64 *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, u64 *cmd, s32 updateI
|
||||
//! useless assignment.
|
||||
ra = ra + temp;
|
||||
}
|
||||
DEBUG_PRINT("- set buffer 1");
|
||||
aSetBuffer(cmd++, 0, t4 + DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_LEFT_CH, bufLen << 1);
|
||||
DEBUG_PRINT("- resample 1");
|
||||
aResample(cmd++, gSynthesisReverb.resampleFlags, gSynthesisReverb.resampleRate, VIRTUAL_TO_PHYSICAL2(gSynthesisReverb.resampleStateLeft));
|
||||
DEBUG_PRINT("- set buffer 2");
|
||||
aSetBuffer(cmd++, 0, t4 + DMEM_ADDR_WET_RIGHT_CH, DMEM_ADDR_RIGHT_CH, bufLen << 1);
|
||||
DEBUG_PRINT("- resample 2");
|
||||
aResample(cmd++, gSynthesisReverb.resampleFlags, gSynthesisReverb.resampleRate, VIRTUAL_TO_PHYSICAL2(gSynthesisReverb.resampleStateRight));
|
||||
DEBUG_PRINT("- set buffer 3");
|
||||
aSetBuffer(cmd++, 0, 0, 0, DEFAULT_LEN_2CH);
|
||||
DEBUG_PRINT("- mix");
|
||||
aMix(cmd++, 0, /*gain*/ 0x8000 + gSynthesisReverb.reverbGain, /*in*/ DMEM_ADDR_LEFT_CH, /*out*/ DMEM_ADDR_LEFT_CH);
|
||||
DEBUG_PRINT("- dmem move");
|
||||
aDMEMMove(cmd++, DMEM_ADDR_LEFT_CH, DMEM_ADDR_WET_LEFT_CH, DEFAULT_LEN_2CH);
|
||||
}
|
||||
cmd = synthesis_process_notes(aiBuf, bufLen, cmd);
|
||||
@@ -700,7 +673,6 @@ u64 *synthesis_process_note(struct Note *note, struct NoteSubEu *noteSubEu, stru
|
||||
#else
|
||||
u64 *synthesis_process_notes(s16 *aiBuf, s32 bufLen, u64 *cmd)
|
||||
{
|
||||
DEBUG_PRINT("synthesis_process_notes()");
|
||||
|
||||
s32 noteIndex; // sp174
|
||||
struct Note *note; // s7
|
||||
@@ -787,29 +759,22 @@ u64 *synthesis_process_notes(s16 *aiBuf, s32 bufLen, u64 *cmd)
|
||||
|
||||
for (noteIndex = 0; noteIndex < gMaxSimultaneousNotes; noteIndex++)
|
||||
{
|
||||
DEBUG_PRINT("- for note index %d/%d", noteIndex, gMaxSimultaneousNotes);
|
||||
|
||||
DEBUG_PRINT("- getting note");
|
||||
note = &gNotes[noteIndex];
|
||||
|
||||
//! This function requires note->enabled to be volatile, but it breaks other functions like note_enable.
|
||||
//! Casting to a struct with just the volatile bitfield works, but there may be a better way to match.
|
||||
DEBUG_PRINT("- if note is enabled but not loaded");
|
||||
if (((struct vNote *)note)->enabled && IS_BANK_LOAD_COMPLETE(note->bankId) == FALSE)
|
||||
{
|
||||
DEBUG_PRINT("- note is enabled but not loaded");
|
||||
gAudioErrorFlags = (note->bankId << 8) + noteIndex + 0x1000000;
|
||||
continue;
|
||||
}
|
||||
|
||||
DEBUG_PRINT("- if note is enabled");
|
||||
if (((struct vNote *)note)->enabled)
|
||||
{
|
||||
DEBUG_PRINT("$ note is enabled!");
|
||||
|
||||
flags = 0;
|
||||
|
||||
DEBUG_PRINT("- if note needs to be init");
|
||||
if (note->needsInit == TRUE)
|
||||
{
|
||||
flags = A_INIT;
|
||||
@@ -817,7 +782,6 @@ u64 *synthesis_process_notes(s16 *aiBuf, s32 bufLen, u64 *cmd)
|
||||
note->samplePosFrac = 0;
|
||||
}
|
||||
|
||||
DEBUG_PRINT("- if note frequency is less than 2");
|
||||
if (note->frequency < US_FLOAT(2.0))
|
||||
{
|
||||
nParts = 1;
|
||||
@@ -842,12 +806,10 @@ u64 *synthesis_process_notes(s16 *aiBuf, s32 bufLen, u64 *cmd)
|
||||
samplesLenFixedPoint = note->samplePosFrac + resamplingRateFixedPoint * bufLen * 2;
|
||||
note->samplePosFrac = samplesLenFixedPoint & 0xFFFF; // 16-bit store, can't reuse
|
||||
|
||||
DEBUG_PRINT("- if note sound is null");
|
||||
if (note->sound == NULL)
|
||||
{
|
||||
// A wave synthesis note (not ADPCM)
|
||||
|
||||
DEBUG_PRINT("- note is null, do wave synthesis");
|
||||
cmd = load_wave_samples(cmd, note, samplesLenFixedPoint >> 0x10);
|
||||
noteSamplesDmemAddrBeforeResampling = DMEM_ADDR_UNCOMPRESSED_NOTE + note->samplePosInt * 2;
|
||||
note->samplePosInt += samplesLenFixedPoint >> 0x10;
|
||||
@@ -856,7 +818,6 @@ u64 *synthesis_process_notes(s16 *aiBuf, s32 bufLen, u64 *cmd)
|
||||
else
|
||||
{
|
||||
// ADPCM note
|
||||
DEBUG_PRINT("- @ handle adpcm note");
|
||||
|
||||
audioBookSample = note->sound->sample;
|
||||
|
||||
@@ -866,7 +827,6 @@ u64 *synthesis_process_notes(s16 *aiBuf, s32 bufLen, u64 *cmd)
|
||||
resampledTempLen = 0;
|
||||
for (curPart = 0; curPart < nParts; curPart++)
|
||||
{
|
||||
DEBUG_PRINT("- for part %d", curPart);
|
||||
nAdpcmSamplesProcessed = 0; // s8
|
||||
s5 = 0; // s4
|
||||
|
||||
@@ -888,7 +848,6 @@ u64 *synthesis_process_notes(s16 *aiBuf, s32 bufLen, u64 *cmd)
|
||||
u32 nEntries; // v1
|
||||
curLoadedBook = audioBookSample->book->book;
|
||||
nEntries = audioBookSample->book->order * audioBookSample->book->npredictors;
|
||||
DEBUG_PRINT("- loading adpcm");
|
||||
aLoadADPCM(cmd++, nEntries * 16, VIRTUAL_TO_PHYSICAL2(curLoadedBook));
|
||||
}
|
||||
|
||||
@@ -952,7 +911,6 @@ u64 *synthesis_process_notes(s16 *aiBuf, s32 bufLen, u64 *cmd)
|
||||
a3 = 0;
|
||||
}
|
||||
|
||||
DEBUG_PRINT("- if not note restart");
|
||||
if (note->restart != FALSE)
|
||||
{
|
||||
aSetLoop(cmd++, VIRTUAL_TO_PHYSICAL2(audioBookSample->loop->state));
|
||||
@@ -1000,7 +958,6 @@ u64 *synthesis_process_notes(s16 *aiBuf, s32 bufLen, u64 *cmd)
|
||||
}
|
||||
flags = 0;
|
||||
|
||||
DEBUG_PRINT("- if note finished");
|
||||
if (noteFinished)
|
||||
{
|
||||
aClearBuffer(cmd++, DMEM_ADDR_UNCOMPRESSED_NOTE + s5,
|
||||
@@ -1011,7 +968,6 @@ u64 *synthesis_process_notes(s16 *aiBuf, s32 bufLen, u64 *cmd)
|
||||
break;
|
||||
}
|
||||
|
||||
DEBUG_PRINT("- if restart");
|
||||
if (restart)
|
||||
{
|
||||
note->restart = TRUE;
|
||||
@@ -1097,20 +1053,14 @@ u64 *synthesis_process_notes(s16 *aiBuf, s32 bufLen, u64 *cmd)
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_PRINT("- done handling notes");
|
||||
|
||||
DEBUG_PRINT("- setting buffer 1");
|
||||
t9 = bufLen * 2;
|
||||
aSetBuffer(cmd++, 0, 0, DMEM_ADDR_TEMP, t9);
|
||||
DEBUG_PRINT("- interleaving");
|
||||
aInterleave(cmd++, DMEM_ADDR_LEFT_CH, DMEM_ADDR_RIGHT_CH);
|
||||
t9 *= 2;
|
||||
DEBUG_PRINT("- setting buffer 2");
|
||||
aSetBuffer(cmd++, 0, 0, DMEM_ADDR_TEMP, t9);
|
||||
DEBUG_PRINT("- saving buffer");
|
||||
aSaveBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(aiBuf));
|
||||
|
||||
DEBUG_PRINT("- returning from process notes");
|
||||
return cmd;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user