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 c3fba60a2b
commit dda8f6d0c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 31 deletions

View File

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

View File

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