ft2-clone

Fasttracker 2 clone
Log | Files | Refs | README | LICENSE

commit 0ea4b9cc0e6cf55d8c947413b51561aec3f03ba5
parent b8e6ddadc1ee4b4c0aca5f5ecc943db37567772a
Author: Olav Sørensen <olav.sorensen@live.no>
Date:   Fri, 17 Jan 2025 19:46:46 +0100

Less RAM usage

Diffstat:
Msrc/ft2_audio.c | 9++-------
Msrc/ft2_audio.h | 2+-
Msrc/ft2_replayer.h | 2+-
Msrc/scopes/ft2_scopes.c | 2+-
4 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/src/ft2_audio.c b/src/ft2_audio.c @@ -386,11 +386,6 @@ void updateVoices(void) // set voice delta v->delta = (int64_t)((dVoiceHz * audio.dHz2MixDeltaMul) + 0.5); // Hz -> fixed-point delta (rounded) - - // set scope delta - const double dHz2ScopeDeltaMul = SCOPE_FRAC_SCALE / (double)SCOPE_HZ; - v->scopeDelta = (int64_t)((dVoiceHz * dHz2ScopeDeltaMul) + 0.5); // Hz -> fixed-point delta (rounded) - if (audio.sincInterpolation) { // decide which sinc LUT to use according to the resampling ratio @@ -771,14 +766,14 @@ static void fillVisualsSyncBuffer(void) for (int32_t i = 0; i < song.numChannels; i++, c++, s++, v++) { c->scopeVolume = v->scopeVolume; - c->scopeDelta = v->scopeDelta; + c->period = s->finalPeriod; c->instrNum = s->instrNum; c->smpNum = s->smpNum; c->status = s->tmpStatus; c->smpStartPos = s->smpStartPos; c->pianoNoteNum = 255; // no piano key - if (songPlaying && (c->status & IS_Period) && !s->keyOff) + if (songPlaying && ui.instEditorShown && (c->status & IS_Period) && !s->keyOff) { const int32_t note = getPianoKey(s->finalPeriod, s->finetune, s->relativeNote); if (note >= 0 && note <= 95) diff --git a/src/ft2_audio.h b/src/ft2_audio.h @@ -62,7 +62,7 @@ typedef struct const int16_t *base16, *revBase16; bool active, samplingBackwards, isFadeOutVoice, hasLooped; uint8_t mixFuncOffset, panning, loopType, scopeVolume; - int32_t position, sampleEnd, loopStart, loopLength, oldPeriod; + int32_t position, sampleEnd, loopStart, loopLength; uint32_t volumeRampLength; uint64_t positionFrac, delta, scopeDelta; diff --git a/src/ft2_replayer.h b/src/ft2_replayer.h @@ -195,8 +195,8 @@ note_t; typedef struct syncedChannel_t // used for audio/video sync queue (pack to save RAM) { uint8_t status, pianoNoteNum, smpNum, instrNum, scopeVolume; + uint16_t period; int32_t smpStartPos; - uint64_t scopeDelta; } #ifdef __GNUC__ __attribute__ ((packed)) diff --git a/src/scopes/ft2_scopes.c b/src/scopes/ft2_scopes.c @@ -492,7 +492,7 @@ void handleScopesFromChQueue(chSyncData_t *chSyncData, uint8_t *scopeUpdateStatu sc->volume = ch->scopeVolume; if (status & IS_Period) - sc->delta = ch->scopeDelta; + sc->delta = (uint64_t)(dPeriod2Hz(ch->period) * (SCOPE_FRAC_SCALE / (double)SCOPE_HZ)); if (status & IS_Trigger) {