shithub: ft²

Download patch

ref: 0ea4b9cc0e6cf55d8c947413b51561aec3f03ba5
parent: b8e6ddadc1ee4b4c0aca5f5ecc943db37567772a
author: Olav Sørensen <olav.sorensen@live.no>
date: Fri Jan 17 14:47:13 EST 2025

Less RAM usage

--- a/src/ft2_audio.c
+++ b/src/ft2_audio.c
@@ -386,11 +386,6 @@
 
 			// 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,7 +766,7 @@
 	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;
@@ -778,7 +773,7 @@
 		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)
--- a/src/ft2_audio.h
+++ b/src/ft2_audio.h
@@ -62,7 +62,7 @@
 	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;
 
--- a/src/ft2_replayer.h
+++ b/src/ft2_replayer.h
@@ -195,8 +195,8 @@
 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))
--- a/src/scopes/ft2_scopes.c
+++ b/src/scopes/ft2_scopes.c
@@ -492,7 +492,7 @@
 			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)
 		{
--