mirror of
https://github.com/HarbourMasters/Starship.git
synced 2025-03-15 04:13:59 +03:00
fix reverbs: co-authored-by: @m4xw
This commit is contained in:
parent
e61aeddb64
commit
b35697e28d
@ -53,7 +53,7 @@ typedef void (*AudioCustomUpdateFunction)(void);
|
|||||||
#define SAMPLES_PER_FRAME ADPCMFSIZE
|
#define SAMPLES_PER_FRAME ADPCMFSIZE
|
||||||
|
|
||||||
// The length of one left/right channel is 13 frames
|
// The length of one left/right channel is 13 frames
|
||||||
#define DMEM_1CH_SIZE (13 * SAMPLES_PER_FRAME * SAMPLE_SIZE)
|
#define DMEM_1CH_SIZE (12 * SAMPLES_PER_FRAME * SAMPLE_SIZE)
|
||||||
// Both left and right channels
|
// Both left and right channels
|
||||||
#define DMEM_2CH_SIZE (2 * DMEM_1CH_SIZE)
|
#define DMEM_2CH_SIZE (2 * DMEM_1CH_SIZE)
|
||||||
|
|
||||||
@ -610,7 +610,7 @@ typedef struct {
|
|||||||
/* 0x06 */ u16 panVolLeft;
|
/* 0x06 */ u16 panVolLeft;
|
||||||
/* 0x08 */ u16 panVolRight;
|
/* 0x08 */ u16 panVolRight;
|
||||||
/* 0x0A */ u16 resampleRate;
|
/* 0x0A */ u16 resampleRate;
|
||||||
/* 0x0C */ s16* waveSampleAddr;
|
/* 0x0C */ Sample** waveSampleAddr;
|
||||||
} NoteSubEu; // size = 0x10
|
} NoteSubEu; // size = 0x10
|
||||||
|
|
||||||
typedef struct Note {
|
typedef struct Note {
|
||||||
@ -623,7 +623,7 @@ typedef struct Note {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* 0x00 */ u8 downsampleRate;
|
/* 0x00 */ u8 downsampleRate;
|
||||||
/* 0x02 */ u8 windowSize;
|
/* 0x01 */ u8 windowSize;
|
||||||
/* 0x02 */ u16 decayRatio; // determines how much reverb persists
|
/* 0x02 */ u16 decayRatio; // determines how much reverb persists
|
||||||
/* 0x04 */ u16 leakRtL;
|
/* 0x04 */ u16 leakRtL;
|
||||||
/* 0x06 */ u16 leakLtR;
|
/* 0x06 */ u16 leakLtR;
|
||||||
|
@ -451,7 +451,7 @@ uintptr_t AudioHeap_SearchCaches(s32 tableType, s32 cache, s32 id) {
|
|||||||
return (uintptr_t) ramAddr;
|
return (uintptr_t) ramAddr;
|
||||||
}
|
}
|
||||||
if (cache == CACHE_PERMANENT) {
|
if (cache == CACHE_PERMANENT) {
|
||||||
//return (uintptr_t) NULL;
|
// return (uintptr_t) NULL;
|
||||||
}
|
}
|
||||||
return (uintptr_t) AudioHeap_SearchRegularCaches(tableType, cache, id);
|
return (uintptr_t) AudioHeap_SearchRegularCaches(tableType, cache, id);
|
||||||
}
|
}
|
||||||
@ -597,7 +597,7 @@ s32 AudioHeap_ResetStep(void) {
|
|||||||
gResetFadeoutFramesLeft--;
|
gResetFadeoutFramesLeft--;
|
||||||
AudioHeap_UpdateReverbs();
|
AudioHeap_UpdateReverbs();
|
||||||
} else {
|
} else {
|
||||||
// memset(audio_buffer, 0, (1056 * 2 * 3) * 2 * 2);
|
// memset(audio_buffer, 0, (1056 * 2 * 3) * 2 * 2);
|
||||||
gResetFadeoutFramesLeft = 4 / sp24;
|
gResetFadeoutFramesLeft = 4 / sp24;
|
||||||
gAudioResetStep--;
|
gAudioResetStep--;
|
||||||
break; // needed to match
|
break; // needed to match
|
||||||
@ -615,7 +615,7 @@ s32 AudioHeap_ResetStep(void) {
|
|||||||
case 1:
|
case 1:
|
||||||
AudioHeap_Init();
|
AudioHeap_Init();
|
||||||
gAudioResetStep = 0;
|
gAudioResetStep = 0;
|
||||||
// memset(audio_buffer, 0, (1056 * 2 * 3) * 2 * 2);
|
// memset(audio_buffer, 0, (1056 * 2 * 3) * 2 * 2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (gAudioResetStep < 3) {
|
if (gAudioResetStep < 3) {
|
||||||
@ -628,8 +628,6 @@ void AudioHeap_Init(void) {
|
|||||||
s32 i;
|
s32 i;
|
||||||
s32 j;
|
s32 j;
|
||||||
AudioSpec* spec = &gAudioSpecs[gAudioSpecId];
|
AudioSpec* spec = &gAudioSpecs[gAudioSpecId];
|
||||||
ReverbSettings* settings;
|
|
||||||
SynthesisReverb* reverb;
|
|
||||||
s16* ramAddr;
|
s16* ramAddr;
|
||||||
u32 persistentSize;
|
u32 persistentSize;
|
||||||
u32 temporarySize;
|
u32 temporarySize;
|
||||||
@ -652,7 +650,7 @@ void AudioHeap_Init(void) {
|
|||||||
gAudioBufferParams.resampleRate = 32000.0f / (s32) gAudioBufferParams.samplingFrequency;
|
gAudioBufferParams.resampleRate = 32000.0f / (s32) gAudioBufferParams.samplingFrequency;
|
||||||
gAudioBufferParams.ticksPerUpdateInvScaled = (3.0f / 2560.0f) / gAudioBufferParams.ticksPerUpdate;
|
gAudioBufferParams.ticksPerUpdateInvScaled = (3.0f / 2560.0f) / gAudioBufferParams.ticksPerUpdate;
|
||||||
gAudioBufferParams.ticksPerUpdateInv = 1.0f / gAudioBufferParams.ticksPerUpdate;
|
gAudioBufferParams.ticksPerUpdateInv = 1.0f / gAudioBufferParams.ticksPerUpdate;
|
||||||
|
|
||||||
gNumNotes = spec->numNotes;
|
gNumNotes = spec->numNotes;
|
||||||
D_8014C1B0 = spec->unk_14;
|
D_8014C1B0 = spec->unk_14;
|
||||||
|
|
||||||
@ -679,7 +677,7 @@ void AudioHeap_Init(void) {
|
|||||||
miscPoolSize = gSessionPool.size - cachePoolSize - 0x100;
|
miscPoolSize = gSessionPool.size - cachePoolSize - 0x100;
|
||||||
gSessionPoolSplit.miscPoolSize = miscPoolSize;
|
gSessionPoolSplit.miscPoolSize = miscPoolSize;
|
||||||
gSessionPoolSplit.cachePoolSize = cachePoolSize;
|
gSessionPoolSplit.cachePoolSize = cachePoolSize;
|
||||||
|
|
||||||
AudioHeap_InitSessionPools(&gSessionPoolSplit);
|
AudioHeap_InitSessionPools(&gSessionPoolSplit);
|
||||||
|
|
||||||
gCachePoolSplit.persistentCommonPoolSize = persistentSize;
|
gCachePoolSplit.persistentCommonPoolSize = persistentSize;
|
||||||
@ -707,7 +705,7 @@ void AudioHeap_Init(void) {
|
|||||||
func_800128B4();
|
func_800128B4();
|
||||||
|
|
||||||
gNoteSubsEu = AudioHeap_AllocZeroed(&gMiscPool, gAudioBufferParams.ticksPerUpdate * gNumNotes * sizeof(NoteSubEu));
|
gNoteSubsEu = AudioHeap_AllocZeroed(&gMiscPool, gAudioBufferParams.ticksPerUpdate * gNumNotes * sizeof(NoteSubEu));
|
||||||
|
|
||||||
for (i = 0; i != 2; i++) {
|
for (i = 0; i != 2; i++) {
|
||||||
gAbiCmdBuffs[i] = AudioHeap_AllocZeroed(&gMiscPool, gMaxAudioCmds * 8);
|
gAbiCmdBuffs[i] = AudioHeap_AllocZeroed(&gMiscPool, gMaxAudioCmds * 8);
|
||||||
}
|
}
|
||||||
@ -715,12 +713,10 @@ void AudioHeap_Init(void) {
|
|||||||
gSynthReverbs[i].useReverb = 0;
|
gSynthReverbs[i].useReverb = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// LTODO: Reverbs are causing distortion.
|
|
||||||
/*
|
|
||||||
gNumSynthReverbs = spec->numReverbs;
|
gNumSynthReverbs = spec->numReverbs;
|
||||||
for (i = 0; i < gNumSynthReverbs; i++) {
|
for (i = 0; i < gNumSynthReverbs; i++) {
|
||||||
settings = &spec->reverbSettings[i];
|
ReverbSettings* settings = &spec->reverbSettings[i];
|
||||||
reverb = &gSynthReverbs[i];
|
SynthesisReverb* reverb = &gSynthReverbs[i];
|
||||||
reverb->downsampleRate = settings->downsampleRate;
|
reverb->downsampleRate = settings->downsampleRate;
|
||||||
reverb->windowSize = settings->windowSize * 64;
|
reverb->windowSize = settings->windowSize * 64;
|
||||||
reverb->decayRatio = settings->decayRatio;
|
reverb->decayRatio = settings->decayRatio;
|
||||||
@ -736,6 +732,7 @@ void AudioHeap_Init(void) {
|
|||||||
|
|
||||||
reverb->bufSizePerChan = reverb->windowSize;
|
reverb->bufSizePerChan = reverb->windowSize;
|
||||||
reverb->framesToIgnore = 2;
|
reverb->framesToIgnore = 2;
|
||||||
|
|
||||||
if (reverb->downsampleRate != 1) {
|
if (reverb->downsampleRate != 1) {
|
||||||
reverb->resampleFlags = 1;
|
reverb->resampleFlags = 1;
|
||||||
reverb->unk_0A = (0x8000 / reverb->downsampleRate);
|
reverb->unk_0A = (0x8000 / reverb->downsampleRate);
|
||||||
@ -753,7 +750,7 @@ void AudioHeap_Init(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
AudioLoad_InitSampleDmaBuffers(gNumNotes);
|
AudioLoad_InitSampleDmaBuffers(gNumNotes);
|
||||||
gPreloadSampleStackTop = 0;
|
gPreloadSampleStackTop = 0;
|
||||||
D_8014C1B4 = 0x1000;
|
D_8014C1B4 = 0x1000;
|
||||||
@ -933,8 +930,9 @@ void AudioHeap_DiscardSampleCacheEntry(SampleCacheEntry* entry) {
|
|||||||
sampleBankId1 = gSoundFontList[fondId].sampleBankId1;
|
sampleBankId1 = gSoundFontList[fondId].sampleBankId1;
|
||||||
sampleBankId2 = gSoundFontList[fondId].sampleBankId2;
|
sampleBankId2 = gSoundFontList[fondId].sampleBankId2;
|
||||||
if (((sampleBankId1 != SAMPLES_NONE) && (entry->sampleBankId == sampleBankId1)) ||
|
if (((sampleBankId1 != SAMPLES_NONE) && (entry->sampleBankId == sampleBankId1)) ||
|
||||||
((sampleBankId2 != SAMPLES_NONE) && (entry->sampleBankId == sampleBankId2)) || (entry->sampleBankId == SAMPLES_SFX)) {
|
((sampleBankId2 != SAMPLES_NONE) && (entry->sampleBankId == sampleBankId2)) ||
|
||||||
if (((void*) AudioHeap_SearchCaches(FONT_TABLE, CACHE_EITHER, fondId) != NULL) &&
|
(entry->sampleBankId == SAMPLES_SFX)) {
|
||||||
|
if (((void*) AudioHeap_SearchCaches(FONT_TABLE, CACHE_EITHER, fondId) != NULL) &&
|
||||||
(gFontLoadStatus[fondId] > 1) != 0) {
|
(gFontLoadStatus[fondId] > 1) != 0) {
|
||||||
for (instId = 0; instId < gSoundFontList[fondId].numInstruments; instId++) {
|
for (instId = 0; instId < gSoundFontList[fondId].numInstruments; instId++) {
|
||||||
instrument = Audio_GetInstrument(fondId, instId);
|
instrument = Audio_GetInstrument(fondId, instId);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user