Skip to content

Commit

Permalink
Undo reverb edit for now
Browse files Browse the repository at this point in the history
Backfill buffer as sanity check
  • Loading branch information
worleydl committed Apr 7, 2024
1 parent 73ec7f9 commit 651df0b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions soh/soh/mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ static inline int32_t clamp32(int64_t v) {
return (int32_t)v;
}

void aBackfillBufferImpl(uint16_t addr, int nbytes) {
memset(BUF_U8(addr), 0, nbytes);
}

void aClearBufferImpl(uint16_t addr, int nbytes) {
nbytes = ROUND_UP_16(nbytes);
memset(BUF_U8(addr), 0, nbytes);
Expand Down
2 changes: 2 additions & 0 deletions soh/soh/mixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#undef aUnkCmd3
#undef aUnkCmd19

void aBackfillBufferImpl(uint16_t addr, int nbytes);
void aClearBufferImpl(uint16_t addr, int nbytes);
void aLoadBufferImpl(const void* source_addr, uint16_t dest_addr, uint16_t nbytes);
void aLoadBufferNoRoundImpl(const void* source_addr, uint16_t dest_addr, uint16_t nbytes);
Expand Down Expand Up @@ -61,6 +62,7 @@ void aUnkCmd19Impl(uint8_t f, uint16_t count, uint16_t out_addr, uint16_t in_add
#define aSegment(pkt, s, b) \
do { \
} while (0)
#define aBackfillBuffer(d, c) aBackfillBufferImpl(d, c)
#define aClearBuffer(pkt, d, c) aClearBufferImpl(d, c)
#define aLoadBuffer(pkt, s, d, c) aLoadBufferImpl(s, d, c)
#define aLoadBufferNoRound(pkt, s, d, c) aLoadBufferNoRoundImpl(s, d, c)
Expand Down
6 changes: 3 additions & 3 deletions soh/src/code/audio_synthesis.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ Acmd* AudioSynth_DoOneAudioUpdate(s16* aiBuf, s32 aiBufLen, Acmd* cmd, s32 updat
return cmd;
}

// yanked from mixer, maybe make it public?
Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisState* synthState, s16* aiBuf,
s32 aiBufLen, Acmd* cmd, s32 updateIndex) {
s32 pad1[3];
Expand Down Expand Up @@ -803,7 +804,6 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
noteFinished = false;
restart = false;
phi_s4 = 0;
endOfSample = false;

nFirstFrameSamplesToIgnore = synthState->samplePosInt & 0xF;
nSamplesUntilLoopEnd = loopEndPos - synthState->samplePosInt;
Expand Down Expand Up @@ -869,7 +869,6 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
s5 = samplesLenAdjusted;
goto skip;
case CODEC_REVERB:
goto skip;
break;
}

Expand Down Expand Up @@ -906,10 +905,11 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
* S
* DDDDDDDDDPPPPPPPPPPPPPPPP
*
* This should return a padding of 17, not 25
* This should return an "align" of 17, not 25
*/
ramAlign = min((nFramesToDecode * frameSize) + 16, (audioFontSample->size + 16) - (sampleDataOffset + sampleDataStart));
aLoadBufferNoRound(cmd++, sampleData - sampleDataStartPad, addr, ramAlign);
aBackfillBuffer(addr + ramAlign, aligned - ramAlign); // Dunno if needed but I make believe this fixes artifacts
}

} else {
Expand Down

0 comments on commit 651df0b

Please sign in to comment.