commit 1502ffc9defe52cf4d7c6b9aa0fcfda4f890c7f8
parent 89718dd6d2c10faa93bb9147142ee4f003e677ee
Author: Olav Sørensen <olav.sorensen@live.no>
Date: Wed, 11 Sep 2024 14:37:52 +0200
Small code change for the scope visualizer
Diffstat:
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/scopes/ft2_scope_macros.h b/src/scopes/ft2_scope_macros.h
@@ -10,7 +10,7 @@
#define SCOPE_REGS_NO_LOOP \
const int32_t volume = s->volume; \
const int32_t sampleEnd = s->sampleEnd; \
- const uint32_t delta = (uint32_t)(s->delta >> (SCOPE_FRAC_BITS-10)); \
+ const uint32_t delta = s->drawDelta; \
const uint32_t color = video.palette[PAL_PATTEXT]; \
const uint32_t width = x + w; \
int32_t sample; \
@@ -22,7 +22,7 @@
const int32_t sampleEnd = s->sampleEnd; \
const int32_t loopStart = s->loopStart; \
const int32_t loopLength = s->loopLength; \
- const uint32_t delta = (uint32_t)(s->delta >> (SCOPE_FRAC_BITS-10)); \
+ const uint32_t delta = s->drawDelta; \
const uint32_t color = video.palette[PAL_PATTEXT]; \
const uint32_t width = x + w; \
int32_t sample; \
@@ -34,7 +34,7 @@
const int32_t sampleEnd = s->sampleEnd; \
const int32_t loopStart = s->loopStart; \
const int32_t loopLength = s->loopLength; \
- const uint32_t delta = (uint32_t)(s->delta >> (SCOPE_FRAC_BITS-10)); \
+ const uint32_t delta = s->drawDelta; \
const uint32_t color = video.palette[PAL_PATTEXT]; \
const uint32_t width = x + w; \
int32_t sample; \
diff --git a/src/scopes/ft2_scopes.c b/src/scopes/ft2_scopes.c
@@ -432,6 +432,11 @@ void drawScopes(void)
// scope is active
scope[i].wasCleared = false;
+ // get relative voice Hz (in relation to middle-C rate), and scale to 16.16fp
+ const uint32_t relHz16 = (uint32_t)(scope[i].delta * (((double)SCOPE_HZ / SCOPE_FRAC_SCALE) / (C4_FREQ / 65536.0)));
+
+ scope[i].drawDelta = relHz16 << 1; // FT2 does this to the final 16.16fp value
+
// clear scope background
clearRect(scopeXOffs, scopeYOffs, scopeDrawLen, SCOPE_HEIGHT);
diff --git a/src/scopes/ft2_scopes.h b/src/scopes/ft2_scopes.h
@@ -28,6 +28,7 @@ typedef struct scope_t
bool wasCleared, sample16Bit;
uint8_t loopType;
int32_t volume, direction, loopStart, loopLength, sampleEnd, position;
+ uint32_t drawDelta;
uint64_t delta, positionFrac;
} scope_t;