Some formatting changes :( (But also some safeguards and updated documentation)

This commit is contained in:
gheskett
2022-02-26 01:56:07 -05:00
parent 6bd3988dd8
commit 056e319105
9 changed files with 40 additions and 27 deletions

View File

@@ -4,19 +4,27 @@
* AUDIO SETTINGS *
******************/
// Fixes the castle music sometimes triggering after getting a dialog.
/**
* Fixes the castle music sometimes triggering after getting a dialog.
*/
#define CASTLE_MUSIC_FIX
// Increase audio heap size to allow for more concurrent notes to be played and for more custom sequences/banks to be imported (not supported for SH).
/**
* Increase audio heap size to allow for more concurrent notes to be played and for more custom sequences/banks to be imported (not supported for SH).
*/
#define EXPAND_AUDIO_HEAP
// The maximum number of notes (sfx inclusive) that can sound at any given time (not supported for SH).
// Lower values may cause notes to get cut more easily but can potentially improve performance slightly.
// Lower values may cause problems with streamed audio if a sequence used for it is missing channel priority data.
// Vanilla by default only generally allocates 16 or 20 notes at once. Memory usage is always determined by the largest of the two values here.
/**
* The maximum number of notes (sfx inclusive) that can sound at any given time (not supported for SH).
* Lower values may cause notes to get cut more easily but can potentially improve performance slightly.
* Lower values may cause problems with streamed audio if a sequence used for it is missing channel priority data.
* Vanilla by default only generally allocates 16 or 20 notes at once. Memory usage is always determined by the largest of the two values here (~7200 bytes per US/JP note).
*/
#define MAX_SIMULTANEOUS_NOTES_EMULATOR 40
#define MAX_SIMULTANEOUS_NOTES_CONSOLE 32
// Use a much better implementation of reverb over vanilla's fake echo reverb. Great for caves or eerie levels, as well as just a better audio experience in general.
// Reverb parameters can be configured in audio/synthesis.c to meet desired aesthetic/performance needs. Currently US/JP only. Hurts emulator and console performance.
/**
* Use a much better implementation of reverb over vanilla's fake echo reverb. Great for caves or eerie levels, as well as just a better audio experience in general.
* Reverb parameters can be configured in audio/synthesis.c to meet desired aesthetic/performance needs. Currently US/JP only. Hurts emulator and console performance.
*/
//#define BETTER_REVERB

View File

@@ -40,6 +40,13 @@
#if (MAX_SIMULTANEOUS_NOTES > 64)
#undef MAX_SIMULTANEOUS_NOTES
#define MAX_SIMULTANEOUS_NOTES 64
#elif (MAX_SIMULTANEOUS_NOTES < 0)
#undef MAX_SIMULTANEOUS_NOTES
#define MAX_SIMULTANEOUS_NOTES 0
#endif
#if defined(BETTER_REVERB) && !(defined(VERSION_US) || defined(VERSION_JP))
#undef BETTER_REVERB
#endif

View File

@@ -10,7 +10,7 @@ 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. Index range must be defined, since it's needed by the compiler.
// To increase reverb window sizes beyond 64, please increase the REVERB_WINDOW_SIZE_MAX in heap.c by a factor of 0x40 and update AUDIO_HEAP_SIZE by 4x the same amount.
// To increase reverb window sizes beyond 64, please increase the REVERB_WINDOW_SIZE_MAX in heap.c by a factor of 0x40.
#ifdef VERSION_EU
struct ReverbSettingsEU sReverbSettings[8] = {
{ /*Downsample Rate*/ 1, /*Window Size*/ 64, /*Gain*/ 0x2FFF },
@@ -57,7 +57,7 @@ struct AudioSessionSettingsEU gAudioSessionPresets[] = {
// - memory used for temporary sequences
// - memory used for temporary banks
// To increase reverb window sizes beyond 0x1000, please increase the REVERB_WINDOW_SIZE_MAX in heap.c and update AUDIO_HEAP_SIZE by the same amount.
// To increase reverb window sizes beyond 0x1000, please increase the REVERB_WINDOW_SIZE_MAX in heap.c.
#if defined(VERSION_JP) || defined(VERSION_US)
struct ReverbSettingsUS gReverbSettings[18] = {
{ 1, 0x0C00, 0x2FFF },

View File

@@ -122,11 +122,11 @@ extern u32 gAudioRandom;
MAX_SIMULTANEOUS_NOTES * ((4 /* updatesPerFrame */ * 20 * 2 * sizeof(u64)) \
+ ALIGN16(sizeof(struct Note)) \
+ (DMA_BUF_SIZE_0 * 3) \
+ (DMA_BUF_SIZE_1) \
+ DMA_BUF_SIZE_1 \
+ ALIGN16(sizeof(struct NoteSynthesisBuffers))) \
+ 320 * 2 * sizeof(u64) /* gMaxAudioCmds */ \
+ (320 * 2 * sizeof(u64)) /* gMaxAudioCmds */ \
)
#elif defined(VERSION_EU)
#else // Probably SH incompatible but that's an entirely different headache to save at this point tbh
#define NOTES_BUFFER_SIZE \
( \
MAX_SIMULTANEOUS_NOTES * ((4 /* updatesPerFrame */ * 0x10 * 2 * sizeof(u64)) \
@@ -135,8 +135,7 @@ extern u32 gAudioRandom;
+ (DMA_BUF_SIZE_1) \
+ ALIGN16(sizeof(struct NoteSynthesisBuffers)) \
+ ALIGN16(4 /* updatesPerFrame */ * sizeof(struct NoteSubEu))) \
+ (0x300 + 4 /* numReverbs */ * 0x20) * 2 * sizeof(u64) /* gMaxAudioCmds */ \
+ 0x4000 /* Extra space to hopefully tolerate whatever the note patch behavior is */ \
+ ((0x300 + (4 /* numReverbs */ * 0x20)) * 2 * sizeof(u64)) /* gMaxAudioCmds */ \
)
#endif

View File

@@ -32,7 +32,7 @@ struct SoundAllocPool gAudioSessionPool;
struct SoundAllocPool gAudioInitPool;
struct SoundAllocPool gNotesAndBuffersPool;
u8 sAudioHeapPad[0x20]; // probably two unused pools
#if defined(BETTER_REVERB) && (defined(VERSION_US) || defined(VERSION_JP))
#ifdef BETTER_REVERB
struct SoundAllocPool gBetterReverbPool;
#endif
struct SoundAllocPool gSeqAndBankPool;
@@ -310,7 +310,7 @@ void puppyprint_get_allocated_pools(s32 *audioPoolList) {
&gSeqLoadedPool.temporary.pool,
&gBankLoadedPool.persistent.pool,
&gBankLoadedPool.temporary.pool,
#if defined(BETTER_REVERB) && (defined(VERSION_US) || defined(VERSION_JP))
#ifdef BETTER_REVERB
&gBetterReverbPool,
#endif
};
@@ -332,7 +332,7 @@ void session_pools_init(struct PoolSplit *a) {
gAudioSessionPool.cur = gAudioSessionPool.start;
sound_alloc_pool_init(&gNotesAndBuffersPool, SOUND_ALLOC_FUNC(&gAudioSessionPool, a->wantSeq ), a->wantSeq );
sound_alloc_pool_init(&gSeqAndBankPool, SOUND_ALLOC_FUNC(&gAudioSessionPool, a->wantCustom ), a->wantCustom );
#if defined(BETTER_REVERB) && (defined(VERSION_US) || defined(VERSION_JP))
#ifdef BETTER_REVERB
sound_alloc_pool_init(&gBetterReverbPool, SOUND_ALLOC_FUNC(&gAudioSessionPool, BETTER_REVERB_SIZE), BETTER_REVERB_SIZE);
#endif
}
@@ -1344,12 +1344,9 @@ void audio_reset_session(void) {
#if defined(VERSION_SH)
persistentMem = DOUBLE_SIZE_ON_64_BIT(preset->persistentSeqMem + preset->persistentBankMem + preset->unk18 + preset->unkMem28 + 0x10);
temporaryMem = DOUBLE_SIZE_ON_64_BIT(preset->temporarySeqMem + preset->temporaryBankMem + preset->unk24 + preset->unkMem2C + 0x10);
#elif defined(VERSION_EU)
#else
persistentMem = DOUBLE_SIZE_ON_64_BIT(preset->persistentSeqMem + preset->persistentBankMem);
temporaryMem = DOUBLE_SIZE_ON_64_BIT(preset->temporarySeqMem + preset->temporaryBankMem);
#else
persistentMem = DOUBLE_SIZE_ON_64_BIT(preset->persistentBankMem + preset->persistentSeqMem);
temporaryMem = DOUBLE_SIZE_ON_64_BIT(preset->temporaryBankMem + preset->temporarySeqMem);
#endif
totalMem = persistentMem + temporaryMem;
wantMisc = gAudioSessionPool.size - totalMem - BETTER_REVERB_SIZE;
@@ -1436,6 +1433,8 @@ void audio_reset_session(void) {
if (gMaxSimultaneousNotes > MAX_SIMULTANEOUS_NOTES)
gMaxSimultaneousNotes = MAX_SIMULTANEOUS_NOTES;
else if (gMaxSimultaneousNotes < 0)
gMaxSimultaneousNotes = 0;
sAudioFirstBoot = 1;
}

View File

@@ -39,7 +39,7 @@
#define AUDIO_ALIGN(val, amnt) (((val) + (1 << amnt) - 1) & ~((1 << amnt) - 1))
#if defined(BETTER_REVERB) && (defined(VERSION_US) || defined(VERSION_JP))
#ifdef BETTER_REVERB
/* ----------------------------------------------------------------------BEGIN REVERB PARAMETERS---------------------------------------------------------------------- */
@@ -206,7 +206,7 @@ struct SynthesisReverb gSynthesisReverb;
u8 sAudioSynthesisPad[0x20];
#endif
#if defined(BETTER_REVERB) && (defined(VERSION_US) || defined(VERSION_JP))
#ifdef BETTER_REVERB
static inline void reverb_samples(s16 *outSampleL, s16 *outSampleR, s32 inSampleL, s32 inSampleR) {
s32 i = 0;
s32 j = 0;

View File

@@ -19,7 +19,7 @@
#define ALIGN16(val) (((val) + 0xF) & ~0xF)
#if defined(BETTER_REVERB) && (defined(VERSION_US) || defined(VERSION_JP))
#ifdef BETTER_REVERB
#define NUM_ALLPASS 12 // Number of delay filters to use with better reverb; do not change this value if you don't know what you're doing.
#define BETTER_REVERB_PTR_SIZE ALIGN16(NUM_ALLPASS * sizeof(s32*) * 2) // Allocation space consumed by dynamically allocated pointers

View File

@@ -316,7 +316,7 @@ const char *audioPoolNames[NUM_AUDIO_POOLS] = {
"gSeqLoadedPool.temporary.pool",
"gBankLoadedPool.persistent.pool",
"gBankLoadedPool.temporary.pool",
#if defined(BETTER_REVERB) && (defined(VERSION_US) || defined(VERSION_JP))
#ifdef BETTER_REVERB
"gBetterReverbPool",
#endif
};

View File

@@ -33,7 +33,7 @@ enum PuppyprintTextAlign {
};
#if PUPPYPRINT_DEBUG
#if defined(BETTER_REVERB) && (defined(VERSION_US) || defined(VERSION_JP))
#ifdef BETTER_REVERB
#define NUM_AUDIO_POOLS 7
#else
#define NUM_AUDIO_POOLS 6