summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKiritoDv <kiritodev01@gmail.com>2024-11-09 20:45:31 -0600
committerKiritoDv <kiritodev01@gmail.com>2024-11-09 20:45:31 -0600
commitcd48d2cefac7d162242cc2d335ec3bd10b0f8cd2 (patch)
treeeaa694a663eda00eae26937f3d3f343d3e8b67dd
parent4acc13fb36523ba270b3b921ffd1328610e0a58c (diff)
Updated audio
-rw-r--r--src/audio/audio_context.c58
-rw-r--r--src/audio/audio_heap.c8
-rw-r--r--src/audio/audio_load.c17
-rw-r--r--src/audio/audio_synthesis.c10
-rw-r--r--src/audio/audio_thread.c10
-rw-r--r--src/audio/mixer.c12
-rw-r--r--src/libultra/io/aisetfreq.c1
-rw-r--r--src/port/Engine.cpp9
-rw-r--r--src/port/Engine.h7
-rw-r--r--src/port/resource/loaders/AudioLoader.cpp5
10 files changed, 73 insertions, 64 deletions
diff --git a/src/audio/audio_context.c b/src/audio/audio_context.c
index 8f33028c..7cecdaf3 100644
--- a/src/audio/audio_context.c
+++ b/src/audio/audio_context.c
@@ -144,91 +144,91 @@ ReverbSettings D_800C76A8[] = {
{ 1, 0x30, 0x4FFF, 0, 0 },
};
AudioSpec gAudioSpecs[] = {
- /* 0 */ { 32000, 2, 22, ARRAY_COUNT(D_800C74D0), D_800C74D0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
+ /* 0 */ { 44100, 2, 22, ARRAY_COUNT(D_800C74D0), D_800C74D0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 1 */
- { 32000, 2, 22, ARRAY_COUNT(D_800C74E0), D_800C74E0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
+ { 44100, 2, 22, ARRAY_COUNT(D_800C74E0), D_800C74E0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 2 */
- { 32000, 2, 22, ARRAY_COUNT(D_800C74F0), D_800C74F0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
+ { 44100, 2, 22, ARRAY_COUNT(D_800C74F0), D_800C74F0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 3 */
- { 32000, 2, 22, ARRAY_COUNT(D_800C7500), D_800C7500, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
+ { 44100, 2, 22, ARRAY_COUNT(D_800C7500), D_800C7500, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 4 */
- { 32000, 2, 22, ARRAY_COUNT(D_800C7510), D_800C7510, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
+ { 44100, 2, 22, ARRAY_COUNT(D_800C7510), D_800C7510, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 5 */
- { 32000, 2, 22, ARRAY_COUNT(D_800C7520), D_800C7520, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
+ { 44100, 2, 22, ARRAY_COUNT(D_800C7520), D_800C7520, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 6 */
- { 32000, 2, 22, ARRAY_COUNT(D_800C7530), D_800C7530, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
+ { 44100, 2, 22, ARRAY_COUNT(D_800C7530), D_800C7530, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 7 */
- { 32000, 2, 22, ARRAY_COUNT(D_800C7540), D_800C7540, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
+ { 44100, 2, 22, ARRAY_COUNT(D_800C7540), D_800C7540, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 8 */
- { 32000, 2, 22, ARRAY_COUNT(D_800C7550), D_800C7550, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
+ { 44100, 2, 22, ARRAY_COUNT(D_800C7550), D_800C7550, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 9 */
- { 32000, 2, 22, ARRAY_COUNT(D_800C7560), D_800C7560, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
+ { 44100, 2, 22, ARRAY_COUNT(D_800C7560), D_800C7560, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 10 */
- { 32000, 2, 22, ARRAY_COUNT(D_800C7570), D_800C7570, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
+ { 44100, 2, 22, ARRAY_COUNT(D_800C7570), D_800C7570, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 11 */
- { 32000, 2, 22, ARRAY_COUNT(D_800C7580), D_800C7580, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
+ { 44100, 2, 22, ARRAY_COUNT(D_800C7580), D_800C7580, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 12 */
- { 32000, 1, 22, ARRAY_COUNT(D_800C7590), D_800C7590, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x2B000,
+ { 44100, 1, 22, ARRAY_COUNT(D_800C7590), D_800C7590, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x2B000,
0x35000 },
/* 13 */
- { 32000, 2, 22, ARRAY_COUNT(D_800C75A0), D_800C75A0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
+ { 44100, 2, 22, ARRAY_COUNT(D_800C75A0), D_800C75A0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 14 */
- { 32000, 2, 22, ARRAY_COUNT(D_800C75B0), D_800C75B0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
+ { 44100, 2, 22, ARRAY_COUNT(D_800C75B0), D_800C75B0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 15 */
- { 32000, 2, 22, ARRAY_COUNT(D_800C75C0), D_800C75C0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
+ { 44100, 2, 22, ARRAY_COUNT(D_800C75C0), D_800C75C0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x34000 },
/* 16 */
- { 32000, 2, 22, ARRAY_COUNT(D_800C75D8), D_800C75D8, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
+ { 44100, 2, 22, ARRAY_COUNT(D_800C75D8), D_800C75D8, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 17 */
- { 32000, 2, 22, ARRAY_COUNT(D_800C75E8), D_800C75E8, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
+ { 44100, 2, 22, ARRAY_COUNT(D_800C75E8), D_800C75E8, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 18 */
- { 32000, 2, 22, ARRAY_COUNT(D_800C75F8), D_800C75F8, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
+ { 44100, 2, 22, ARRAY_COUNT(D_800C75F8), D_800C75F8, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 19 */
- { 32000, 2, 22, ARRAY_COUNT(D_800C7608), D_800C7608, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
+ { 44100, 2, 22, ARRAY_COUNT(D_800C7608), D_800C7608, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 20 */
- { 32000, 2, 22, ARRAY_COUNT(D_800C7618), D_800C7618, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
+ { 44100, 2, 22, ARRAY_COUNT(D_800C7618), D_800C7618, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 21 */
- { 32000, 2, 32, ARRAY_COUNT(D_800C7628), D_800C7628, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
+ { 44100, 2, 32, ARRAY_COUNT(D_800C7628), D_800C7628, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x00000 },
/* 22 */
- { 32000, 1, 32, ARRAY_COUNT(D_800C7638), D_800C7638, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
+ { 44100, 1, 32, ARRAY_COUNT(D_800C7638), D_800C7638, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x00000 },
/* 23 */
- { 32000, 1, 32, ARRAY_COUNT(D_800C7648), D_800C7648, 0x7FFF, 0x1200, 0xA000, 0, 0x5B00, 0x1D00, 0, 0x00000,
+ { 44100, 1, 32, ARRAY_COUNT(D_800C7648), D_800C7648, 0x7FFF, 0x1200, 0xA000, 0, 0x5B00, 0x1D00, 0, 0x00000,
0x00000 },
/* 24 */
- { 32000, 1, 22, ARRAY_COUNT(D_800C7658), D_800C7658, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x00000,
+ { 44100, 1, 22, ARRAY_COUNT(D_800C7658), D_800C7658, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x00000,
0x60000 },
/* 25 */
- { 32000, 2, 22, ARRAY_COUNT(D_800C7668), D_800C7668, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
+ { 44100, 2, 22, ARRAY_COUNT(D_800C7668), D_800C7668, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x00000 },
/* 26 */
- { 32000, 2, 22, ARRAY_COUNT(D_800C7678), D_800C7678, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
+ { 44100, 2, 22, ARRAY_COUNT(D_800C7678), D_800C7678, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x00000 },
/* 27 */
- { 32000, 2, 32, ARRAY_COUNT(D_800C7688), D_800C7688, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
+ { 44100, 2, 32, ARRAY_COUNT(D_800C7688), D_800C7688, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x00000 },
/* 28 */
- { 32000, 2, 22, ARRAY_COUNT(D_800C74D0), D_800C74D0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
+ { 44100, 2, 22, ARRAY_COUNT(D_800C74D0), D_800C74D0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
};
s32 D_800C7C28 = 0x20000000; // unused?
diff --git a/src/audio/audio_heap.c b/src/audio/audio_heap.c
index 1e15902b..769d920d 100644
--- a/src/audio/audio_heap.c
+++ b/src/audio/audio_heap.c
@@ -647,7 +647,7 @@ void AudioHeap_Init(void) {
gSampleDmaCount = 0;
gAudioBufferParams.samplingFrequency = spec->samplingFrequency;
- gAudioBufferParams.aiSamplingFrequency = 32000;
+ gAudioBufferParams.aiSamplingFrequency = osAiSetFrequency(gAudioBufferParams.samplingFrequency);
gAudioBufferParams.samplesPerFrameTarget = ALIGN16(gAudioBufferParams.samplingFrequency / gRefreshRate);
printf("aiSamplingFrequency %d\n", gAudioBufferParams.aiSamplingFrequency);
@@ -672,9 +672,9 @@ void AudioHeap_Init(void) {
gAudioBufferParams.maxAiBufferLength *= gAudioBufferParams.count;
gAudioBufferParams.minAiBufferLength *= gAudioBufferParams.count;
gAudioBufferParams.ticksPerUpdate *= gAudioBufferParams.count;
- if (gAudioBufferParams.count >= 2) {
- gAudioBufferParams.maxAiBufferLength -= 0x10;
- }
+ if (gAudioBufferParams.count >= 2) {
+ gAudioBufferParams.maxAiBufferLength -= 0x10;
+ }
gMaxAudioCmds = (gNumNotes * 20 * gAudioBufferParams.ticksPerUpdate) + (spec->numReverbs * 32) + 480;
persistentSize = spec->persistentSeqCacheSize + spec->persistentFontCacheSize +
spec->persistentSampleBankCacheSize + spec->persistentSampleCacheSize + 0x10;
diff --git a/src/audio/audio_load.c b/src/audio/audio_load.c
index ae690892..4a4b7ef3 100644
--- a/src/audio/audio_load.c
+++ b/src/audio/audio_load.c
@@ -311,10 +311,8 @@ s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId) {
}
void AudioLoad_AsyncLoadSampleBank(s32 sampleBankId, s32 nChunks, s32 retData, OSMesgQueue* retQueue) {
- if (AudioLoad_AsyncLoadInner(SAMPLE_TABLE, AudioLoad_GetLoadTableIndex(SAMPLE_TABLE, sampleBankId), nChunks,
- retData, retQueue) == NULL) {
- osSendMesg(retQueue, OS_MESG_PTR(NULL), OS_MESG_NOBLOCK);
- }
+ AudioLoad_AsyncLoadInner(SAMPLE_TABLE, AudioLoad_GetLoadTableIndex(SAMPLE_TABLE, sampleBankId), nChunks, retData, retQueue);
+ osSendMesg(retQueue, OS_MESG_PTR(NULL), OS_MESG_NOBLOCK);
}
void AudioLoad_AsyncLoadSeq(s32 seqId, s32 nChunks, s32 retData, OSMesgQueue* retQueue) {
@@ -430,6 +428,10 @@ void* AudioLoad_SyncLoadSampleBank(u32 sampleBankId, s32* outMedium) {
s32 noLoad;
sampleBankId = AudioLoad_GetLoadTableIndex(SAMPLE_TABLE, sampleBankId);
+ gSampleFontLoadStatus[sampleBankId] = 2;
+
+ return Audio_LoadBlob(gAudioTable, sampleBankTable->entries[sampleBankId].romAddr);
+
ramAddr = AudioLoad_SearchCaches(2, sampleBankId);
if (ramAddr != NULL) {
if (gSampleFontLoadStatus[sampleBankId] != 5) {
@@ -520,7 +522,6 @@ void* AudioLoad_SyncLoad(u32 tableType, u32 id, s32* didAllocate) {
return Audio_LoadBlob(gAudioSeq, table->entries[id].romAddr);
case FONT_TABLE:
gFontLoadStatus[id] = LOAD_STATUS_COMPLETE;
- printf("fontId: %d\n", id);
return Audio_LoadFont(table->entries[id]);
case SAMPLE_TABLE:
loadStatus = 0;
@@ -705,10 +706,12 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData,
switch (tableType) {
case SEQUENCE_TABLE:
gFontLoadStatus[id] = LOAD_STATUS_COMPLETE;
+ osSendMesg(retQueue, OS_MESG_32(retData << 0x18), OS_MESG_NOBLOCK);
return Audio_LoadBlob(gAudioSeq, table->entries[id].romAddr);
case FONT_TABLE:
gFontLoadStatus[id] = LOAD_STATUS_COMPLETE;
printf("fontId: %d\n", id);
+ osSendMesg(retQueue, OS_MESG_32(retData << 0x18), OS_MESG_NOBLOCK);
return Audio_LoadFont(table->entries[id]);
case SAMPLE_TABLE:
gSampleFontLoadStatus[id] = LOAD_STATUS_COMPLETE;
@@ -790,7 +793,7 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData,
}
void AudioLoad_ProcessLoads(s32 resetStatus) {
- AudioLoad_ProcessSlowLoads(resetStatus);
+ // AudioLoad_ProcessSlowLoads(resetStatus);
// AudioLoad_ProcessSamplePreloads(resetStatus);
// AudioLoad_ProcessAsyncLoads(resetStatus);
}
@@ -903,6 +906,8 @@ s32 AudioLoad_SlowLoadSample(s32 fontId, u8 instId, s8* status) {
AudioSlowLoad* slowLoad;
sample = AudioLoad_GetFontSample(fontId, instId);
+ return 0;
+
if (sample == NULL) {
*status = SLOW_LOAD_STATUS_0;
return -1;
diff --git a/src/audio/audio_synthesis.c b/src/audio/audio_synthesis.c
index f446bcc4..0ed75e8d 100644
--- a/src/audio/audio_synthesis.c
+++ b/src/audio/audio_synthesis.c
@@ -644,7 +644,7 @@ Acmd* func_80009B64(Acmd* aList, s32* cmdCount, s16* aiBufStart, s32 aiBufLen) {
}
aiBufPtr = (s32*) aiBufStart;
- for (i = gAudioBufferParams.ticksPerUpdate; i > 0; i--) {
+ for (i = gAudioBufferParams.ticksPerUpdate - 1; i > 0; i--) {
if (i == 1) {
chunkLen = aiBufLen;
} else if ((aiBufLen / i) >= gAudioBufferParams.samplesPerTickMax) {
@@ -1000,18 +1000,18 @@ Acmd* func_8000A700(s32 noteIndex, NoteSubEu* noteSub, NoteSynthesisState* synth
skipBytes = 0;
goto skip;
}
- aligned = ALIGN16(nFramesToDecode * frameSize + SAMPLES_PER_FRAME);
+ aligned = ALIGN16(nFramesToDecode * frameSize + 0x10);
addr = 0x990 - aligned;
if (nFramesToDecode != 0) {
// LTODO: Validate this
// bookSample->medium = 0;
- frameIndex = (synthState->samplePosInt + skipInitialSamples - nFirstFrameSamplesToIgnore) / SAMPLES_PER_FRAME;
+ frameIndex = (synthState->samplePosInt + skipInitialSamples - nFirstFrameSamplesToIgnore) / 16;
sampleDataOffset = frameIndex * frameSize;
if (bookSample->medium == 0) {
- sampleData = sampleDataOffset + sampleAddr;
+ sampleData = sampleDmaStart + sampleDataOffset + sampleAddr;
} else {
- sampleData = sampleDataOffset + sampleAddr;
+ sampleData = sampleDmaStart + sampleDataOffset + sampleAddr;
}
// if (1){}
sampleDataStartPad = (uintptr_t) sampleData & 0xF;
diff --git a/src/audio/audio_thread.c b/src/audio/audio_thread.c
index 0ccbba46..f60cf6af 100644
--- a/src/audio/audio_thread.c
+++ b/src/audio/audio_thread.c
@@ -48,7 +48,7 @@ void AudioThread_CreateNextAudioBuffer(s16 *samples, u32 num_samples) {
gCurAudioFrameDmaCount = 0;
AudioLoad_DecreaseSampleDmaTtls();
- // AudioLoad_ProcessLoads(gAudioResetStep);
+ AudioLoad_ProcessLoads(gAudioResetStep);
if (MQ_GET_MESG(gAudioSpecQueue, &specId)) {
if (gAudioResetStep == 0) {
@@ -80,6 +80,7 @@ void AudioThread_CreateNextAudioBuffer(s16 *samples, u32 num_samples) {
}
gCurAbiCmdBuffer = func_80009B64(gCurAbiCmdBuffer, &abiCmdCount, samples, num_samples);
+ memcpy(gAiBuffers[gCurAiBuffIndex], samples, num_samples);
gAudioRandom = osGetCount() * (gAudioRandom + gAudioTaskCountQ);
gAudioCurTask->msg = OS_MESG_PTR(NULL);
@@ -347,7 +348,7 @@ void AudioThread_ScheduleProcessCmds(void) {
D_800C7C70 = (u8) (gThreadCmdWritePos - gThreadCmdReadPos + 0x100);
}
msg = (((gThreadCmdReadPos & 0xFF) << 8) | (gThreadCmdWritePos & 0xFF));
- osSendMesg32(gThreadCmdProcQueue, msg, OS_MESG_NOBLOCK);
+ osSendMesg(gThreadCmdProcQueue, OS_MESG_32(msg), OS_MESG_NOBLOCK);
gThreadCmdReadPos = gThreadCmdWritePos;
}
@@ -364,11 +365,10 @@ void AudioThread_ProcessCmds(u32 msg) {
u8 writePos;
if (!gThreadCmdQueueFinished) {
- gCurCmdReadPos = msg >> 8;
+ gCurCmdReadPos = (msg >> 8) & 0xFF;
}
-
+ writePos = msg & 0xFF;
while (true) {
- writePos = msg & 0xFF;
if (gCurCmdReadPos == writePos) {
gThreadCmdQueueFinished = 0;
diff --git a/src/audio/mixer.c b/src/audio/mixer.c
index 1ff6768c..1c8225b7 100644
--- a/src/audio/mixer.c
+++ b/src/audio/mixer.c
@@ -126,10 +126,16 @@ void aSetBufferImpl(uint8_t flags, uint16_t in, uint16_t out, uint16_t nbytes) {
}
void aInterleaveImpl(uint16_t dest, uint16_t left, uint16_t right, uint16_t c) {
- int count = ROUND_UP_8(c) / sizeof(int16_t) / 4;
+ if(rspa.nbytes == 0){
+ return;
+ }
+
+ int count = ROUND_UP_32(rspa.nbytes) >> 3;
+
int16_t *l = BUF_S16(left);
int16_t *r = BUF_S16(right);
- int16_t *d = BUF_S16(dest);
+ int16_t *d = BUF_S16(rspa.out);
+
while (count > 0) {
int16_t l0 = *l++;
int16_t l1 = *l++;
@@ -277,7 +283,7 @@ void aEnvSetup2Impl(uint16_t initial_vol_left, uint16_t initial_vol_right) {
void aEnvMixerImpl(uint16_t in_addr, uint16_t n_samples, bool swap_reverb,
bool neg_3, bool neg_2,
bool neg_left, bool neg_right,
- int32_t wet_dry_addr, u32 unk)
+ int32_t wet_dry_addr, uint32_t unk)
{
int16_t *in = BUF_S16(in_addr);
int16_t *dry[2] = {BUF_S16(((wet_dry_addr >> 24) & 0xFF) << 4), BUF_S16(((wet_dry_addr >> 16) & 0xFF) << 4)};
diff --git a/src/libultra/io/aisetfreq.c b/src/libultra/io/aisetfreq.c
index 97b07f58..7847ece7 100644
--- a/src/libultra/io/aisetfreq.c
+++ b/src/libultra/io/aisetfreq.c
@@ -4,6 +4,7 @@ s32 osViClock2 = 0x02E6D354;
s32 osAiSetFrequency(u32 freq) {
return 1;
+
register u32 a1;
register s32 a2;
register float ftmp;
diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp
index acf4028b..79a9761e 100644
--- a/src/port/Engine.cpp
+++ b/src/port/Engine.cpp
@@ -66,7 +66,7 @@ GameEngine::GameEngine() {
}
}
- this->context = Ship::Context::CreateInstance("Starship", "ship", "starship.cfg.json", OTRFiles, {}, 3, { 32000, 512, 1100 });
+ this->context = Ship::Context::CreateInstance("Starship", "ship", "starship.cfg.json", OTRFiles, {}, 3, { 44100, 1024, 2480 });
auto loader = context->GetResourceManager()->GetResourceLoader();
loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryAnimV0>(), RESOURCE_FORMAT_BINARY, "Animation", static_cast<uint32_t>(SF64::ResourceType::AnimData), 0);
@@ -134,12 +134,15 @@ void GameEngine::HandleAudioThread(){
break;
}
}
+
+ #define AUDIO_FRAMES_PER_UPDATE (gVIsPerFrame > 0 ? gVIsPerFrame : 1 )
+
std::unique_lock<std::mutex> Lock(audio.mutex);
int samples_left = AudioPlayerBuffered();
u32 num_audio_samples = samples_left < AudioPlayerGetDesiredBuffered() ? SAMPLES_HIGH : SAMPLES_LOW;
s16 audio_buffer[SAMPLES_PER_FRAME];
- for (int i = 0; i < NUM_AUDIO_CHANNELS; i++) {
- AudioThread_CreateNextAudioBuffer(audio_buffer + i * (num_audio_samples * 2), num_audio_samples);
+ for (int i = 0; i < AUDIO_FRAMES_PER_UPDATE; i++) {
+ AudioThread_CreateNextAudioBuffer(audio_buffer + i * (num_audio_samples * NUM_AUDIO_CHANNELS), num_audio_samples);
}
AudioPlayerPlayFrame((u8 *) audio_buffer, num_audio_samples * (sizeof(int16_t) * NUM_AUDIO_CHANNELS * AUDIO_FRAMES_PER_UPDATE));
audio.processing = false;
diff --git a/src/port/Engine.h b/src/port/Engine.h
index e222330d..74b63f2e 100644
--- a/src/port/Engine.h
+++ b/src/port/Engine.h
@@ -15,11 +15,10 @@ struct GamePool {
#include <Fast3D/gfx_pc.h>
#include "libultraship/src/Context.h"
-#define SAMPLES_HIGH 544
-#define SAMPLES_LOW 528
-#define AUDIO_FRAMES_PER_UPDATE 2
+#define SAMPLES_HIGH 752
+#define SAMPLES_LOW 720
#define NUM_AUDIO_CHANNELS 2
-#define SAMPLES_PER_FRAME (SAMPLES_HIGH * NUM_AUDIO_CHANNELS * 2)
+#define SAMPLES_PER_FRAME (SAMPLES_HIGH * NUM_AUDIO_CHANNELS * 3)
class GameEngine {
public:
diff --git a/src/port/resource/loaders/AudioLoader.cpp b/src/port/resource/loaders/AudioLoader.cpp
index 4ebe0d74..bb851d09 100644
--- a/src/port/resource/loaders/AudioLoader.cpp
+++ b/src/port/resource/loaders/AudioLoader.cpp
@@ -139,11 +139,6 @@ Sample* Audio_LoadSample(uint32_t sampleAddr, AudioTableEntry entry, uint32_t sa
sample->isRelocated = 1;
sample->medium = MEDIUM_RAM;
- std::filesystem::path path{ "dumps/" + std::to_string(addr) + ".raw" };
- std::ofstream ofs(path);
- ofs.write(reinterpret_cast<const char*>(sample->sampleAddr), sample->size);
- ofs.close();
-
gUsedSamples[gNumUsedSamples++] = sample;
return sample;
}