audio: increase max simultaneous notes (#437)

We go with a very generous amount here to ensure that we basically never
reach the limit. A few fixes were also made in load.c to catch any
segfaults in case someone decides to increase the limit even further.
This commit is contained in:
Dark 2023-07-05 15:01:42 -04:00 committed by GitHub
parent 19be94168d
commit 15ea01d241
2 changed files with 30 additions and 31 deletions

View File

@ -44,8 +44,6 @@ struct AudioSessionSettingsEU gAudioSessionPresets[] = {
}; };
#endif #endif
#define MAX_SIMUL_NOTE_MULT 2 // double the number of max simultaneous notes
// Format: // Format:
// - frequency // - frequency
// - max number of simultaneous notes // - max number of simultaneous notes
@ -57,36 +55,38 @@ struct AudioSessionSettingsEU gAudioSessionPresets[] = {
// - memory used for persistent banks // - memory used for persistent banks
// - memory used for temporary sequences // - memory used for temporary sequences
// - memory used for temporary banks // - memory used for temporary banks
// increased from defaults to allow for more sounds playing at once
#if defined(VERSION_JP) || defined(VERSION_US) #if defined(VERSION_JP) || defined(VERSION_US)
struct AudioSessionSettings gAudioSessionPresets[18] = { struct AudioSessionSettings gAudioSessionPresets[18] = {
#ifdef VERSION_JP #ifdef VERSION_JP
{ 32000, 16 * MAX_SIMUL_NOTE_MULT, 1, 0x0800, 0x2FFF, 0x7FFF, 0x3900, 0x6000, 0x4400, 0x2A00 }, { 32000, 48, 1, 0x0800, 0x2FFF, 0x7FFF, 0x3900, 0x6000, 0x4400, 0x2A00 },
{ 32000, 16 * MAX_SIMUL_NOTE_MULT, 1, 0x0A00, 0x47FF, 0x7FFF, 0x3900, 0x6000, 0x4400, 0x2A00 }, { 32000, 48, 1, 0x0A00, 0x47FF, 0x7FFF, 0x3900, 0x6000, 0x4400, 0x2A00 },
{ 32000, 16 * MAX_SIMUL_NOTE_MULT, 1, 0x1000, 0x2FFF, 0x7FFF, 0x3900, 0x6000, 0x4400, 0x2A00 }, { 32000, 48, 1, 0x1000, 0x2FFF, 0x7FFF, 0x3900, 0x6000, 0x4400, 0x2A00 },
{ 32000, 16 * MAX_SIMUL_NOTE_MULT, 1, 0x0E00, 0x3FFF, 0x7FFF, 0x3900, 0x6000, 0x4400, 0x2A00 }, { 32000, 48, 1, 0x0E00, 0x3FFF, 0x7FFF, 0x3900, 0x6000, 0x4400, 0x2A00 },
{ 32000, 16 * MAX_SIMUL_NOTE_MULT, 1, 0x0C00, 0x4FFF, 0x7FFF, 0x3900, 0x6000, 0x4400, 0x2A00 }, { 32000, 48, 1, 0x0C00, 0x4FFF, 0x7FFF, 0x3900, 0x6000, 0x4400, 0x2A00 },
{ 32000, 16 * MAX_SIMUL_NOTE_MULT, 1, 0x0800, 0x2FFF, 0x7FFF, 0x3E00, 0x6200, 0x3F00, 0x2A00 }, { 32000, 48, 1, 0x0800, 0x2FFF, 0x7FFF, 0x3E00, 0x6200, 0x3F00, 0x2A00 },
{ 32000, 16 * MAX_SIMUL_NOTE_MULT, 1, 0x0A00, 0x47FF, 0x7FFF, 0x3F00, 0x6200, 0x4400, 0x2A80 }, { 32000, 48, 1, 0x0A00, 0x47FF, 0x7FFF, 0x3F00, 0x6200, 0x4400, 0x2A80 },
{ 32000, 20 * MAX_SIMUL_NOTE_MULT, 1, 0x0800, 0x37FF, 0x7FFF, 0x3300, 0x5500, 0x4000, 0x1B00 }, { 32000, 48, 1, 0x0800, 0x37FF, 0x7FFF, 0x3300, 0x5500, 0x4000, 0x1B00 },
#else #else
{ 32000, 16 * MAX_SIMUL_NOTE_MULT, 1, 0x0C00, 0x2FFF, 0x7FFF, 0x7400, 0xCC00, 0x7400, 0x7400 }, { 32000, 48, 1, 0x0C00, 0x2FFF, 0x7FFF, 0x7400, 0xCC00, 0x7400, 0x7400 },
{ 32000, 16 * MAX_SIMUL_NOTE_MULT, 1, 0x0A00, 0x47FF, 0x7FFF, 0x7400, 0xCC00, 0x7400, 0x7400 }, { 32000, 48, 1, 0x0A00, 0x47FF, 0x7FFF, 0x7400, 0xCC00, 0x7400, 0x7400 },
{ 32000, 16 * MAX_SIMUL_NOTE_MULT, 1, 0x1000, 0x2FFF, 0x7FFF, 0x7400, 0xCC00, 0x7400, 0x7400 }, { 32000, 48, 1, 0x1000, 0x2FFF, 0x7FFF, 0x7400, 0xCC00, 0x7400, 0x7400 },
{ 32000, 16 * MAX_SIMUL_NOTE_MULT, 1, 0x0E00, 0x3FFF, 0x7FFF, 0x7400, 0xCC00, 0x7400, 0x7400 }, { 32000, 48, 1, 0x0E00, 0x3FFF, 0x7FFF, 0x7400, 0xCC00, 0x7400, 0x7400 },
{ 32000, 16 * MAX_SIMUL_NOTE_MULT, 1, 0x0C00, 0x4FFF, 0x7FFF, 0x7400, 0xCC00, 0x7400, 0x7400 }, { 32000, 48, 1, 0x0C00, 0x4FFF, 0x7FFF, 0x7400, 0xCC00, 0x7400, 0x7400 },
{ 32000, 16 * MAX_SIMUL_NOTE_MULT, 1, 0x0C00, 0x2FFF, 0x7FFF, 0x7400, 0xCC00, 0x7400, 0x7400 }, { 32000, 48, 1, 0x0C00, 0x2FFF, 0x7FFF, 0x7400, 0xCC00, 0x7400, 0x7400 },
{ 32000, 16 * MAX_SIMUL_NOTE_MULT, 1, 0x0A00, 0x47FF, 0x7FFF, 0x7400, 0xCC00, 0x7400, 0x7400 }, { 32000, 48, 1, 0x0A00, 0x47FF, 0x7FFF, 0x7400, 0xCC00, 0x7400, 0x7400 },
{ 32000, 20 * MAX_SIMUL_NOTE_MULT, 1, 0x0800, 0x37FF, 0x7FFF, 0x7400, 0xCC00, 0x7400, 0x7400 }, { 32000, 48, 1, 0x0800, 0x37FF, 0x7FFF, 0x7400, 0xCC00, 0x7400, 0x7400 },
#endif #endif
{ 27000, 16 * MAX_SIMUL_NOTE_MULT, 1, 0x0800, 0x2FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 }, { 27000, 48, 1, 0x0800, 0x2FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 },
{ 27000, 16 * MAX_SIMUL_NOTE_MULT, 1, 0x0800, 0x3FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 }, { 27000, 48, 1, 0x0800, 0x3FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 },
{ 27000, 16 * MAX_SIMUL_NOTE_MULT, 1, 0x1000, 0x2FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 }, { 27000, 48, 1, 0x1000, 0x2FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 },
{ 27000, 16 * MAX_SIMUL_NOTE_MULT, 1, 0x1000, 0x3FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 }, { 27000, 48, 1, 0x1000, 0x3FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 },
{ 27000, 16 * MAX_SIMUL_NOTE_MULT, 1, 0x0C00, 0x4FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 }, { 27000, 48, 1, 0x0C00, 0x4FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 },
{ 32000, 14 * MAX_SIMUL_NOTE_MULT, 1, 0x0800, 0x2FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 }, { 32000, 48, 1, 0x0800, 0x2FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 },
{ 32000, 12 * MAX_SIMUL_NOTE_MULT, 1, 0x0800, 0x2FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 }, { 32000, 48, 1, 0x0800, 0x2FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 },
{ 32000, 10 * MAX_SIMUL_NOTE_MULT, 1, 0x0800, 0x2FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 }, { 32000, 48, 1, 0x0800, 0x2FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 },
{ 32000, 8 * MAX_SIMUL_NOTE_MULT, 1, 0x0800, 0x2FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 }, { 32000, 48, 1, 0x0800, 0x2FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
}; };
#endif #endif

View File

@ -84,11 +84,8 @@ OSMesgQueue gAudioDmaMesgQueue;
OSMesg gAudioDmaMesg; OSMesg gAudioDmaMesg;
OSIoMesg gAudioDmaIoMesg; OSIoMesg gAudioDmaIoMesg;
#ifdef VERSION_EU // increased from defaults to allow more sounds to play
#define SAMPLE_DMA_COUNT 0x100 #define SAMPLE_DMA_COUNT 0x100
#else
#define SAMPLE_DMA_COUNT 0x90
#endif
#ifdef VERSION_SH #ifdef VERSION_SH
struct SharedDma *sSampleDmas = NULL; // sh: 0x803503D0 struct SharedDma *sSampleDmas = NULL; // sh: 0x803503D0
@ -451,6 +448,7 @@ void init_sample_dma_buffers(UNUSED s32 arg0) {
sSampleDmas[gSampleDmaNumListItems].unused2 = 0; sSampleDmas[gSampleDmaNumListItems].unused2 = 0;
sSampleDmas[gSampleDmaNumListItems].ttl = 0; sSampleDmas[gSampleDmaNumListItems].ttl = 0;
gSampleDmaNumListItems++; gSampleDmaNumListItems++;
assert(gSampleDmaNumListItems < SAMPLE_DMA_COUNT);
} }
#if defined(VERSION_JP) || defined(VERSION_US) #if defined(VERSION_JP) || defined(VERSION_US)
out1: out1:
@ -502,6 +500,7 @@ out1:
sSampleDmas[gSampleDmaNumListItems].bufSize = sDmaBufSize; sSampleDmas[gSampleDmaNumListItems].bufSize = sDmaBufSize;
#endif #endif
gSampleDmaNumListItems++; gSampleDmaNumListItems++;
assert(gSampleDmaNumListItems < SAMPLE_DMA_COUNT);
} }
#if defined(VERSION_JP) || defined(VERSION_US) #if defined(VERSION_JP) || defined(VERSION_US)
out2: out2: