From e541c44e385fc4c299388efe3c3571c808e146a6 Mon Sep 17 00:00:00 2001
From: David Huss <dh@atoav.com>
Date: Sat, 17 Feb 2024 04:53:33 +0100
Subject: [PATCH] Scale waveform when volume is changed

If the volume control is changed the waveform changes as well

Changelog: feature
---
 daisyy-looper/daisyy-looper.ino | 2 +-
 daisyy-looper/ui.h              | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/daisyy-looper/daisyy-looper.ino b/daisyy-looper/daisyy-looper.ino
index cc9f68a..afad6f1 100644
--- a/daisyy-looper/daisyy-looper.ino
+++ b/daisyy-looper/daisyy-looper.ino
@@ -426,7 +426,7 @@ void loop() {
   switch (ui.fx_mode) {
     case FX_MODE_ALL:
       if (!isnan(p5)) {  lfo_amount = p5; }
-      if (!isnan(p6)) {  ui.activeLooper()->volume = p6 * 4.0f; }
+      if (!isnan(p6)) {  ui.activeLooper()->volume = p6 * 4.0f; ui.recalculateWaveform(); }
       if (!isnan(p7)) {  reverbmix = p7; }
       break;
     case FX_MODE_REVERB:
diff --git a/daisyy-looper/ui.h b/daisyy-looper/ui.h
index 1d997a5..34e1ff2 100644
--- a/daisyy-looper/ui.h
+++ b/daisyy-looper/ui.h
@@ -873,6 +873,10 @@ class Ui {
       activeLooper()->SetLoop(start, length);
     }
 
+    void recalculateWaveform() {
+      this->waveform_cache_dirty = true;
+    }
+
     private:
       double last_render = 0.0;
       uint16_t waveform_cache[128] = {0};
-- 
GitLab