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