You've already forked Microtransactions64
mirror of
https://github.com/Print-and-Panic/Microtransactions64.git
synced 2026-01-21 10:17:19 -08:00
Bugfixes, sound bank heap defines, BETTER_REVERB improvements
This commit is contained in:
@@ -37,11 +37,7 @@ struct ReverbSettingsEU sReverbSettings[8] = {
|
||||
*/
|
||||
|
||||
struct AudioSessionSettingsEU gAudioSessionPresets[] = {
|
||||
#ifdef EXPAND_AUDIO_HEAP
|
||||
{ /*1*/ 32000,/*2*/ 1,/*3*/ MAX_SIMULTANEOUS_NOTES,/*4*/ 1,/*5*/ 0, &sReverbSettings[0],/*6*/ 0x7FFF,/*7*/ 0,/*8*/ 0x8200,/*9*/ 0xDC00,/*10*/ 0xE800,/*11*/ 0x5500 },
|
||||
#else
|
||||
{ /*1*/ 32000,/*2*/ 1,/*3*/ MAX_SIMULTANEOUS_NOTES,/*4*/ 1,/*5*/ 0, &sReverbSettings[0],/*6*/ 0x7FFF,/*7*/ 0,/*8*/ 0x4100,/*9*/ 0x6E00,/*10*/ 0x7400,/*11*/ 0x2A80 },
|
||||
#endif
|
||||
{ /*1*/ 32000,/*2*/ 1,/*3*/ MAX_SIMULTANEOUS_NOTES,/*4*/ 1,/*5*/ 0, &sReverbSettings[0],/*6*/ 0x7FFF,/*7*/ 0,/*8*/ PERSISTENT_SEQ_MEM,/*9*/ PERSISTENT_BANK_MEM,/*10*/ TEMPORARY_SEQ_MEM,/*11*/ TEMPORARY_BANK_MEM },
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -80,15 +76,9 @@ struct ReverbSettingsUS gReverbSettings[18] = {
|
||||
{ 1, 0x0800, 0x2FFF },
|
||||
};
|
||||
|
||||
#ifdef EXPAND_AUDIO_HEAP
|
||||
struct AudioSessionSettings gAudioSessionPresets[1] = {
|
||||
{ 32000, MAX_SIMULTANEOUS_NOTES, 1, 0x1000, 0x2FFF, 0x7FFF, 0x8200, 0xDC00, 0xE800, 0x5500 },
|
||||
{ 32000, MAX_SIMULTANEOUS_NOTES, 1, 0x1000, 0x2FFF, 0x7FFF, PERSISTENT_SEQ_MEM, PERSISTENT_BANK_MEM, TEMPORARY_SEQ_MEM, TEMPORARY_BANK_MEM },
|
||||
};
|
||||
#else
|
||||
struct AudioSessionSettings gAudioSessionPresets[1] = {
|
||||
{ 32000, MAX_SIMULTANEOUS_NOTES, 1, 0x1000, 0x2FFF, 0x7FFF, 0x4100, 0x6E00, 0x7400, 0x2A80 },
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
// gAudioCosineTable[k] = round((2**15 - 1) * cos(pi/2 * k / 127)). Unused.
|
||||
#if defined(VERSION_JP) || defined(VERSION_US)
|
||||
|
||||
@@ -21,6 +21,24 @@
|
||||
#define DMA_BUF_SIZE_1 (160 * 9)
|
||||
#endif
|
||||
|
||||
#ifdef EXPAND_AUDIO_HEAP
|
||||
#define PERSISTENT_SEQ_MEM 0x8200
|
||||
#define PERSISTENT_BANK_MEM 0xDC00
|
||||
#define TEMPORARY_SEQ_MEM 0xE800
|
||||
#define TEMPORARY_BANK_MEM 0x5500
|
||||
#define BANK_SETS_ALLOC 0x400
|
||||
#define EXT_AUDIO_INIT_POOL_SIZE 0x2000
|
||||
#else
|
||||
#define PERSISTENT_SEQ_MEM 0x4100
|
||||
#define PERSISTENT_BANK_MEM 0x6E00
|
||||
#define TEMPORARY_SEQ_MEM 0x7400
|
||||
#define TEMPORARY_BANK_MEM 0x2A80
|
||||
#define BANK_SETS_ALLOC 0x100
|
||||
#define EXT_AUDIO_INIT_POOL_SIZE 0x0
|
||||
#endif
|
||||
|
||||
#define SEQ_BANK_MEM (PERSISTENT_SEQ_MEM + PERSISTENT_BANK_MEM + TEMPORARY_SEQ_MEM + TEMPORARY_BANK_MEM)
|
||||
|
||||
// constant .data
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
extern struct AudioSessionSettingsEU gAudioSessionPresets[];
|
||||
@@ -139,20 +157,6 @@ extern u32 gAudioRandom;
|
||||
)
|
||||
#endif
|
||||
|
||||
#ifdef EXPAND_AUDIO_HEAP
|
||||
#if defined(VERSION_US) || defined(VERSION_JP) || defined(VERSION_EU)
|
||||
#define EXT_AUDIO_INIT_POOL_SIZE (0x2000 + 0x300)
|
||||
#define EXT_AUDIO_HEAP_SIZE 0x14D80
|
||||
#else
|
||||
// SH not yet supported for expanded audio heap
|
||||
#define EXT_AUDIO_INIT_POOL_SIZE 0x0
|
||||
#define EXT_AUDIO_HEAP_SIZE 0x0
|
||||
#endif
|
||||
#else
|
||||
#define EXT_AUDIO_INIT_POOL_SIZE 0x0
|
||||
#define EXT_AUDIO_HEAP_SIZE 0x0
|
||||
#endif
|
||||
|
||||
#ifdef VERSION_SH
|
||||
extern f32 unk_sh_data_1[];
|
||||
|
||||
@@ -179,15 +183,13 @@ extern OSMesgQueue *D_SH_80350FA8;
|
||||
#endif
|
||||
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
#define AUDIO_INIT_POOL_SIZE (0x2C00 + EXT_AUDIO_INIT_POOL_SIZE)
|
||||
#define AUDIO_INIT_POOL_SIZE (0x2C00 + BANK_SETS_ALLOC + EXT_AUDIO_INIT_POOL_SIZE)
|
||||
#else
|
||||
#define AUDIO_INIT_POOL_SIZE (0x2500 + EXT_AUDIO_INIT_POOL_SIZE)
|
||||
#define AUDIO_INIT_POOL_SIZE (0x2500 + BANK_SETS_ALLOC + EXT_AUDIO_INIT_POOL_SIZE)
|
||||
#endif
|
||||
|
||||
// TODO: needs validation once EU can compile. EU is very likely incorrect!
|
||||
#define AUDIO_HEAP_BASE (0x14D80 /* sound bank space */ + AUDIO_INIT_POOL_SIZE + EXT_AUDIO_HEAP_SIZE + NOTES_BUFFER_SIZE)
|
||||
|
||||
#define AUDIO_HEAP_SIZE (AUDIO_HEAP_BASE + BETTER_REVERB_SIZE + REVERB_WINDOW_HEAP_SIZE)
|
||||
#define AUDIO_HEAP_SIZE (SEQ_BANK_MEM + AUDIO_INIT_POOL_SIZE + NOTES_BUFFER_SIZE + BETTER_REVERB_SIZE + REVERB_WINDOW_HEAP_SIZE)
|
||||
|
||||
#ifdef VERSION_SH
|
||||
extern u32 D_SH_80315EF0;
|
||||
|
||||
@@ -983,13 +983,8 @@ void audio_init() {
|
||||
alSeqFileNew(gAlTbl, gSoundDataRaw);
|
||||
|
||||
// Load bank sets for each sequence
|
||||
#ifdef EXPAND_AUDIO_HEAP
|
||||
gAlBankSets = soundAlloc(&gAudioInitPool, 0x400);
|
||||
audio_dma_copy_immediate((uintptr_t) gBankSetsData, gAlBankSets, 0x400);
|
||||
#else
|
||||
gAlBankSets = soundAlloc(&gAudioInitPool, 0x100);
|
||||
audio_dma_copy_immediate((uintptr_t) gBankSetsData, gAlBankSets, 0x100);
|
||||
#endif
|
||||
gAlBankSets = soundAlloc(&gAudioInitPool, BANK_SETS_ALLOC);
|
||||
audio_dma_copy_immediate((uintptr_t) gBankSetsData, gAlBankSets, BANK_SETS_ALLOC);
|
||||
|
||||
init_sequence_players();
|
||||
gAudioLoadLock = AUDIO_LOCK_NOT_LOADING;
|
||||
|
||||
@@ -1448,4 +1448,4 @@ void note_init_all(void) {
|
||||
note->synthesisBuffers = soundAlloc(&gNotesAndBuffersPool, ALIGN16(sizeof(struct NoteSynthesisBuffers)));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2517,10 +2517,10 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) {
|
||||
break;
|
||||
|
||||
case 0xda: // seq_changevol
|
||||
temp = (f32)(s8) m64_read_u8(state) / 127.0f;
|
||||
seqPlayer->fadeVolume += temp;
|
||||
temp = m64_read_u8(state);
|
||||
seqPlayer->fadeVolume += (f32)(s8) temp / 127.0f;
|
||||
|
||||
seqPlayer->volumeDefault += temp;
|
||||
seqPlayer->volumeDefault += (f32)(s8) temp / 127.0f;
|
||||
if (seqPlayer->volumeDefault > 1.0f)
|
||||
seqPlayer->volumeDefault = 1.0f;
|
||||
else if (seqPlayer->volumeDefault < 0.0f)
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
*
|
||||
* This is also known to cause severe lag on emulators that have counter factor set to 2 or greater.
|
||||
* Be sure either you alert the user in advance, or check for and set betterReverbDownsampleEmulator to -1 if it's detected the user isn't using good settings.
|
||||
* Reducing performance heavy parameters or using RCVI hack may be another working solution to this problem.
|
||||
*/
|
||||
|
||||
|
||||
@@ -80,28 +81,28 @@ s8 betterReverbDownsampleEmulator = 2;
|
||||
// This value represents the number of filters to use with the reverb. This can be decreased to improve performance, but at the cost of a lesser presence of reverb in the final audio.
|
||||
// Filter count should always be a multiple of 3. Never ever set this value to be greater than NUM_ALLPASS.
|
||||
// Setting it to anything less than 3 will disable reverb outright.
|
||||
// This can be changed at any time, but is best set when calling audio_reset_session.
|
||||
// This can be changed at any time, but is best set immediately before calling audio_reset_session.
|
||||
u32 reverbFilterCountConsole = (NUM_ALLPASS - 6);
|
||||
|
||||
// This value represents the number of filters to use with the reverb. This can be decreased to improve performance, but at the cost of a lesser presence of reverb in the final audio.
|
||||
// Filter count should always be a multiple of 3. Never ever set this value to be greater than NUM_ALLPASS.
|
||||
// Setting it to anything less than 3 will disable reverb outright.
|
||||
// This can be changed at any time, but is best set when calling audio_reset_session.
|
||||
// This can be changed at any time, but is best set immediately before calling audio_reset_session.
|
||||
u32 reverbFilterCountEmulator = NUM_ALLPASS;
|
||||
|
||||
// Set this to TRUE to use mono over stereo for reverb. This should increase performance, but at the cost of a less fullfilling reverb experience.
|
||||
// If performance is desirable, it is recommended to change reverbFilterCountConsole or betterReverbDownsampleConsole first.
|
||||
// This can be changed at any time, but is best set when calling audio_reset_session.
|
||||
// This can be changed at any time, but is best set immediately before calling audio_reset_session.
|
||||
u8 monoReverbConsole = FALSE;
|
||||
|
||||
// Set this to TRUE to use mono over stereo for reverb. This should increase performance, but at the cost of a less fullfilling reverb experience.
|
||||
// If performance is desirable, it is recommended to change reverbFilterCountEmulator or betterReverbDownsampleEmulator first.
|
||||
// This can be changed at any time, but is best set when calling audio_reset_session.
|
||||
// This can be changed at any time, but is best set immediately before calling audio_reset_session.
|
||||
u8 monoReverbEmulator = FALSE;
|
||||
|
||||
// This value controls the size of the reverb buffer. It affects the global reverb delay time. This variable is one of the easiest to control.
|
||||
// It is not recommended setting this to values greater than 0x1000 * 2^(downsample factor - 1), as you run the risk of running into a memory issue (though this is far from a guarantee).
|
||||
// Setting the value lower than the downsample buffer size will destroy the game audio. This is taken into account automatically, but also means the value set here isn't what always gets used.
|
||||
// Similarly, this value maxes out at (REVERB_WINDOW_SIZE_MAX * 2^(downsample factor - 1)).
|
||||
// If this value is changed, it will go into effect the next time audio_reset_session is called.
|
||||
// Set to -1 to use a default preset instead. Higher values represent more audio delay (usually better for echoey spaces).
|
||||
s32 betterReverbWindowsSize = -1;
|
||||
@@ -120,32 +121,15 @@ s32 betterReverbWindowsSize = -1;
|
||||
|
||||
// These values affect filter delays. Bigger values will result in fatter echo (and more memory); must be cumulatively smaller than BETTER_REVERB_SIZE/2.
|
||||
// If setting a reverb downsample value to 1, these must be cumulatively smaller than BETTER_REVERB_SIZE/4.
|
||||
// These values should never be changed unless in this declaration or during a call to audio_reset_session, as it could otherwise lead to a major memory leak or garbage audio.
|
||||
// None of the delay values should ever be smaller than 1 either; these are s32s purely to avoid typecasts.
|
||||
// These values are currently set by using delaysBaseline in the audio_reset_session function, so its behavior must be overridden to use dynamically (or at all).
|
||||
s32 delaysL[NUM_ALLPASS] = {
|
||||
// None of the delay values should ever be smaller than 1; these are s32s purely to avoid typecasts.
|
||||
// These values are applied any time audio_reset_session is called, and as such can be changed at any time without issues.
|
||||
s32 delaysBaselineL[NUM_ALLPASS] = {
|
||||
1080, 1352, 1200,
|
||||
1200, 1232, 1432,
|
||||
1384, 1048, 1352,
|
||||
928, 1504, 1512
|
||||
};
|
||||
s32 delaysR[NUM_ALLPASS] = {
|
||||
1384, 1352, 1048,
|
||||
928, 1512, 1504,
|
||||
1080, 1200, 1352,
|
||||
1200, 1432, 1232
|
||||
};
|
||||
|
||||
// Like the delays array, but represents default max values that don't change (also probably somewhat redundant)
|
||||
// Change this array rather than the delays array to customize reverb delay times globally.
|
||||
// Similarly to delaysL/R, these should be kept within the memory constraints defined by BETTER_REVERB_SIZE.
|
||||
const s32 delaysBaselineL[NUM_ALLPASS] = {
|
||||
1080, 1352, 1200,
|
||||
1200, 1232, 1432,
|
||||
1384, 1048, 1352,
|
||||
928, 1504, 1512
|
||||
};
|
||||
const s32 delaysBaselineR[NUM_ALLPASS] = {
|
||||
s32 delaysBaselineR[NUM_ALLPASS] = {
|
||||
1384, 1352, 1048,
|
||||
928, 1512, 1504,
|
||||
1080, 1200, 1352,
|
||||
@@ -164,10 +148,12 @@ s32 reverbFilterCount = NUM_ALLPASS;
|
||||
s32 reverbFilterCountm1 = (NUM_ALLPASS - 1);
|
||||
u8 monoReverb = FALSE;
|
||||
u8 toggleBetterReverb = TRUE;
|
||||
s32 allpassIdxL[NUM_ALLPASS] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
s32 allpassIdxR[NUM_ALLPASS] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
s32 tmpBufL[NUM_ALLPASS] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
s32 tmpBufR[NUM_ALLPASS] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
s32 allpassIdxL[NUM_ALLPASS] = {0};
|
||||
s32 allpassIdxR[NUM_ALLPASS] = {0};
|
||||
s32 tmpBufL[NUM_ALLPASS] = {0};
|
||||
s32 tmpBufR[NUM_ALLPASS] = {0};
|
||||
s32 delaysL[NUM_ALLPASS] = {0};
|
||||
s32 delaysR[NUM_ALLPASS] = {0};
|
||||
s32 **delayBufsL;
|
||||
s32 **delayBufsR;
|
||||
#endif
|
||||
|
||||
@@ -39,8 +39,8 @@ extern u8 monoReverbConsole;
|
||||
extern u8 monoReverbEmulator;
|
||||
extern s32 betterReverbWindowsSize;
|
||||
|
||||
extern const s32 delaysBaselineL[NUM_ALLPASS];
|
||||
extern const s32 delaysBaselineR[NUM_ALLPASS];
|
||||
extern s32 delaysBaselineL[NUM_ALLPASS];
|
||||
extern s32 delaysBaselineR[NUM_ALLPASS];
|
||||
extern s32 delaysL[NUM_ALLPASS];
|
||||
extern s32 delaysR[NUM_ALLPASS];
|
||||
extern s32 reverbMultsL[NUM_ALLPASS / 3];
|
||||
@@ -51,6 +51,8 @@ extern s32 **delayBufsR;
|
||||
extern u8 toggleBetterReverb;
|
||||
#define REVERB_WINDOW_SIZE_MAX 0x2000
|
||||
|
||||
STATIC_ASSERT(NUM_ALLPASS % 3 == 0, "NUM_ALLPASS must be a multiple of 3!");
|
||||
|
||||
#else
|
||||
|
||||
#define BETTER_REVERB_SIZE 0
|
||||
|
||||
Reference in New Issue
Block a user