From dda8f6d0c3c0ae018907c7d3f997ee7c5d67271d Mon Sep 17 00:00:00 2001 From: Dark Date: Wed, 5 Jul 2023 15:01:42 -0400 Subject: [PATCH] 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. --- src/audio/data.c | 54 ++++++++++++++++++++++++------------------------ src/audio/load.c | 7 +++---- 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/src/audio/data.c b/src/audio/data.c index bdac8bbe..e915b352 100644 --- a/src/audio/data.c +++ b/src/audio/data.c @@ -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 diff --git a/src/audio/load.c b/src/audio/load.c index 4a26478d..93ce2104 100644 --- a/src/audio/load.c +++ b/src/audio/load.c @@ -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: