You've already forked Microtransactions64
mirror of
https://github.com/Print-and-Panic/Microtransactions64.git
synced 2026-01-21 10:17:19 -08:00
Audio just loads once on EU now lol
This commit is contained in:
@@ -8,32 +8,39 @@ extern struct OSMesgQueue OSMesgQueue1;
|
||||
extern struct OSMesgQueue OSMesgQueue2;
|
||||
extern struct OSMesgQueue OSMesgQueue3;
|
||||
|
||||
//Since the audio session is just one now, the reverb settings are duplicated to match the original audio setting scenario.
|
||||
//It's a bit hacky but whatever lol.
|
||||
#ifdef VERSION_EU
|
||||
struct ReverbSettingsEU sReverbSettings[] = {
|
||||
{ 0x04, 0x0c, 0x2fff },
|
||||
{ 0x04, 0x0a, 0x47ff },
|
||||
{ 0x04, 0x10, 0x2fff },
|
||||
{ 0x04, 0x0e, 0x3fff },
|
||||
{ 0x04, 0x0c, 0x4fff },
|
||||
{ 0x04, 0x0a, 0x37ff }
|
||||
{/*Downsample Rate*/ 4,/*Window Size*/ 16,/*Gain*/ 0x2FFF },
|
||||
{/*Downsample Rate*/ 4,/*Window Size*/ 10,/*Gain*/ 0x47FF },
|
||||
{/*Downsample Rate*/ 4,/*Window Size*/ 16,/*Gain*/ 0x2FFF },
|
||||
{/*Downsample Rate*/ 4,/*Window Size*/ 15,/*Gain*/ 0x3FFF },
|
||||
{/*Downsample Rate*/ 4,/*Window Size*/ 12,/*Gain*/ 0x4FFF },
|
||||
{/*Downsample Rate*/ 4,/*Window Size*/ 16,/*Gain*/ 0x2FFF }, //Duplicate of the first index
|
||||
{/*Downsample Rate*/ 4,/*Window Size*/ 10,/*Gain*/ 0x47FF }, //Duplicate of the second index
|
||||
{/*Downsample Rate*/ 4,/*Window Size*/ 10,/*Gain*/ 0x37FF },
|
||||
};
|
||||
/**
|
||||
1: Frequency
|
||||
2: Unk1 - Should be 1
|
||||
3: Simultaneous Notes
|
||||
4: Number of Reverberations
|
||||
5: Unk2 - Should be 0
|
||||
6: Volume
|
||||
7: Unk3 - Should be 0
|
||||
8: Persistent Sequence Memory
|
||||
9: Persistent Bank Memory
|
||||
10: Temporary Sequence Memory
|
||||
11: Temporary Bank Memory
|
||||
*/
|
||||
|
||||
struct AudioSessionSettingsEU gAudioSessionPresets[] = {
|
||||
{ 0x00007d00, 0x01, 0x10, 0x01, 0x00, &sReverbSettings[0], 0x7fff, 0x0000, 0x00003a40, 0x00006d00,
|
||||
0x00004400, 0x00002a00 },
|
||||
{ 0x00007d00, 0x01, 0x10, 0x01, 0x00, &sReverbSettings[1], 0x7fff, 0x0000, 0x00003a40, 0x00006d00,
|
||||
0x00004400, 0x00002a00 },
|
||||
{ 0x00007d00, 0x01, 0x10, 0x01, 0x00, &sReverbSettings[2], 0x7fff, 0x0000, 0x00003a40, 0x00006d00,
|
||||
0x00004400, 0x00002a00 },
|
||||
{ 0x00007d00, 0x01, 0x10, 0x01, 0x00, &sReverbSettings[3], 0x7fff, 0x0000, 0x00003a40, 0x00006d00,
|
||||
0x00004400, 0x00002a00 },
|
||||
{ 0x00007d00, 0x01, 0x10, 0x01, 0x00, &sReverbSettings[4], 0x7fff, 0x0000, 0x00003a40, 0x00006d00,
|
||||
0x00004400, 0x00002a00 },
|
||||
{ 0x00007d00, 0x01, 0x10, 0x01, 0x00, &sReverbSettings[0], 0x7fff, 0x0000, 0x00004000, 0x00006e00,
|
||||
0x00003f00, 0x00002a00 },
|
||||
{ 0x00007d00, 0x01, 0x10, 0x01, 0x00, &sReverbSettings[1], 0x7fff, 0x0000, 0x00004100, 0x00006e00,
|
||||
0x00004400, 0x00002a80 },
|
||||
{ 0x00007d00, 0x01, 0x14, 0x01, 0x00, &sReverbSettings[5], 0x7fff, 0x0000, 0x00003500, 0x00006280,
|
||||
0x00004000, 0x00001b00 }
|
||||
#ifdef EXPAND_AUDIO_HEAP
|
||||
{/*1*/ 32000,/*2*/ 1,/*3*/ 20,/*4*/ 1,/*5*/ 0, &sReverbSettings[0],/*6*/ 0x7FFF,/*7*/ 0,/*8*/ 0x7200,/*9*/ 0xC000,/*10*/ 0x8800,/*11*/ 0x5400 },
|
||||
#else
|
||||
{/*1*/ 32000,/*2*/ 1,/*3*/ 20,/*4*/ 1,/*5*/ 0, &sReverbSettings[0],/*6*/ 0x7FFF,/*7*/ 0,/*8*/ 0x4100,/*9*/ 0x6E00,/*10*/ 0x4400,/*11*/ 0x2A80 },
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
// constant .data
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
extern struct AudioSessionSettingsEU gAudioSessionPresets[];
|
||||
extern struct ReverbSettingsEU sReverbSettings[];
|
||||
#else
|
||||
extern struct AudioSessionSettings gAudioSessionPresets[18];
|
||||
#endif
|
||||
|
||||
166
src/audio/heap.c
166
src/audio/heap.c
@@ -1080,16 +1080,98 @@ void wait_for_audio_frames(s32 frames) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#define VERSION_EU
|
||||
|
||||
s32 built = 0;
|
||||
s32 sAudioFirstBoot = 0;
|
||||
//Separate the reverb settings into their own func. Bit unstable currently, so still only runs at boot.
|
||||
#ifdef VERSION_EU
|
||||
void init_reverb_eu(void)
|
||||
{
|
||||
s16 *mem;
|
||||
struct AudioSessionSettingsEU *preset = &gAudioSessionPresets[0];
|
||||
struct SynthesisReverb *reverb;
|
||||
struct ReverbSettingsEU *reverbSettings;
|
||||
s32 j, i;
|
||||
for (j = 0; j < 4; j++) {
|
||||
gSynthesisReverbs[j].useReverb = 0;
|
||||
}
|
||||
//gAudioResetPresetIdToLoad
|
||||
gNumSynthesisReverbs = preset->numReverbs;
|
||||
for (j = 0; j < gNumSynthesisReverbs; j++) {
|
||||
reverb = &gSynthesisReverbs[j];
|
||||
reverbSettings = &sReverbSettings[j];
|
||||
#ifdef VERSION_SH
|
||||
reverb->downsampleRate = reverbSettings->downsampleRate;
|
||||
reverb->windowSize = reverbSettings->windowSize * 64;
|
||||
reverb->windowSize /= reverb->downsampleRate;
|
||||
#else
|
||||
reverb->windowSize = reverbSettings->windowSize * 64;
|
||||
reverb->downsampleRate = reverbSettings->downsampleRate;
|
||||
#endif
|
||||
reverb->reverbGain = reverbSettings->gain;
|
||||
#ifdef VERSION_SH
|
||||
reverb->panRight = reverbSettings->unk4;
|
||||
reverb->panLeft = reverbSettings->unk6;
|
||||
reverb->unk5 = reverbSettings->unk8;
|
||||
reverb->unk08 = reverbSettings->unkA;
|
||||
#endif
|
||||
reverb->useReverb = 8;
|
||||
reverb->ringBuffer.left = soundAlloc(&gNotesAndBuffersPool, reverb->windowSize * 2);
|
||||
reverb->ringBuffer.right = soundAlloc(&gNotesAndBuffersPool, reverb->windowSize * 2);
|
||||
reverb->nextRingBufferPos = 0;
|
||||
reverb->unkC = 0;
|
||||
reverb->curFrame = 0;
|
||||
reverb->bufSizePerChannel = reverb->windowSize;
|
||||
reverb->framesLeftToIgnore = 2;
|
||||
#ifdef VERSION_SH
|
||||
reverb->resampleFlags = A_INIT;
|
||||
#endif
|
||||
if (reverb->downsampleRate != 1) {
|
||||
#ifndef VERSION_SH
|
||||
reverb->resampleFlags = A_INIT;
|
||||
#endif
|
||||
reverb->resampleRate = 0x8000 / reverb->downsampleRate;
|
||||
reverb->resampleStateLeft = soundAlloc(&gNotesAndBuffersPool, 16 * sizeof(s16));
|
||||
reverb->resampleStateRight = soundAlloc(&gNotesAndBuffersPool, 16 * sizeof(s16));
|
||||
reverb->unk24 = soundAlloc(&gNotesAndBuffersPool, 16 * sizeof(s16));
|
||||
reverb->unk28 = soundAlloc(&gNotesAndBuffersPool, 16 * sizeof(s16));
|
||||
for (i = 0; i < gAudioBufferParameters.updatesPerFrame; i++) {
|
||||
mem = soundAlloc(&gNotesAndBuffersPool, DEFAULT_LEN_2CH);
|
||||
reverb->items[0][i].toDownsampleLeft = mem;
|
||||
reverb->items[0][i].toDownsampleRight = mem + DEFAULT_LEN_1CH / sizeof(s16);
|
||||
mem = soundAlloc(&gNotesAndBuffersPool, DEFAULT_LEN_2CH);
|
||||
reverb->items[1][i].toDownsampleLeft = mem;
|
||||
reverb->items[1][i].toDownsampleRight = mem + DEFAULT_LEN_1CH / sizeof(s16);
|
||||
}
|
||||
}
|
||||
#ifdef VERSION_SH
|
||||
if (reverbSettings->unkC != 0) {
|
||||
reverb->unk108 = sound_alloc_uninitialized(&gNotesAndBuffersPool, 16 * sizeof(s16));
|
||||
reverb->unk100 = sound_alloc_uninitialized(&gNotesAndBuffersPool, 8 * sizeof(s16));
|
||||
func_sh_802F0DE8(reverb->unk100, reverbSettings->unkC);
|
||||
} else {
|
||||
reverb->unk100 = NULL;
|
||||
}
|
||||
if (reverbSettings->unkE != 0) {
|
||||
reverb->unk10C = sound_alloc_uninitialized(&gNotesAndBuffersPool, 16 * sizeof(s16));
|
||||
reverb->unk104 = sound_alloc_uninitialized(&gNotesAndBuffersPool, 8 * sizeof(s16));
|
||||
func_sh_802F0DE8(reverb->unk104, reverbSettings->unkE);
|
||||
} else {
|
||||
reverb->unk104 = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(VERSION_JP) || defined(VERSION_US)
|
||||
void audio_reset_session(struct AudioSessionSettings *preset) {
|
||||
#else
|
||||
void audio_reset_session(void) {
|
||||
struct AudioSessionSettingsEU *preset = &gAudioSessionPresets[gAudioResetPresetIdToLoad];
|
||||
struct ReverbSettingsEU *reverbSettings;
|
||||
if (sAudioFirstBoot)
|
||||
{
|
||||
//init_reverb_eu();
|
||||
return;
|
||||
}
|
||||
struct AudioSessionSettingsEU *preset = &gAudioSessionPresets[0];
|
||||
#endif
|
||||
s16 *mem;
|
||||
#if defined(VERSION_JP) || defined(VERSION_US)
|
||||
@@ -1340,74 +1422,7 @@ void audio_reset_session(void) {
|
||||
gAudioCmdBuffers[j] = soundAlloc(&gNotesAndBuffersPool, gMaxAudioCmds * sizeof(u64));
|
||||
}
|
||||
|
||||
for (j = 0; j < 4; j++) {
|
||||
gSynthesisReverbs[j].useReverb = 0;
|
||||
}
|
||||
gNumSynthesisReverbs = preset->numReverbs;
|
||||
for (j = 0; j < gNumSynthesisReverbs; j++) {
|
||||
reverb = &gSynthesisReverbs[j];
|
||||
reverbSettings = &preset->reverbSettings[j];
|
||||
#ifdef VERSION_SH
|
||||
reverb->downsampleRate = reverbSettings->downsampleRate;
|
||||
reverb->windowSize = reverbSettings->windowSize * 64;
|
||||
reverb->windowSize /= reverb->downsampleRate;
|
||||
#else
|
||||
reverb->windowSize = reverbSettings->windowSize * 64;
|
||||
reverb->downsampleRate = reverbSettings->downsampleRate;
|
||||
#endif
|
||||
reverb->reverbGain = reverbSettings->gain;
|
||||
#ifdef VERSION_SH
|
||||
reverb->panRight = reverbSettings->unk4;
|
||||
reverb->panLeft = reverbSettings->unk6;
|
||||
reverb->unk5 = reverbSettings->unk8;
|
||||
reverb->unk08 = reverbSettings->unkA;
|
||||
#endif
|
||||
reverb->useReverb = 8;
|
||||
reverb->ringBuffer.left = soundAlloc(&gNotesAndBuffersPool, reverb->windowSize * 2);
|
||||
reverb->ringBuffer.right = soundAlloc(&gNotesAndBuffersPool, reverb->windowSize * 2);
|
||||
reverb->nextRingBufferPos = 0;
|
||||
reverb->unkC = 0;
|
||||
reverb->curFrame = 0;
|
||||
reverb->bufSizePerChannel = reverb->windowSize;
|
||||
reverb->framesLeftToIgnore = 2;
|
||||
#ifdef VERSION_SH
|
||||
reverb->resampleFlags = A_INIT;
|
||||
#endif
|
||||
if (reverb->downsampleRate != 1) {
|
||||
#ifndef VERSION_SH
|
||||
reverb->resampleFlags = A_INIT;
|
||||
#endif
|
||||
reverb->resampleRate = 0x8000 / reverb->downsampleRate;
|
||||
reverb->resampleStateLeft = soundAlloc(&gNotesAndBuffersPool, 16 * sizeof(s16));
|
||||
reverb->resampleStateRight = soundAlloc(&gNotesAndBuffersPool, 16 * sizeof(s16));
|
||||
reverb->unk24 = soundAlloc(&gNotesAndBuffersPool, 16 * sizeof(s16));
|
||||
reverb->unk28 = soundAlloc(&gNotesAndBuffersPool, 16 * sizeof(s16));
|
||||
for (i = 0; i < gAudioBufferParameters.updatesPerFrame; i++) {
|
||||
mem = soundAlloc(&gNotesAndBuffersPool, DEFAULT_LEN_2CH);
|
||||
reverb->items[0][i].toDownsampleLeft = mem;
|
||||
reverb->items[0][i].toDownsampleRight = mem + DEFAULT_LEN_1CH / sizeof(s16);
|
||||
mem = soundAlloc(&gNotesAndBuffersPool, DEFAULT_LEN_2CH);
|
||||
reverb->items[1][i].toDownsampleLeft = mem;
|
||||
reverb->items[1][i].toDownsampleRight = mem + DEFAULT_LEN_1CH / sizeof(s16);
|
||||
}
|
||||
}
|
||||
#ifdef VERSION_SH
|
||||
if (reverbSettings->unkC != 0) {
|
||||
reverb->unk108 = sound_alloc_uninitialized(&gNotesAndBuffersPool, 16 * sizeof(s16));
|
||||
reverb->unk100 = sound_alloc_uninitialized(&gNotesAndBuffersPool, 8 * sizeof(s16));
|
||||
func_sh_802F0DE8(reverb->unk100, reverbSettings->unkC);
|
||||
} else {
|
||||
reverb->unk100 = NULL;
|
||||
}
|
||||
if (reverbSettings->unkE != 0) {
|
||||
reverb->unk10C = sound_alloc_uninitialized(&gNotesAndBuffersPool, 16 * sizeof(s16));
|
||||
reverb->unk104 = sound_alloc_uninitialized(&gNotesAndBuffersPool, 8 * sizeof(s16));
|
||||
func_sh_802F0DE8(reverb->unk104, reverbSettings->unkE);
|
||||
} else {
|
||||
reverb->unk104 = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
init_reverb_eu();
|
||||
|
||||
#else
|
||||
if (reverbWindowSize == 0) {
|
||||
@@ -1462,11 +1477,7 @@ void audio_reset_session(void) {
|
||||
init_sample_dma_buffers(gMaxSimultaneousNotes);
|
||||
|
||||
#if defined(VERSION_EU)
|
||||
if (!built)
|
||||
{
|
||||
build_vol_rampings_table(0, gAudioBufferParameters.samplesPerUpdate);
|
||||
built = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef VERSION_SH
|
||||
@@ -1484,6 +1495,7 @@ if (!built)
|
||||
#ifdef PUPPYPRINT
|
||||
append_puppyprint_log("Audio Initialised in %dus.", (s32)OS_CYCLES_TO_USEC(osGetTime() - first));
|
||||
#endif
|
||||
sAudioFirstBoot = 1;
|
||||
}
|
||||
|
||||
#ifdef VERSION_SH
|
||||
|
||||
Reference in New Issue
Block a user