From fd5cdfecb4c2d6b6e66e9b23050633d19a4822bc Mon Sep 17 00:00:00 2001
From: Markus Kohlhase <markus.kohlhase@slowtec.de>
Date: Sun, 19 Sep 2021 21:13:59 +0200
Subject: [PATCH 01/36] Denon MC7000: Use parameter buttons for beat jumps

---
 res/controllers/Denon-MC7000-scripts.js | 40 ++++++++++++++++
 res/controllers/Denon-MC7000.midi.xml   | 64 ++++++++++++-------------
 2 files changed, 72 insertions(+), 32 deletions(-)

diff --git a/res/controllers/Denon-MC7000-scripts.js b/res/controllers/Denon-MC7000-scripts.js
index b647a43ffd8..97afcadf1f0 100644
--- a/res/controllers/Denon-MC7000-scripts.js
+++ b/res/controllers/Denon-MC7000-scripts.js
@@ -981,6 +981,46 @@ MC7000.StarsUp = function(channel, control, value, status, group) {
     }
 };
 
+// Parameter Button '<'
+MC7000.parameterButtonDown = function(channel, control, value, status, group) {
+    if (value) {
+        script.triggerControl(group, "beatjump_backward");
+    }
+};
+
+// Parameter Button '>'
+MC7000.parameterButtonUp = function(channel, control, value, status, group) {
+    if (value) {
+        script.triggerControl(group, "beatjump_forward");
+    }
+};
+
+// Parameter Button '<' + 'SHIFT'
+MC7000.parameterButtonDownShifted = function(channel, control, value, status, group) {
+    if (value) {
+        const beatJumpSize = engine.getValue(group, "beatjump_size");
+        let decreasedIndex = MC7000.beatJump.indexOf(beatJumpSize) - 1;
+        if (decreasedIndex < 0) {
+            decreasedIndex = 0;
+        }
+        const newBeatJumpSize = MC7000.beatJump[decreasedIndex];
+        engine.setValue(group, "beatjump_size", newBeatJumpSize);
+    }
+};
+
+// Parameter Button '>' + 'SHIFT'
+MC7000.parameterButtonUpShifted = function(channel, control, value, status, group) {
+    if (value) {
+        const beatjumpSize = engine.getValue(group, "beatjump_size");
+        let increasedIndex = MC7000.beatJump.indexOf(beatjumpSize) + 1;
+        if (increasedIndex >= MC7000.beatJump.length) {
+            increasedIndex = MC7000.beatJump.length === 0 ? 0 : MC7000.beatJump.length - 1;
+        }
+        const newBeatJumpSize = MC7000.beatJump[increasedIndex];
+        engine.setValue(group, "beatjump_size", newBeatJumpSize);
+    }
+};
+
 // Set Crossfader Curve
 MC7000.crossFaderCurve = function(control, value) {
     script.crossfaderCurve(value);
diff --git a/res/controllers/Denon-MC7000.midi.xml b/res/controllers/Denon-MC7000.midi.xml
index 29d43d4841f..619b2c5a0c5 100644
--- a/res/controllers/Denon-MC7000.midi.xml
+++ b/res/controllers/Denon-MC7000.midi.xml
@@ -1984,7 +1984,7 @@
 <!-- PARAMETER BUTTONS -->
 			<control>
                 <group>[Channel1]</group>
-                <key>MC7000.StarsDown</key>
+                <key>MC7000.parameterButtonDown</key>
                 <description></description>
                 <status>0x94</status>
                 <midino>0x28</midino>
@@ -1994,7 +1994,7 @@
             </control>
             <control>
                 <group>[Channel1]</group>
-                <key>MC7000.StarsUp</key>
+                <key>MC7000.parameterButtonUp</key>
                 <description></description>
                 <status>0x94</status>
                 <midino>0x29</midino>
@@ -2003,28 +2003,28 @@
                 </options>
             </control>
             <control>
-                <group>[Library]</group>
-                <key>track_color_prev</key>
+                <group>[Channel1]</group>
+                <key>MC7000.parameterButtonDownShifted</key>
                 <description></description>
                 <status>0x94</status>
                 <midino>0x2A</midino>
                 <options>
-                    <normal/>
+                    <script-binding/>
                 </options>
             </control>
             <control>
-                <group>[Library]</group>
-                <key>track_color_next</key>
+                <group>[Channel1]</group>
+                <key>MC7000.parameterButtonUpShifted</key>
                 <description></description>
                 <status>0x94</status>
                 <midino>0x2B</midino>
                 <options>
-                    <normal/>
+                    <script-binding/>
                 </options>
             </control>
             <control>
                 <group>[Channel2]</group>
-                <key>MC7000.StarsDown</key>
+                <key>MC7000.parameterButtonDown</key>
                 <description></description>
                 <status>0x95</status>
                 <midino>0x28</midino>
@@ -2034,7 +2034,7 @@
             </control>
             <control>
                 <group>[Channel2]</group>
-                <key>MC7000.StarsUp</key>
+                <key>MC7000.parameterButtonUp</key>
                 <description></description>
                 <status>0x95</status>
                 <midino>0x29</midino>
@@ -2043,28 +2043,28 @@
                 </options>
             </control>
             <control>
-                <group>[Library]</group>
-                <key>track_color_prev</key>
+                <group>[Channel2]</group>
+                <key>MC7000.parameterButtonDownShifted</key>
                 <description></description>
                 <status>0x95</status>
                 <midino>0x2A</midino>
                 <options>
-                    <normal/>
+                    <script-binding/>
                 </options>
             </control>
             <control>
-                <group>[Library]</group>
-                <key>track_color_next</key>
+                <group>[Channel2]</group>
+                <key>MC7000.parameterButtonUpShifted</key>
                 <description></description>
                 <status>0x95</status>
                 <midino>0x2B</midino>
                 <options>
-                    <normal/>
+                    <script-binding/>
                 </options>
             </control>
             <control>
                 <group>[Channel3]</group>
-                <key>MC7000.StarsDown</key>
+                <key>MC7000.parameterButtonDown</key>
                 <description></description>
                 <status>0x96</status>
                 <midino>0x28</midino>
@@ -2074,7 +2074,7 @@
             </control>
             <control>
                 <group>[Channel3]</group>
-                <key>MC7000.StarsUp</key>
+                <key>MC7000.parameterButtonUp</key>
                 <description></description>
                 <status>0x96</status>
                 <midino>0x29</midino>
@@ -2083,28 +2083,28 @@
                 </options>
             </control>
             <control>
-                <group>[Library]</group>
-                <key>track_color_prev</key>
+                <group>[Channel3]</group>
+                <key>MC7000.parameterButtonDownShifted</key>
                 <description></description>
                 <status>0x96</status>
                 <midino>0x2A</midino>
                 <options>
-                    <normal/>
+                    <script-binding/>
                 </options>
             </control>
             <control>
-                <group>[Library]</group>
-                <key>track_color_next</key>
+                <group>[Channel3]</group>
+                <key>MC7000.parameterButtonUpShifted</key>
                 <description></description>
                 <status>0x96</status>
                 <midino>0x2B</midino>
                 <options>
-                    <normal/>
+                    <script-binding/>
                 </options>
             </control>
             <control>
                 <group>[Channel4]</group>
-                <key>MC7000.StarsDown</key>
+                <key>MC7000.parameterButtonDown</key>
                 <description></description>
                 <status>0x97</status>
                 <midino>0x28</midino>
@@ -2114,7 +2114,7 @@
             </control>
             <control>
                 <group>[Channel4]</group>
-                <key>MC7000.StarsUp</key>
+                <key>MC7000.parameterButtonUp</key>
                 <description></description>
                 <status>0x97</status>
                 <midino>0x29</midino>
@@ -2123,23 +2123,23 @@
                 </options>
             </control>
             <control>
-                <group>[Library]</group>
-                <key>track_color_prev</key>
+                <group>[Channel4]</group>
+                <key>MC7000.parameterButtonDownShifted</key>
                 <description></description>
                 <status>0x97</status>
                 <midino>0x2A</midino>
                 <options>
-                    <normal/>
+                    <script-binding/>
                 </options>
             </control>
             <control>
-                <group>[Library]</group>
-                <key>track_color_next</key>
+                <group>[Channel4]</group>
+                <key>MC7000.parameterButtonUpShifted</key>
                 <description></description>
                 <status>0x97</status>
                 <midino>0x2B</midino>
                 <options>
-                    <normal/>
+                    <script-binding/>
                 </options>
             </control>
 <!-- LIBRARY -->

From c0002cb4c97cd31d7a55696dcf2a1c24f8ba7068 Mon Sep 17 00:00:00 2001
From: fwcd <fwcd@fwcd.dev>
Date: Thu, 22 Aug 2024 02:03:13 +0200
Subject: [PATCH 02/36] Denon MC7000: Remove unused paramButton variable

---
 res/controllers/Denon-MC7000-scripts.js | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/res/controllers/Denon-MC7000-scripts.js b/res/controllers/Denon-MC7000-scripts.js
index 97afcadf1f0..bb339ad2ce5 100644
--- a/res/controllers/Denon-MC7000-scripts.js
+++ b/res/controllers/Denon-MC7000-scripts.js
@@ -162,9 +162,6 @@ MC7000.prevVuLevel = [0, 0, 0, 0];
 MC7000.prevJogLED = [0, 0, 0, 0];
 MC7000.prevPadLED = [0, 0, 0, 0];
 
-// Param Buttons for Pitch Play
-MC7000.paramButton = [0, 0, 0, 0];
-
 /*
 Color Codes:
 Colors are encoded using the following schema: Take the individual components of the color (R, G, B). Then use

From ae43298a1d71b6066012f38db06c939b180f362c Mon Sep 17 00:00:00 2001
From: fwcd <fwcd@fwcd.dev>
Date: Thu, 22 Aug 2024 02:14:39 +0200
Subject: [PATCH 03/36] Denon MC7000: Use early return for better readability

---
 res/controllers/Denon-MC7000-scripts.js | 44 ++++++++++++++-----------
 1 file changed, 24 insertions(+), 20 deletions(-)

diff --git a/res/controllers/Denon-MC7000-scripts.js b/res/controllers/Denon-MC7000-scripts.js
index bb339ad2ce5..3653ba8a574 100644
--- a/res/controllers/Denon-MC7000-scripts.js
+++ b/res/controllers/Denon-MC7000-scripts.js
@@ -980,42 +980,46 @@ MC7000.StarsUp = function(channel, control, value, status, group) {
 
 // Parameter Button '<'
 MC7000.parameterButtonDown = function(channel, control, value, status, group) {
-    if (value) {
-        script.triggerControl(group, "beatjump_backward");
+    if (value === 0) {
+        return;
     }
+    script.triggerControl(group, "beatjump_backward");
 };
 
 // Parameter Button '>'
 MC7000.parameterButtonUp = function(channel, control, value, status, group) {
-    if (value) {
-        script.triggerControl(group, "beatjump_forward");
+    if (value === 0) {
+        return;
     }
+    script.triggerControl(group, "beatjump_forward");
 };
 
 // Parameter Button '<' + 'SHIFT'
 MC7000.parameterButtonDownShifted = function(channel, control, value, status, group) {
-    if (value) {
-        const beatJumpSize = engine.getValue(group, "beatjump_size");
-        let decreasedIndex = MC7000.beatJump.indexOf(beatJumpSize) - 1;
-        if (decreasedIndex < 0) {
-            decreasedIndex = 0;
-        }
-        const newBeatJumpSize = MC7000.beatJump[decreasedIndex];
-        engine.setValue(group, "beatjump_size", newBeatJumpSize);
+    if (value === 0) {
+        return;
+    }
+    const beatJumpSize = engine.getValue(group, "beatjump_size");
+    let decreasedIndex = MC7000.beatJump.indexOf(beatJumpSize) - 1;
+    if (decreasedIndex < 0) {
+        decreasedIndex = 0;
     }
+    const newBeatJumpSize = MC7000.beatJump[decreasedIndex];
+    engine.setValue(group, "beatjump_size", newBeatJumpSize);
 };
 
 // Parameter Button '>' + 'SHIFT'
 MC7000.parameterButtonUpShifted = function(channel, control, value, status, group) {
-    if (value) {
-        const beatjumpSize = engine.getValue(group, "beatjump_size");
-        let increasedIndex = MC7000.beatJump.indexOf(beatjumpSize) + 1;
-        if (increasedIndex >= MC7000.beatJump.length) {
-            increasedIndex = MC7000.beatJump.length === 0 ? 0 : MC7000.beatJump.length - 1;
-        }
-        const newBeatJumpSize = MC7000.beatJump[increasedIndex];
-        engine.setValue(group, "beatjump_size", newBeatJumpSize);
+    if (value === 0) {
+        return;
+    }
+    const beatjumpSize = engine.getValue(group, "beatjump_size");
+    let increasedIndex = MC7000.beatJump.indexOf(beatjumpSize) + 1;
+    if (increasedIndex >= MC7000.beatJump.length) {
+        increasedIndex = MC7000.beatJump.length === 0 ? 0 : MC7000.beatJump.length - 1;
     }
+    const newBeatJumpSize = MC7000.beatJump[increasedIndex];
+    engine.setValue(group, "beatjump_size", newBeatJumpSize);
 };
 
 // Set Crossfader Curve

From 1187ee20fbd346711587097fe9c59b2354da0c0d Mon Sep 17 00:00:00 2001
From: fwcd <fwcd@fwcd.dev>
Date: Thu, 22 Aug 2024 02:48:35 +0200
Subject: [PATCH 04/36] Denon MC7000: Unify parameter button logic and make it
 customizable

---
 res/controllers/Denon-MC7000-scripts.js | 111 +++++++++++++-----------
 res/controllers/Denon-MC7000.midi.xml   |  43 +++++----
 2 files changed, 85 insertions(+), 69 deletions(-)

diff --git a/res/controllers/Denon-MC7000-scripts.js b/res/controllers/Denon-MC7000-scripts.js
index 3653ba8a574..06be810474e 100644
--- a/res/controllers/Denon-MC7000-scripts.js
+++ b/res/controllers/Denon-MC7000-scripts.js
@@ -110,6 +110,11 @@ MC7000.jogParams = {
     }
 };
 
+// Parameter button mode. See Denon-MC7000.midi.xml for documentation of the available modes.
+MC7000.parameterButtonSettings = {
+    mode: engine.getSetting("parameterButtonMode") || "starsAndColor",
+};
+
 /*/////////////////////////////////
 //      USER VARIABLES END       //
 /////////////////////////////////*/
@@ -949,77 +954,77 @@ MC7000.censor = function(channel, control, value, status, group) {
         }
     }
 };
-// Param Button for Pitch Play to decrease pitch, or decrease star rating otherwise
-MC7000.StarsDown = function(channel, control, value, status, group) {
-    const deckNumber = script.deckFromGroup(group);
-    const deckIndex = deckNumber - 1;
-    if (value > 0x00) {
-        if (MC7000.PADMode[deckIndex] === "Pitch") {
-            for (let padIdx = 0; padIdx < 8; padIdx++) {
-                MC7000.halftoneToPadMap[deckIndex][padIdx] = MC7000.halftoneToPadMap[deckIndex][padIdx] - 8; // pitch down
-            }
-        } else {
-            engine.setValue(group, "stars_down", true); // stars down
-        }
+
+// Parameter Buttons
+MC7000.parameterButton = function(value, group, {isLeftButton, isShiftPressed}) {
+    if (value === 0) {
+        return;
     }
-};
-// Param Button for Pitch Play to increase pitch, or increase star rating otherwise
-MC7000.StarsUp = function(channel, control, value, status, group) {
+
     const deckNumber = script.deckFromGroup(group);
     const deckIndex = deckNumber - 1;
-    if (value > 0x00) {
-        if (MC7000.PADMode[deckIndex] === "Pitch") {
-            for (let padIdx = 0; padIdx < 8; padIdx++) {
-                MC7000.halftoneToPadMap[deckIndex][padIdx] = MC7000.halftoneToPadMap[deckIndex][padIdx] + 8; // pitch up
+
+    if (MC7000.PADMode[deckIndex] === "Pitch") {
+        const pitchDelta = isLeftButton ? -8 : 8;
+        for (let padIdx = 0; padIdx < 8; padIdx++) {
+            MC7000.halftoneToPadMap[deckIndex][padIdx] += pitchDelta;
+        }
+    } else {
+        switch (MC7000.parameterButtonSettings.mode) {
+        case "starsAndColor":
+            if (isShiftPressed) {
+                script.triggerControl(group, `track_color_${isLeftButton ? "prev" : "next"}`);
+            } else {
+                script.triggerControl(group, `stars_${isLeftButton ? "down" : "up"}`);
             }
-        } else {
-            engine.setValue(group, "stars_up", true); // stars up
+            break;
+        case "beatjump":
+            if (isShiftPressed) {
+                const beatJumpSize = engine.getValue(group, "beatjump_size");
+                const indexDelta = isLeftButton ? -1 : 1;
+                const newIndex = Math.max(0, Math.min(MC7000.beatJump.length - 1, MC7000.beatJump.indexOf(beatJumpSize) + indexDelta));
+                const newBeatJumpSize = MC7000.beatJump[newIndex];
+                engine.setValue(group, "beatjump_size", newBeatJumpSize);
+            } else {
+                script.triggerControl(group, `beatjump_${isLeftButton ? "backward" : "forward"}`);
+            }
+            break;
+        default:
+            break;
         }
     }
 };
 
 // Parameter Button '<'
-MC7000.parameterButtonDown = function(channel, control, value, status, group) {
-    if (value === 0) {
-        return;
-    }
-    script.triggerControl(group, "beatjump_backward");
+MC7000.parameterButtonLeft = function(channel, control, value, status, group) {
+    MC7000.parameterButton(value, group, {
+        isLeftButton: true,
+        isShiftPressed: false
+    });
 };
 
 // Parameter Button '>'
-MC7000.parameterButtonUp = function(channel, control, value, status, group) {
-    if (value === 0) {
-        return;
-    }
-    script.triggerControl(group, "beatjump_forward");
+MC7000.parameterButtonRight = function(channel, control, value, status, group) {
+    MC7000.parameterButton(value, group, {
+        isLeftButton: false,
+        isShiftPressed: false
+    });
 };
 
 // Parameter Button '<' + 'SHIFT'
-MC7000.parameterButtonDownShifted = function(channel, control, value, status, group) {
-    if (value === 0) {
-        return;
-    }
-    const beatJumpSize = engine.getValue(group, "beatjump_size");
-    let decreasedIndex = MC7000.beatJump.indexOf(beatJumpSize) - 1;
-    if (decreasedIndex < 0) {
-        decreasedIndex = 0;
-    }
-    const newBeatJumpSize = MC7000.beatJump[decreasedIndex];
-    engine.setValue(group, "beatjump_size", newBeatJumpSize);
+MC7000.parameterButtonLeftShifted = function(channel, control, value, status, group) {
+    MC7000.parameterButton(value, group, {
+        isLeftButton: true,
+        isShiftPressed: true
+    });
 };
 
 // Parameter Button '>' + 'SHIFT'
-MC7000.parameterButtonUpShifted = function(channel, control, value, status, group) {
-    if (value === 0) {
-        return;
-    }
-    const beatjumpSize = engine.getValue(group, "beatjump_size");
-    let increasedIndex = MC7000.beatJump.indexOf(beatjumpSize) + 1;
-    if (increasedIndex >= MC7000.beatJump.length) {
-        increasedIndex = MC7000.beatJump.length === 0 ? 0 : MC7000.beatJump.length - 1;
-    }
-    const newBeatJumpSize = MC7000.beatJump[increasedIndex];
-    engine.setValue(group, "beatjump_size", newBeatJumpSize);
+MC7000.parameterButtonRightShifted = function(channel, control, value, status, group) {
+    MC7000.parameterButton(value, group, {
+        isLeftButton: false,
+        isShiftPressed: true
+    });
 };
 
 // Set Crossfader Curve
diff --git a/res/controllers/Denon-MC7000.midi.xml b/res/controllers/Denon-MC7000.midi.xml
index 619b2c5a0c5..001c1fd876d 100644
--- a/res/controllers/Denon-MC7000.midi.xml
+++ b/res/controllers/Denon-MC7000.midi.xml
@@ -64,6 +64,17 @@
                 </option>
             </group>
         </group>
+        <group label="Alternative Mapping">
+            <group label="Parameter Buttons">
+                <option
+                    variable="parameterButtonMode"
+                    type="enum"
+                    label="Parameter Button Mode">
+                    <value label="Change Star Rating (Shift: Track Color)">starsAndColor</value>
+                    <value label="Perform Beat Jump (Shift: Adjust Jump Size)">beatjump</value>
+                </option>
+            </group>
+        </group>
     </settings>
     <controller id="DENON MC7000">
         <scriptfiles>
@@ -1984,7 +1995,7 @@
 <!-- PARAMETER BUTTONS -->
 			<control>
                 <group>[Channel1]</group>
-                <key>MC7000.parameterButtonDown</key>
+                <key>MC7000.parameterButtonLeft</key>
                 <description></description>
                 <status>0x94</status>
                 <midino>0x28</midino>
@@ -1994,7 +2005,7 @@
             </control>
             <control>
                 <group>[Channel1]</group>
-                <key>MC7000.parameterButtonUp</key>
+                <key>MC7000.parameterButtonRight</key>
                 <description></description>
                 <status>0x94</status>
                 <midino>0x29</midino>
@@ -2004,7 +2015,7 @@
             </control>
             <control>
                 <group>[Channel1]</group>
-                <key>MC7000.parameterButtonDownShifted</key>
+                <key>MC7000.parameterButtonLeftShifted</key>
                 <description></description>
                 <status>0x94</status>
                 <midino>0x2A</midino>
@@ -2014,7 +2025,7 @@
             </control>
             <control>
                 <group>[Channel1]</group>
-                <key>MC7000.parameterButtonUpShifted</key>
+                <key>MC7000.parameterButtonRightShifted</key>
                 <description></description>
                 <status>0x94</status>
                 <midino>0x2B</midino>
@@ -2024,7 +2035,7 @@
             </control>
             <control>
                 <group>[Channel2]</group>
-                <key>MC7000.parameterButtonDown</key>
+                <key>MC7000.parameterButtonLeft</key>
                 <description></description>
                 <status>0x95</status>
                 <midino>0x28</midino>
@@ -2034,7 +2045,7 @@
             </control>
             <control>
                 <group>[Channel2]</group>
-                <key>MC7000.parameterButtonUp</key>
+                <key>MC7000.parameterButtonRight</key>
                 <description></description>
                 <status>0x95</status>
                 <midino>0x29</midino>
@@ -2044,7 +2055,7 @@
             </control>
             <control>
                 <group>[Channel2]</group>
-                <key>MC7000.parameterButtonDownShifted</key>
+                <key>MC7000.parameterButtonLeftShifted</key>
                 <description></description>
                 <status>0x95</status>
                 <midino>0x2A</midino>
@@ -2054,7 +2065,7 @@
             </control>
             <control>
                 <group>[Channel2]</group>
-                <key>MC7000.parameterButtonUpShifted</key>
+                <key>MC7000.parameterButtonRightShifted</key>
                 <description></description>
                 <status>0x95</status>
                 <midino>0x2B</midino>
@@ -2064,7 +2075,7 @@
             </control>
             <control>
                 <group>[Channel3]</group>
-                <key>MC7000.parameterButtonDown</key>
+                <key>MC7000.parameterButtonLeft</key>
                 <description></description>
                 <status>0x96</status>
                 <midino>0x28</midino>
@@ -2074,7 +2085,7 @@
             </control>
             <control>
                 <group>[Channel3]</group>
-                <key>MC7000.parameterButtonUp</key>
+                <key>MC7000.parameterButtonRight</key>
                 <description></description>
                 <status>0x96</status>
                 <midino>0x29</midino>
@@ -2084,7 +2095,7 @@
             </control>
             <control>
                 <group>[Channel3]</group>
-                <key>MC7000.parameterButtonDownShifted</key>
+                <key>MC7000.parameterButtonLeftShifted</key>
                 <description></description>
                 <status>0x96</status>
                 <midino>0x2A</midino>
@@ -2094,7 +2105,7 @@
             </control>
             <control>
                 <group>[Channel3]</group>
-                <key>MC7000.parameterButtonUpShifted</key>
+                <key>MC7000.parameterButtonRightShifted</key>
                 <description></description>
                 <status>0x96</status>
                 <midino>0x2B</midino>
@@ -2104,7 +2115,7 @@
             </control>
             <control>
                 <group>[Channel4]</group>
-                <key>MC7000.parameterButtonDown</key>
+                <key>MC7000.parameterButtonLeft</key>
                 <description></description>
                 <status>0x97</status>
                 <midino>0x28</midino>
@@ -2114,7 +2125,7 @@
             </control>
             <control>
                 <group>[Channel4]</group>
-                <key>MC7000.parameterButtonUp</key>
+                <key>MC7000.parameterButtonRight</key>
                 <description></description>
                 <status>0x97</status>
                 <midino>0x29</midino>
@@ -2124,7 +2135,7 @@
             </control>
             <control>
                 <group>[Channel4]</group>
-                <key>MC7000.parameterButtonDownShifted</key>
+                <key>MC7000.parameterButtonLeftShifted</key>
                 <description></description>
                 <status>0x97</status>
                 <midino>0x2A</midino>
@@ -2134,7 +2145,7 @@
             </control>
             <control>
                 <group>[Channel4]</group>
-                <key>MC7000.parameterButtonUpShifted</key>
+                <key>MC7000.parameterButtonRightShifted</key>
                 <description></description>
                 <status>0x97</status>
                 <midino>0x2B</midino>

From b3af50927be4780bccf9df2ae8d63cbc331fe429 Mon Sep 17 00:00:00 2001
From: fwcd <fwcd@fwcd.dev>
Date: Thu, 22 Aug 2024 02:55:31 +0200
Subject: [PATCH 05/36] Denon MC7000: Add intro/outro mode for parameter
 buttons

---
 res/controllers/Denon-MC7000-scripts.js | 7 +++++++
 res/controllers/Denon-MC7000.midi.xml   | 1 +
 2 files changed, 8 insertions(+)

diff --git a/res/controllers/Denon-MC7000-scripts.js b/res/controllers/Denon-MC7000-scripts.js
index 06be810474e..3f930033d2a 100644
--- a/res/controllers/Denon-MC7000-scripts.js
+++ b/res/controllers/Denon-MC7000-scripts.js
@@ -989,6 +989,13 @@ MC7000.parameterButton = function(value, group, {isLeftButton, isShiftPressed})
                 script.triggerControl(group, `beatjump_${isLeftButton ? "backward" : "forward"}`);
             }
             break;
+        case "introOutro":
+            {
+                const cue = isLeftButton ? "intro_end" : "outro_start";
+                const action = isShiftPressed ? "clear" : "activate";
+                script.triggerControl(group, `${cue}_${action}`);
+            }
+            break;
         default:
             break;
         }
diff --git a/res/controllers/Denon-MC7000.midi.xml b/res/controllers/Denon-MC7000.midi.xml
index 001c1fd876d..9d17646c2b2 100644
--- a/res/controllers/Denon-MC7000.midi.xml
+++ b/res/controllers/Denon-MC7000.midi.xml
@@ -72,6 +72,7 @@
                     label="Parameter Button Mode">
                     <value label="Change Star Rating (Shift: Track Color)">starsAndColor</value>
                     <value label="Perform Beat Jump (Shift: Adjust Jump Size)">beatjump</value>
+                    <value label="Set Intro/Outro (Shift: Clear Intro/Outro)">introOutro</value>
                 </option>
             </group>
         </group>

From a4ff156239643e18bda6b324a72d143c90314f4c Mon Sep 17 00:00:00 2001
From: fwcd <fwcd@fwcd.dev>
Date: Thu, 22 Aug 2024 02:57:41 +0200
Subject: [PATCH 06/36] Denon MC7000: Add description for parameter button mode
 setting

---
 res/controllers/Denon-MC7000.midi.xml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/res/controllers/Denon-MC7000.midi.xml b/res/controllers/Denon-MC7000.midi.xml
index 9d17646c2b2..c9aaccbde21 100644
--- a/res/controllers/Denon-MC7000.midi.xml
+++ b/res/controllers/Denon-MC7000.midi.xml
@@ -73,6 +73,10 @@
                     <value label="Change Star Rating (Shift: Track Color)">starsAndColor</value>
                     <value label="Perform Beat Jump (Shift: Adjust Jump Size)">beatjump</value>
                     <value label="Set Intro/Outro (Shift: Clear Intro/Outro)">introOutro</value>
+                    <description>
+                        Change the functionality of the orange parameter buttons
+                        in the bottom left/right corner of the controller.
+                    </description>
                 </option>
             </group>
         </group>

From 1a4f12308ed50005b10733440e4a38e19a9b3c00 Mon Sep 17 00:00:00 2001
From: fwcd <fwcd@fwcd.dev>
Date: Thu, 22 Aug 2024 02:58:40 +0200
Subject: [PATCH 07/36] Denon MC7000: Set starsAndColor as default param button
 mode

---
 res/controllers/Denon-MC7000.midi.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/res/controllers/Denon-MC7000.midi.xml b/res/controllers/Denon-MC7000.midi.xml
index c9aaccbde21..550f6e7f5ba 100644
--- a/res/controllers/Denon-MC7000.midi.xml
+++ b/res/controllers/Denon-MC7000.midi.xml
@@ -70,7 +70,7 @@
                     variable="parameterButtonMode"
                     type="enum"
                     label="Parameter Button Mode">
-                    <value label="Change Star Rating (Shift: Track Color)">starsAndColor</value>
+                    <value label="Change Star Rating (Shift: Track Color)" default="true">starsAndColor</value>
                     <value label="Perform Beat Jump (Shift: Adjust Jump Size)">beatjump</value>
                     <value label="Set Intro/Outro (Shift: Clear Intro/Outro)">introOutro</value>
                     <description>

From 9f9157451786310669c69da2630e4dbc450a6876 Mon Sep 17 00:00:00 2001
From: fwcd <fwcd@fwcd.dev>
Date: Thu, 22 Aug 2024 03:11:46 +0200
Subject: [PATCH 08/36] Denon MC7000: Make pitch play override of param buttons
 customizable

---
 res/controllers/Denon-MC7000-scripts.js | 12 +++++++++---
 res/controllers/Denon-MC7000.midi.xml   | 12 ++++++++++++
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/res/controllers/Denon-MC7000-scripts.js b/res/controllers/Denon-MC7000-scripts.js
index 3f930033d2a..979f7e84b01 100644
--- a/res/controllers/Denon-MC7000-scripts.js
+++ b/res/controllers/Denon-MC7000-scripts.js
@@ -110,9 +110,14 @@ MC7000.jogParams = {
     }
 };
 
-// Parameter button mode. See Denon-MC7000.midi.xml for documentation of the available modes.
+// Parameter button settings (the orange buttons at the bottom left/right of the controller).
 MC7000.parameterButtonSettings = {
+    // Parameter button mode. Available modes are `starsAndColor`, `beatjump` and `introOutro`.
     mode: engine.getSetting("parameterButtonMode") || "starsAndColor",
+    // Whether to use the parameter buttons to change the pitch range during
+    // pitch play mode. If this option is enabled, the pitch change
+    // functionality overrides the normal parameter button mode during pitch play.
+    parameterButtonPitchPlayOverrideEnabled: engine.getSetting("parameterButtonPitchPlayOverrideEnabled"),
 };
 
 /*/////////////////////////////////
@@ -963,14 +968,15 @@ MC7000.parameterButton = function(value, group, {isLeftButton, isShiftPressed})
 
     const deckNumber = script.deckFromGroup(group);
     const deckIndex = deckNumber - 1;
+    const settings = MC7000.parameterButtonSettings;
 
-    if (MC7000.PADMode[deckIndex] === "Pitch") {
+    if (settings.parameterButtonPitchPlayOverrideEnabled && MC7000.PADMode[deckIndex] === "Pitch") {
         const pitchDelta = isLeftButton ? -8 : 8;
         for (let padIdx = 0; padIdx < 8; padIdx++) {
             MC7000.halftoneToPadMap[deckIndex][padIdx] += pitchDelta;
         }
     } else {
-        switch (MC7000.parameterButtonSettings.mode) {
+        switch (settings.mode) {
         case "starsAndColor":
             if (isShiftPressed) {
                 script.triggerControl(group, `track_color_${isLeftButton ? "prev" : "next"}`);
diff --git a/res/controllers/Denon-MC7000.midi.xml b/res/controllers/Denon-MC7000.midi.xml
index 550f6e7f5ba..6ce7d82a6a7 100644
--- a/res/controllers/Denon-MC7000.midi.xml
+++ b/res/controllers/Denon-MC7000.midi.xml
@@ -78,6 +78,18 @@
                         in the bottom left/right corner of the controller.
                     </description>
                 </option>
+                <option
+                    variable="parameterButtonPitchPlayOverrideEnabled"
+                    label="Override parameter button mode during pitch play to set pitch range"
+                    type="boolean"
+                    default="true">
+                    <description>
+                        Whether to use the parameter buttons to change the pitch
+                        range during pitch play mode. If this option is enabled,
+                        the pitch change functionality overrides the normal
+                        parameter button mode during pitch play.
+                    </description>
+                </option>
             </group>
         </group>
     </settings>

From 590eddaf8828cdbc03c5405a87f8ca094546b5ee Mon Sep 17 00:00:00 2001
From: fwcd <fwcd@fwcd.dev>
Date: Thu, 22 Aug 2024 03:14:51 +0200
Subject: [PATCH 09/36] Denon MC7000: Use nullish-coalescing operator for param
 settings

---
 res/controllers/Denon-MC7000-scripts.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/res/controllers/Denon-MC7000-scripts.js b/res/controllers/Denon-MC7000-scripts.js
index 979f7e84b01..e2c38fc5601 100644
--- a/res/controllers/Denon-MC7000-scripts.js
+++ b/res/controllers/Denon-MC7000-scripts.js
@@ -113,11 +113,11 @@ MC7000.jogParams = {
 // Parameter button settings (the orange buttons at the bottom left/right of the controller).
 MC7000.parameterButtonSettings = {
     // Parameter button mode. Available modes are `starsAndColor`, `beatjump` and `introOutro`.
-    mode: engine.getSetting("parameterButtonMode") || "starsAndColor",
+    mode: engine.getSetting("parameterButtonMode") ?? "starsAndColor",
     // Whether to use the parameter buttons to change the pitch range during
     // pitch play mode. If this option is enabled, the pitch change
     // functionality overrides the normal parameter button mode during pitch play.
-    parameterButtonPitchPlayOverrideEnabled: engine.getSetting("parameterButtonPitchPlayOverrideEnabled"),
+    parameterButtonPitchPlayOverrideEnabled: engine.getSetting("parameterButtonPitchPlayOverrideEnabled") ?? true,
 };
 
 /*/////////////////////////////////

From 27baedd3712294dce76e1c989e5a11eaf25e3aec Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= <daschuer@mixxx.org>
Date: Sun, 1 Sep 2024 23:51:46 +0200
Subject: [PATCH 10/36] Skip copy if source is equal the destination the copy
 is unnecessary and __restrict__ assumption is violated.

---
 src/effects/backends/builtin/biquadfullkilleqeffect.cpp  | 2 +-
 src/effects/backends/builtin/distortioneffect.cpp        | 8 ++++++--
 src/effects/backends/builtin/loudnesscontoureffect.cpp   | 4 +++-
 src/effects/backends/builtin/metronomeeffect.cpp         | 4 +++-
 src/effects/backends/builtin/parametriceqeffect.cpp      | 4 +++-
 src/effects/backends/builtin/threebandbiquadeqeffect.cpp | 4 +++-
 6 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/src/effects/backends/builtin/biquadfullkilleqeffect.cpp b/src/effects/backends/builtin/biquadfullkilleqeffect.cpp
index fc3cfc67760..6501ce26d45 100644
--- a/src/effects/backends/builtin/biquadfullkilleqeffect.cpp
+++ b/src/effects/backends/builtin/biquadfullkilleqeffect.cpp
@@ -380,7 +380,7 @@ void BiquadFullKillEQEffect::processChannel(
         pState->m_highKill->pauseFilter();
     }
 
-    if (activeFilters == 0) {
+    if (activeFilters == 0 && pOutput != pInput) {
         SampleUtil::copy(pOutput, pInput, engineParameters.samplesPerBuffer());
     }
 
diff --git a/src/effects/backends/builtin/distortioneffect.cpp b/src/effects/backends/builtin/distortioneffect.cpp
index ff196bd4bd2..e17421b2762 100644
--- a/src/effects/backends/builtin/distortioneffect.cpp
+++ b/src/effects/backends/builtin/distortioneffect.cpp
@@ -105,7 +105,9 @@ void DistortionEffect::processChannel(
     CSAMPLE driveParam = static_cast<CSAMPLE>(m_pDrive->value());
 
     if (driveParam < 0.01) {
-        SampleUtil::copy(pOutput, pInput, numSamples);
+        if (pOutput != pInput) {
+            SampleUtil::copy(pOutput, pInput, numSamples);
+        }
         return;
     }
 
@@ -122,7 +124,9 @@ void DistortionEffect::processChannel(
 
     default:
         // We should never enter here, but we act as a noop effect just in case.
-        SampleUtil::copy(pOutput, pInput, numSamples);
+        if (pOutput != pInput) {
+            SampleUtil::copy(pOutput, pInput, numSamples);
+        }
         return;
     }
 }
diff --git a/src/effects/backends/builtin/loudnesscontoureffect.cpp b/src/effects/backends/builtin/loudnesscontoureffect.cpp
index b2f49f50303..ad75c6b6546 100644
--- a/src/effects/backends/builtin/loudnesscontoureffect.cpp
+++ b/src/effects/backends/builtin/loudnesscontoureffect.cpp
@@ -141,7 +141,9 @@ void LoudnessContourEffect::processChannel(
     if (filterGainDb == 0) {
         pState->m_low->pauseFilter();
         pState->m_high->pauseFilter();
-        SampleUtil::copy(pOutput, pInput, engineParameters.samplesPerBuffer());
+        if (pOutput != pInput) {
+            SampleUtil::copy(pOutput, pInput, engineParameters.samplesPerBuffer());
+        }
     } else {
         pState->m_low->process(pInput, pOutput, engineParameters.samplesPerBuffer());
         pState->m_high->process(pOutput, pState->m_pBuf, engineParameters.samplesPerBuffer());
diff --git a/src/effects/backends/builtin/metronomeeffect.cpp b/src/effects/backends/builtin/metronomeeffect.cpp
index e7b7638b9e7..9c68e6001e4 100644
--- a/src/effects/backends/builtin/metronomeeffect.cpp
+++ b/src/effects/backends/builtin/metronomeeffect.cpp
@@ -96,7 +96,9 @@ void MetronomeEffect::processChannel(
                 engineParameters.sampleRate() * 60 / m_pBpmParameter->value());
     }
 
-    SampleUtil::copy(pOutput, pInput, engineParameters.samplesPerBuffer());
+    if (pOutput != pInput) {
+        SampleUtil::copy(pOutput, pInput, engineParameters.samplesPerBuffer());
+    }
 
     if (gs->m_framesSinceClickStart < clickSize) {
         // still in click region, write remaining click frames.
diff --git a/src/effects/backends/builtin/parametriceqeffect.cpp b/src/effects/backends/builtin/parametriceqeffect.cpp
index a6cc1879238..f1b7c56029e 100644
--- a/src/effects/backends/builtin/parametriceqeffect.cpp
+++ b/src/effects/backends/builtin/parametriceqeffect.cpp
@@ -187,7 +187,9 @@ void ParametricEQEffect::processChannel(
             pState->m_bands[1]->process(pInput, pOutput, engineParameters.samplesPerBuffer());
         } else {
             pState->m_bands[1]->pauseFilter();
-            SampleUtil::copy(pOutput, pInput, engineParameters.samplesPerBuffer());
+            if (pOutput != pInput) {
+                SampleUtil::copy(pOutput, pInput, engineParameters.samplesPerBuffer());
+            }
         }
     }
 
diff --git a/src/effects/backends/builtin/threebandbiquadeqeffect.cpp b/src/effects/backends/builtin/threebandbiquadeqeffect.cpp
index bc1c5161522..af4b5ad5697 100644
--- a/src/effects/backends/builtin/threebandbiquadeqeffect.cpp
+++ b/src/effects/backends/builtin/threebandbiquadeqeffect.cpp
@@ -351,7 +351,9 @@ void ThreeBandBiquadEQEffect::processChannel(
     }
 
     if (activeFilters == 0) {
-        SampleUtil::copy(pOutput, pInput, engineParameters.samplesPerBuffer());
+        if (pOutput != pInput) {
+            SampleUtil::copy(pOutput, pInput, engineParameters.samplesPerBuffer());
+        }
     }
 
     if (enableState == EffectEnableState::Disabling) {

From 77cdbacd12b271fb35eb5a523ca5bb1385fd9b71 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= <daschuer@mixxx.org>
Date: Sun, 1 Sep 2024 23:37:06 +0200
Subject: [PATCH 11/36] Rename beat_fraction to beat_fraction_buffer_end to
 clarify that the value is related to the buffer end.

---
 src/effects/backends/builtin/metronomeeffect.cpp | 2 +-
 src/effects/backends/builtin/tremoloeffect.cpp   | 2 +-
 src/engine/controls/bpmcontrol.cpp               | 2 +-
 src/engine/effects/groupfeaturestate.h           | 9 +++++----
 src/engine/enginebuffer.cpp                      | 1 +
 5 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/effects/backends/builtin/metronomeeffect.cpp b/src/effects/backends/builtin/metronomeeffect.cpp
index 9c68e6001e4..6781f2cbf72 100644
--- a/src/effects/backends/builtin/metronomeeffect.cpp
+++ b/src/effects/backends/builtin/metronomeeffect.cpp
@@ -82,7 +82,7 @@ void MetronomeEffect::processChannel(
                 engineParameters.sampleRate() * groupFeatures.beat_length_sec);
         if (groupFeatures.has_beat_fraction) {
             const auto currentFrame = static_cast<SINT>(
-                    maxFrames * groupFeatures.beat_fraction);
+                    maxFrames * groupFeatures.beat_fraction_buffer_end);
             if (maxFrames > clickSize &&
                     currentFrame > clickSize &&
                     currentFrame < maxFrames - clickSize &&
diff --git a/src/effects/backends/builtin/tremoloeffect.cpp b/src/effects/backends/builtin/tremoloeffect.cpp
index 61ae0f641a1..4d84d2d7b34 100644
--- a/src/effects/backends/builtin/tremoloeffect.cpp
+++ b/src/effects/backends/builtin/tremoloeffect.cpp
@@ -139,7 +139,7 @@ void TremoloEffect::processChannel(
 
     if (enableState == EffectEnableState::Enabling || quantizeEnabling || tripletDisabling) {
         if (gf.has_beat_length_sec && gf.has_beat_fraction) {
-            currentFrame = static_cast<unsigned int>(gf.beat_fraction *
+            currentFrame = static_cast<unsigned int>(gf.beat_fraction_buffer_end *
                     gf.beat_length_sec * engineParameters.sampleRate());
         } else {
             currentFrame = 0;
diff --git a/src/engine/controls/bpmcontrol.cpp b/src/engine/controls/bpmcontrol.cpp
index d0aebad6867..c6c20c748f6 100644
--- a/src/engine/controls/bpmcontrol.cpp
+++ b/src/engine/controls/bpmcontrol.cpp
@@ -1115,7 +1115,7 @@ void BpmControl::collectFeatures(GroupFeatureState* pGroupFeatures) const {
         }
 
         pGroupFeatures->has_beat_fraction = true;
-        pGroupFeatures->beat_fraction = beatFraction;
+        pGroupFeatures->beat_fraction_buffer_end = beatFraction;
     }
 }
 
diff --git a/src/engine/effects/groupfeaturestate.h b/src/engine/effects/groupfeaturestate.h
index 4da54cd70f6..0c8cad81071 100644
--- a/src/engine/effects/groupfeaturestate.h
+++ b/src/engine/effects/groupfeaturestate.h
@@ -8,7 +8,7 @@ struct GroupFeatureState {
             : has_beat_length_sec(false),
               beat_length_sec(0.0),
               has_beat_fraction(false),
-              beat_fraction(0.0),
+              beat_fraction_buffer_end(0.0),
               has_gain(false),
               gain(1.0) {
     }
@@ -17,10 +17,11 @@ struct GroupFeatureState {
     bool has_beat_length_sec;
     double beat_length_sec;
 
-    // Fraction (0.0 to 1.0) of the current positions transition from the
-    // previous beat to the next beat.
+    // Beat fraction (0.0 to 1.0) of the position at the buffer end.
+    // Previous beat is in the current or earlier buffer. The next beat
+    // in the next or later buffer.
     bool has_beat_fraction;
-    double beat_fraction;
+    double beat_fraction_buffer_end;
 
     bool has_gain;
     double gain;
diff --git a/src/engine/enginebuffer.cpp b/src/engine/enginebuffer.cpp
index c7dce1c6056..b7b12c6f649 100644
--- a/src/engine/enginebuffer.cpp
+++ b/src/engine/enginebuffer.cpp
@@ -1107,6 +1107,7 @@ void EngineBuffer::processTrackLocked(
     }
 
     for (const auto& pControl : std::as_const(m_engineControls)) {
+        // m_playPos is already updated here and points to the end of the played buffer
         pControl->setFrameInfo(m_playPos, trackEndPosition, m_trackSampleRateOld);
         pControl->process(rate, m_playPos, iBufferSize);
     }

From 92ffa72363b5c892496be4f218fae22ee283e38b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= <daschuer@mixxx.org>
Date: Mon, 2 Sep 2024 23:36:42 +0200
Subject: [PATCH 12/36] Avoid unnecessary seconds round-trip in
 GroupFeatureState

---
 src/effects/backends/builtin/autopaneffect.cpp   |  4 ++--
 src/effects/backends/builtin/echoeffect.cpp      |  5 ++---
 src/effects/backends/builtin/flangereffect.cpp   |  5 ++---
 src/effects/backends/builtin/metronomeeffect.cpp |  5 ++---
 src/effects/backends/builtin/phasereffect.cpp    |  5 ++---
 src/effects/backends/builtin/tremoloeffect.cpp   |  9 ++++-----
 src/engine/controls/bpmcontrol.cpp               | 10 +++++-----
 src/engine/effects/groupfeaturestate.h           |  9 ++++-----
 8 files changed, 23 insertions(+), 29 deletions(-)

diff --git a/src/effects/backends/builtin/autopaneffect.cpp b/src/effects/backends/builtin/autopaneffect.cpp
index 7e9d9aa5543..8d0fccd46ad 100644
--- a/src/effects/backends/builtin/autopaneffect.cpp
+++ b/src/effects/backends/builtin/autopaneffect.cpp
@@ -88,10 +88,10 @@ void AutoPanEffect::processChannel(
     double period = m_pPeriodParameter->value();
     const auto smoothing = static_cast<float>(0.5 - m_pSmoothingParameter->value());
 
-    if (groupFeatures.has_beat_length_sec) {
+    if (groupFeatures.has_beat_length_frames) {
         // period is a number of beats
         double beats = std::max(roundToFraction(period, 2), 0.25);
-        period = beats * groupFeatures.beat_length_sec * engineParameters.sampleRate();
+        period = beats * groupFeatures.beat_length_frames;
 
         // TODO(xxx) sync phase
         //if (groupFeatures.has_beat_fraction) {
diff --git a/src/effects/backends/builtin/echoeffect.cpp b/src/effects/backends/builtin/echoeffect.cpp
index 4b132bcfb38..4bd1cb34cf9 100644
--- a/src/effects/backends/builtin/echoeffect.cpp
+++ b/src/effects/backends/builtin/echoeffect.cpp
@@ -132,7 +132,7 @@ void EchoEffect::processChannel(
     const auto pingpong_frac = static_cast<CSAMPLE_GAIN>(m_pPingPongParameter->value());
 
     int delay_frames;
-    if (groupFeatures.has_beat_length_sec) {
+    if (groupFeatures.has_beat_length_frames) {
         // period is a number of beats
         if (m_pQuantizeParameter->toBool()) {
             period = std::max(roundToFraction(period, 4), 1 / 8.0);
@@ -142,8 +142,7 @@ void EchoEffect::processChannel(
         } else if (period < 1 / 8.0) {
             period = 1 / 8.0;
         }
-        delay_frames = static_cast<int>(period * groupFeatures.beat_length_sec *
-                engineParameters.sampleRate());
+        delay_frames = static_cast<int>(period * groupFeatures.beat_length_frames);
     } else {
         // period is a number of seconds
         period = std::max(period, 1 / 8.0);
diff --git a/src/effects/backends/builtin/flangereffect.cpp b/src/effects/backends/builtin/flangereffect.cpp
index 542c5e8d706..5d1476d4a2d 100644
--- a/src/effects/backends/builtin/flangereffect.cpp
+++ b/src/effects/backends/builtin/flangereffect.cpp
@@ -117,14 +117,13 @@ void FlangerEffect::processChannel(
         const GroupFeatureState& groupFeatures) {
     double lfoPeriodParameter = m_pSpeedParameter->value();
     double lfoPeriodFrames;
-    if (groupFeatures.has_beat_length_sec) {
+    if (groupFeatures.has_beat_length_frames) {
         // lfoPeriodParameter is a number of beats
         lfoPeriodParameter = std::max(roundToFraction(lfoPeriodParameter, 2.0), kMinLfoBeats);
         if (m_pTripletParameter->toBool()) {
             lfoPeriodParameter /= 3.0;
         }
-        lfoPeriodFrames = lfoPeriodParameter * groupFeatures.beat_length_sec *
-                engineParameters.sampleRate();
+        lfoPeriodFrames = lfoPeriodParameter * groupFeatures.beat_length_frames;
     } else {
         // lfoPeriodParameter is a number of seconds
         lfoPeriodFrames = std::max(lfoPeriodParameter, kMinLfoBeats) *
diff --git a/src/effects/backends/builtin/metronomeeffect.cpp b/src/effects/backends/builtin/metronomeeffect.cpp
index 6781f2cbf72..15d3c6886b5 100644
--- a/src/effects/backends/builtin/metronomeeffect.cpp
+++ b/src/effects/backends/builtin/metronomeeffect.cpp
@@ -77,9 +77,8 @@ void MetronomeEffect::processChannel(
     }
 
     SINT maxFrames;
-    if (m_pSyncParameter->toBool() && groupFeatures.has_beat_length_sec) {
-        maxFrames = static_cast<SINT>(
-                engineParameters.sampleRate() * groupFeatures.beat_length_sec);
+    if (m_pSyncParameter->toBool() && groupFeatures.has_beat_length_frames) {
+        maxFrames = static_cast<SINT>(groupFeatures.beat_length_frames);
         if (groupFeatures.has_beat_fraction) {
             const auto currentFrame = static_cast<SINT>(
                     maxFrames * groupFeatures.beat_fraction_buffer_end);
diff --git a/src/effects/backends/builtin/phasereffect.cpp b/src/effects/backends/builtin/phasereffect.cpp
index dd92f19ceb4..c51688123da 100644
--- a/src/effects/backends/builtin/phasereffect.cpp
+++ b/src/effects/backends/builtin/phasereffect.cpp
@@ -132,14 +132,13 @@ void PhaserEffect::processChannel(
 
     double periodParameter = m_pLFOPeriodParameter->value();
     double periodSamples;
-    if (groupFeatures.has_beat_length_sec) {
+    if (groupFeatures.has_beat_length_frames) {
         // periodParameter is a number of beats
         periodParameter = std::max(roundToFraction(periodParameter, 2.0), 1 / 4.0);
         if (m_pTripletParameter->toBool()) {
             periodParameter /= 3.0;
         }
-        periodSamples = periodParameter * groupFeatures.beat_length_sec *
-                engineParameters.sampleRate();
+        periodSamples = periodParameter * groupFeatures.beat_length_frames;
     } else {
         // periodParameter is a number of seconds
         periodSamples = std::max(periodParameter, 1 / 4.0) * engineParameters.sampleRate();
diff --git a/src/effects/backends/builtin/tremoloeffect.cpp b/src/effects/backends/builtin/tremoloeffect.cpp
index 4d84d2d7b34..c7652b735cc 100644
--- a/src/effects/backends/builtin/tremoloeffect.cpp
+++ b/src/effects/backends/builtin/tremoloeffect.cpp
@@ -138,9 +138,9 @@ void TremoloEffect::processChannel(
     bool tripletDisabling = pState->tripletEnabled && !m_pTripletParameter->toBool();
 
     if (enableState == EffectEnableState::Enabling || quantizeEnabling || tripletDisabling) {
-        if (gf.has_beat_length_sec && gf.has_beat_fraction) {
+        if (gf.has_beat_length_frames && gf.has_beat_fraction) {
             currentFrame = static_cast<unsigned int>(gf.beat_fraction_buffer_end *
-                    gf.beat_length_sec * engineParameters.sampleRate());
+                    gf.beat_length_frames);
         } else {
             currentFrame = 0;
         }
@@ -149,7 +149,7 @@ void TremoloEffect::processChannel(
 
     int framePerPeriod;
     double rate = m_pRateParameter->value();
-    if (gf.has_beat_length_sec && gf.has_beat_fraction) {
+    if (gf.has_beat_length_frames && gf.has_beat_fraction) {
         if (m_pQuantizeParameter->toBool()) {
             const auto divider = static_cast<int>(log2(rate));
             rate = pow(2, divider);
@@ -158,8 +158,7 @@ void TremoloEffect::processChannel(
                 rate *= 3.0;
             }
         }
-        const auto framePerBeat = static_cast<int>(
-                gf.beat_length_sec * engineParameters.sampleRate());
+        const auto framePerBeat = static_cast<int>(gf.beat_length_frames);
         framePerPeriod = static_cast<int>(framePerBeat / rate);
     } else {
         framePerPeriod = static_cast<int>(engineParameters.sampleRate() / rate);
diff --git a/src/engine/controls/bpmcontrol.cpp b/src/engine/controls/bpmcontrol.cpp
index c6c20c748f6..2a6e33a9dd3 100644
--- a/src/engine/controls/bpmcontrol.cpp
+++ b/src/engine/controls/bpmcontrol.cpp
@@ -1106,12 +1106,12 @@ void BpmControl::collectFeatures(GroupFeatureState* pGroupFeatures) const {
                 nextBeatPosition,
                 &beatLengthFrames,
                 &beatFraction)) {
-        const double framesPerSecond = info.sampleRate * m_pRateRatio->get();
-        if (framesPerSecond != 0.0) {
-            pGroupFeatures->beat_length_sec = beatLengthFrames / framesPerSecond;
-            pGroupFeatures->has_beat_length_sec = true;
+        const double rateRatio = m_pRateRatio->get();
+        if (rateRatio != 0.0) {
+            pGroupFeatures->beat_length_frames = beatLengthFrames / rateRatio;
+            pGroupFeatures->has_beat_length_frames = true;
         } else {
-            pGroupFeatures->has_beat_length_sec = false;
+            pGroupFeatures->has_beat_length_frames = false;
         }
 
         pGroupFeatures->has_beat_fraction = true;
diff --git a/src/engine/effects/groupfeaturestate.h b/src/engine/effects/groupfeaturestate.h
index 0c8cad81071..cdb1299b577 100644
--- a/src/engine/effects/groupfeaturestate.h
+++ b/src/engine/effects/groupfeaturestate.h
@@ -5,17 +5,16 @@
 /// GroupFeatureState communicates metadata about EngineChannels to EffectProcessors.
 struct GroupFeatureState {
     GroupFeatureState()
-            : has_beat_length_sec(false),
-              beat_length_sec(0.0),
+            : has_beat_length_frames(false),
+              beat_length_frames(0.0),
               has_beat_fraction(false),
               beat_fraction_buffer_end(0.0),
               has_gain(false),
               gain(1.0) {
     }
 
-    // The beat length in seconds.
-    bool has_beat_length_sec;
-    double beat_length_sec;
+    bool has_beat_length_frames;
+    double beat_length_frames;
 
     // Beat fraction (0.0 to 1.0) of the position at the buffer end.
     // Previous beat is in the current or earlier buffer. The next beat

From 22b7c29c33e1fe067e3aa739870fcef7b649e6fd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= <daschuer@mixxx.org>
Date: Tue, 3 Sep 2024 07:39:47 +0200
Subject: [PATCH 13/36] Remove unused include

---
 src/engine/effects/groupfeaturestate.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/engine/effects/groupfeaturestate.h b/src/engine/effects/groupfeaturestate.h
index cdb1299b577..216ca6a587c 100644
--- a/src/engine/effects/groupfeaturestate.h
+++ b/src/engine/effects/groupfeaturestate.h
@@ -1,7 +1,5 @@
 #pragma once
 
-#include "proto/keys.pb.h"
-
 /// GroupFeatureState communicates metadata about EngineChannels to EffectProcessors.
 struct GroupFeatureState {
     GroupFeatureState()

From 808c09c5d8d7ae65eff53550fb23745a8a1d8063 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= <daschuer@mixxx.org>
Date: Tue, 3 Sep 2024 08:10:59 +0200
Subject: [PATCH 14/36] GroupFeatureState: std::optional

---
 .../backends/builtin/autopaneffect.cpp        |  4 ++--
 src/effects/backends/builtin/echoeffect.cpp   |  4 ++--
 .../backends/builtin/flangereffect.cpp        |  4 ++--
 .../builtin/loudnesscontoureffect.cpp         |  4 ++--
 .../backends/builtin/metronomeeffect.cpp      |  8 ++++----
 src/effects/backends/builtin/phasereffect.cpp |  4 ++--
 .../backends/builtin/tremoloeffect.cpp        | 10 +++++-----
 src/engine/controls/bpmcontrol.cpp            |  5 -----
 src/engine/effects/groupfeaturestate.h        | 19 ++++++-------------
 src/engine/enginemixer.cpp                    |  2 --
 src/engine/enginepregain.cpp                  |  1 -
 11 files changed, 25 insertions(+), 40 deletions(-)

diff --git a/src/effects/backends/builtin/autopaneffect.cpp b/src/effects/backends/builtin/autopaneffect.cpp
index 8d0fccd46ad..63a939fdfb4 100644
--- a/src/effects/backends/builtin/autopaneffect.cpp
+++ b/src/effects/backends/builtin/autopaneffect.cpp
@@ -88,10 +88,10 @@ void AutoPanEffect::processChannel(
     double period = m_pPeriodParameter->value();
     const auto smoothing = static_cast<float>(0.5 - m_pSmoothingParameter->value());
 
-    if (groupFeatures.has_beat_length_frames) {
+    if (groupFeatures.beat_length_frames.has_value()) {
         // period is a number of beats
         double beats = std::max(roundToFraction(period, 2), 0.25);
-        period = beats * groupFeatures.beat_length_frames;
+        period = beats * groupFeatures.beat_length_frames.value();
 
         // TODO(xxx) sync phase
         //if (groupFeatures.has_beat_fraction) {
diff --git a/src/effects/backends/builtin/echoeffect.cpp b/src/effects/backends/builtin/echoeffect.cpp
index 4bd1cb34cf9..4921c578589 100644
--- a/src/effects/backends/builtin/echoeffect.cpp
+++ b/src/effects/backends/builtin/echoeffect.cpp
@@ -132,7 +132,7 @@ void EchoEffect::processChannel(
     const auto pingpong_frac = static_cast<CSAMPLE_GAIN>(m_pPingPongParameter->value());
 
     int delay_frames;
-    if (groupFeatures.has_beat_length_frames) {
+    if (groupFeatures.beat_length_frames.has_value()) {
         // period is a number of beats
         if (m_pQuantizeParameter->toBool()) {
             period = std::max(roundToFraction(period, 4), 1 / 8.0);
@@ -142,7 +142,7 @@ void EchoEffect::processChannel(
         } else if (period < 1 / 8.0) {
             period = 1 / 8.0;
         }
-        delay_frames = static_cast<int>(period * groupFeatures.beat_length_frames);
+        delay_frames = static_cast<int>(period * groupFeatures.beat_length_frames.value());
     } else {
         // period is a number of seconds
         period = std::max(period, 1 / 8.0);
diff --git a/src/effects/backends/builtin/flangereffect.cpp b/src/effects/backends/builtin/flangereffect.cpp
index 5d1476d4a2d..d1fcaa83623 100644
--- a/src/effects/backends/builtin/flangereffect.cpp
+++ b/src/effects/backends/builtin/flangereffect.cpp
@@ -117,13 +117,13 @@ void FlangerEffect::processChannel(
         const GroupFeatureState& groupFeatures) {
     double lfoPeriodParameter = m_pSpeedParameter->value();
     double lfoPeriodFrames;
-    if (groupFeatures.has_beat_length_frames) {
+    if (groupFeatures.beat_length_frames.has_value()) {
         // lfoPeriodParameter is a number of beats
         lfoPeriodParameter = std::max(roundToFraction(lfoPeriodParameter, 2.0), kMinLfoBeats);
         if (m_pTripletParameter->toBool()) {
             lfoPeriodParameter /= 3.0;
         }
-        lfoPeriodFrames = lfoPeriodParameter * groupFeatures.beat_length_frames;
+        lfoPeriodFrames = lfoPeriodParameter * groupFeatures.beat_length_frames.value();
     } else {
         // lfoPeriodParameter is a number of seconds
         lfoPeriodFrames = std::max(lfoPeriodParameter, kMinLfoBeats) *
diff --git a/src/effects/backends/builtin/loudnesscontoureffect.cpp b/src/effects/backends/builtin/loudnesscontoureffect.cpp
index ad75c6b6546..36073576f01 100644
--- a/src/effects/backends/builtin/loudnesscontoureffect.cpp
+++ b/src/effects/backends/builtin/loudnesscontoureffect.cpp
@@ -109,9 +109,9 @@ void LoudnessContourEffect::processChannel(
     auto gain = static_cast<CSAMPLE_GAIN>(pState->m_oldGain);
 
     if (enableState != EffectEnableState::Disabling) {
-        bool useGain = m_pUseGain->toBool() && groupFeatures.has_gain;
+        bool useGain = m_pUseGain->toBool() && groupFeatures.gain.has_value();
         double loudness = m_pLoudness->value();
-        double gainKnob = groupFeatures.gain;
+        double gainKnob = groupFeatures.gain.value();
 
         filterGainDb = loudness;
 
diff --git a/src/effects/backends/builtin/metronomeeffect.cpp b/src/effects/backends/builtin/metronomeeffect.cpp
index 15d3c6886b5..8af5e6b9224 100644
--- a/src/effects/backends/builtin/metronomeeffect.cpp
+++ b/src/effects/backends/builtin/metronomeeffect.cpp
@@ -77,11 +77,11 @@ void MetronomeEffect::processChannel(
     }
 
     SINT maxFrames;
-    if (m_pSyncParameter->toBool() && groupFeatures.has_beat_length_frames) {
-        maxFrames = static_cast<SINT>(groupFeatures.beat_length_frames);
-        if (groupFeatures.has_beat_fraction) {
+    if (m_pSyncParameter->toBool() && groupFeatures.beat_length_frames.has_value()) {
+        maxFrames = static_cast<SINT>(groupFeatures.beat_length_frames.value());
+        if (groupFeatures.beat_fraction_buffer_end.has_value()) {
             const auto currentFrame = static_cast<SINT>(
-                    maxFrames * groupFeatures.beat_fraction_buffer_end);
+                    maxFrames * groupFeatures.beat_fraction_buffer_end.value());
             if (maxFrames > clickSize &&
                     currentFrame > clickSize &&
                     currentFrame < maxFrames - clickSize &&
diff --git a/src/effects/backends/builtin/phasereffect.cpp b/src/effects/backends/builtin/phasereffect.cpp
index c51688123da..26d683f7fc8 100644
--- a/src/effects/backends/builtin/phasereffect.cpp
+++ b/src/effects/backends/builtin/phasereffect.cpp
@@ -132,13 +132,13 @@ void PhaserEffect::processChannel(
 
     double periodParameter = m_pLFOPeriodParameter->value();
     double periodSamples;
-    if (groupFeatures.has_beat_length_frames) {
+    if (groupFeatures.beat_length_frames.has_value()) {
         // periodParameter is a number of beats
         periodParameter = std::max(roundToFraction(periodParameter, 2.0), 1 / 4.0);
         if (m_pTripletParameter->toBool()) {
             periodParameter /= 3.0;
         }
-        periodSamples = periodParameter * groupFeatures.beat_length_frames;
+        periodSamples = periodParameter * groupFeatures.beat_length_frames.value();
     } else {
         // periodParameter is a number of seconds
         periodSamples = std::max(periodParameter, 1 / 4.0) * engineParameters.sampleRate();
diff --git a/src/effects/backends/builtin/tremoloeffect.cpp b/src/effects/backends/builtin/tremoloeffect.cpp
index c7652b735cc..3a40acafd66 100644
--- a/src/effects/backends/builtin/tremoloeffect.cpp
+++ b/src/effects/backends/builtin/tremoloeffect.cpp
@@ -138,9 +138,9 @@ void TremoloEffect::processChannel(
     bool tripletDisabling = pState->tripletEnabled && !m_pTripletParameter->toBool();
 
     if (enableState == EffectEnableState::Enabling || quantizeEnabling || tripletDisabling) {
-        if (gf.has_beat_length_frames && gf.has_beat_fraction) {
-            currentFrame = static_cast<unsigned int>(gf.beat_fraction_buffer_end *
-                    gf.beat_length_frames);
+        if (gf.beat_length_frames.has_value() && gf.beat_fraction_buffer_end.has_value()) {
+            currentFrame = static_cast<unsigned int>(gf.beat_fraction_buffer_end.value() *
+                    gf.beat_length_frames.value());
         } else {
             currentFrame = 0;
         }
@@ -149,7 +149,7 @@ void TremoloEffect::processChannel(
 
     int framePerPeriod;
     double rate = m_pRateParameter->value();
-    if (gf.has_beat_length_frames && gf.has_beat_fraction) {
+    if (gf.beat_length_frames.has_value() && gf.beat_fraction_buffer_end.has_value()) {
         if (m_pQuantizeParameter->toBool()) {
             const auto divider = static_cast<int>(log2(rate));
             rate = pow(2, divider);
@@ -158,7 +158,7 @@ void TremoloEffect::processChannel(
                 rate *= 3.0;
             }
         }
-        const auto framePerBeat = static_cast<int>(gf.beat_length_frames);
+        const auto framePerBeat = static_cast<int>(gf.beat_length_frames.value());
         framePerPeriod = static_cast<int>(framePerBeat / rate);
     } else {
         framePerPeriod = static_cast<int>(engineParameters.sampleRate() / rate);
diff --git a/src/engine/controls/bpmcontrol.cpp b/src/engine/controls/bpmcontrol.cpp
index 2a6e33a9dd3..767db0d98b3 100644
--- a/src/engine/controls/bpmcontrol.cpp
+++ b/src/engine/controls/bpmcontrol.cpp
@@ -1109,12 +1109,7 @@ void BpmControl::collectFeatures(GroupFeatureState* pGroupFeatures) const {
         const double rateRatio = m_pRateRatio->get();
         if (rateRatio != 0.0) {
             pGroupFeatures->beat_length_frames = beatLengthFrames / rateRatio;
-            pGroupFeatures->has_beat_length_frames = true;
-        } else {
-            pGroupFeatures->has_beat_length_frames = false;
         }
-
-        pGroupFeatures->has_beat_fraction = true;
         pGroupFeatures->beat_fraction_buffer_end = beatFraction;
     }
 }
diff --git a/src/engine/effects/groupfeaturestate.h b/src/engine/effects/groupfeaturestate.h
index 216ca6a587c..55542c598ba 100644
--- a/src/engine/effects/groupfeaturestate.h
+++ b/src/engine/effects/groupfeaturestate.h
@@ -1,25 +1,18 @@
 #pragma once
 
+#include <optional>
+
 /// GroupFeatureState communicates metadata about EngineChannels to EffectProcessors.
 struct GroupFeatureState {
-    GroupFeatureState()
-            : has_beat_length_frames(false),
-              beat_length_frames(0.0),
-              has_beat_fraction(false),
-              beat_fraction_buffer_end(0.0),
-              has_gain(false),
-              gain(1.0) {
+    GroupFeatureState() {
     }
 
-    bool has_beat_length_frames;
-    double beat_length_frames;
+    std::optional<double> beat_length_frames;
 
     // Beat fraction (0.0 to 1.0) of the position at the buffer end.
     // Previous beat is in the current or earlier buffer. The next beat
     // in the next or later buffer.
-    bool has_beat_fraction;
-    double beat_fraction_buffer_end;
+    std::optional<double> beat_fraction_buffer_end;
 
-    bool has_gain;
-    double gain;
+    std::optional<double> gain;
 };
diff --git a/src/engine/enginemixer.cpp b/src/engine/enginemixer.cpp
index c7eda1a7d97..ac78fff3fe8 100644
--- a/src/engine/enginemixer.cpp
+++ b/src/engine/enginemixer.cpp
@@ -768,7 +768,6 @@ void EngineMixer::process(const int iBufferSize) {
         // record/broadcast signal
         if (m_pEngineEffectsManager) {
             GroupFeatureState mainFeatures;
-            mainFeatures.has_gain = true;
             mainFeatures.gain = m_pMainGain->get();
             m_pEngineEffectsManager->processPostFaderInPlace(
                     m_mainOutputHandle.handle(),
@@ -832,7 +831,6 @@ void EngineMixer::applyMainEffects(int bufferSize) {
     // Apply main effects
     if (m_pEngineEffectsManager) {
         GroupFeatureState mainFeatures;
-        mainFeatures.has_gain = true;
         mainFeatures.gain = m_pMainGain->get();
         m_pEngineEffectsManager->processPostFaderInPlace(m_mainHandle.handle(),
                 m_mainHandle.handle(),
diff --git a/src/engine/enginepregain.cpp b/src/engine/enginepregain.cpp
index 02c75fee683..72d4809064d 100644
--- a/src/engine/enginepregain.cpp
+++ b/src/engine/enginepregain.cpp
@@ -164,5 +164,4 @@ void EnginePregain::process(CSAMPLE* pInOut, const int iBufferSize) {
 
 void EnginePregain::collectFeatures(GroupFeatureState* pGroupFeatures) const {
     pGroupFeatures->gain = m_pPotmeterPregain->get();
-    pGroupFeatures->has_gain = true;
 }

From c0cbd6ad8b284c0ac7e421aa10dfe1db326ed8a4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= <daschuer@mixxx.org>
Date: Tue, 3 Sep 2024 21:38:41 +0200
Subject: [PATCH 15/36] Add scratch_rate to GroupFeatureState to allow to
 quantize effects during scratching

---
 src/engine/controls/bpmcontrol.cpp     | 3 ++-
 src/engine/controls/bpmcontrol.h       | 2 +-
 src/engine/effects/groupfeaturestate.h | 5 +++++
 src/engine/enginebuffer.cpp            | 2 +-
 4 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/engine/controls/bpmcontrol.cpp b/src/engine/controls/bpmcontrol.cpp
index 767db0d98b3..b5a73904b2f 100644
--- a/src/engine/controls/bpmcontrol.cpp
+++ b/src/engine/controls/bpmcontrol.cpp
@@ -1085,7 +1085,7 @@ void BpmControl::resetSyncAdjustment() {
     m_resetSyncAdjustment = true;
 }
 
-void BpmControl::collectFeatures(GroupFeatureState* pGroupFeatures) const {
+void BpmControl::collectFeatures(GroupFeatureState* pGroupFeatures, double speed) const {
     // Without a beatgrid we don't know any beat details.
     FrameInfo info = frameInfo();
     if (!info.sampleRate.isValid() || !m_pBeats) {
@@ -1109,6 +1109,7 @@ void BpmControl::collectFeatures(GroupFeatureState* pGroupFeatures) const {
         const double rateRatio = m_pRateRatio->get();
         if (rateRatio != 0.0) {
             pGroupFeatures->beat_length_frames = beatLengthFrames / rateRatio;
+            pGroupFeatures->scratch_rate = speed / rateRatio;
         }
         pGroupFeatures->beat_fraction_buffer_end = beatFraction;
     }
diff --git a/src/engine/controls/bpmcontrol.h b/src/engine/controls/bpmcontrol.h
index 7f6d5384c6b..5f385d748a9 100644
--- a/src/engine/controls/bpmcontrol.h
+++ b/src/engine/controls/bpmcontrol.h
@@ -64,7 +64,7 @@ class BpmControl : public EngineControl {
     /// override is used for seeks.
     double updateBeatDistance(mixxx::audio::FramePos playpos);
 
-    void collectFeatures(GroupFeatureState* pGroupFeatures) const;
+    void collectFeatures(GroupFeatureState* pGroupFeatures, double speed) const;
 
     // Calculates contextual information about beats: the previous beat, the
     // next beat, the current beat length, and the beat ratio (how far dPosition
diff --git a/src/engine/effects/groupfeaturestate.h b/src/engine/effects/groupfeaturestate.h
index 55542c598ba..b5d8b61e0ba 100644
--- a/src/engine/effects/groupfeaturestate.h
+++ b/src/engine/effects/groupfeaturestate.h
@@ -7,8 +7,13 @@ struct GroupFeatureState {
     GroupFeatureState() {
     }
 
+    // Adjusted by the rate slider
     std::optional<double> beat_length_frames;
 
+    // Rate change by temporary actions like scratching
+    // and not the rate slider.
+    std::optional<double> scratch_rate;
+
     // Beat fraction (0.0 to 1.0) of the position at the buffer end.
     // Previous beat is in the current or earlier buffer. The next beat
     // in the next or later buffer.
diff --git a/src/engine/enginebuffer.cpp b/src/engine/enginebuffer.cpp
index b7b12c6f649..0a2a45e2a97 100644
--- a/src/engine/enginebuffer.cpp
+++ b/src/engine/enginebuffer.cpp
@@ -1571,7 +1571,7 @@ double EngineBuffer::getRateRatio() const {
 
 void EngineBuffer::collectFeatures(GroupFeatureState* pGroupFeatures) const {
     if (m_pBpmControl != nullptr) {
-        m_pBpmControl->collectFeatures(pGroupFeatures);
+        m_pBpmControl->collectFeatures(pGroupFeatures, m_speed_old);
     }
 }
 

From 0648e0585f39a0867fd6789664853d13e04f120a Mon Sep 17 00:00:00 2001
From: ronso0 <ronso0@mixxx.org>
Date: Wed, 4 Sep 2024 11:57:08 +0200
Subject: [PATCH 16/36] Controller: unify/clean up logging, fix code style

---
 src/controllers/controller.cpp                | 22 +++++++++----------
 ...legacymidicontrollermappingfilehandler.cpp |  9 ++++++--
 2 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/src/controllers/controller.cpp b/src/controllers/controller.cpp
index c9cb45c7e5e..4b9ec5c7d29 100644
--- a/src/controllers/controller.cpp
+++ b/src/controllers/controller.cpp
@@ -36,20 +36,19 @@ ControllerJSProxy* Controller::jsProxy() {
     return new ControllerJSProxy(this);
 }
 
-void Controller::startEngine()
-{
-    qCInfo(m_logBase) << "  Starting engine";
+void Controller::startEngine() {
+    qCInfo(m_logBase) << "Starting engine";
     if (m_pScriptEngineLegacy) {
-        qCWarning(m_logBase) << "Controller: Engine already exists! Restarting:";
+        qCWarning(m_logBase) << "startEngine(): Engine already exists! Restarting:";
         stopEngine();
     }
     m_pScriptEngineLegacy = new ControllerScriptEngineLegacy(this, m_logBase);
 }
 
 void Controller::stopEngine() {
-    qCInfo(m_logBase) << "  Shutting down engine";
+    qCInfo(m_logBase) << "Shutting down engine";
     if (!m_pScriptEngineLegacy) {
-        qCWarning(m_logBase) << "Controller::stopEngine(): No engine exists!";
+        qCWarning(m_logBase) << "No engine exists!";
         return;
     }
     delete m_pScriptEngineLegacy;
@@ -59,14 +58,13 @@ void Controller::stopEngine() {
 bool Controller::applyMapping() {
     qCInfo(m_logBase) << "Applying controller mapping...";
 
-    const std::shared_ptr<LegacyControllerMapping> pMapping = cloneMapping();
-
     // Load the script code into the engine
     if (!m_pScriptEngineLegacy) {
-        qCWarning(m_logBase) << "Controller::applyMapping(): No engine exists!";
+        qCWarning(m_logBase) << "No engine exists!";
         return false;
     }
 
+    const std::shared_ptr<LegacyControllerMapping> pMapping = cloneMapping();
     QList<LegacyControllerMapping::ScriptFileInfo> scriptFiles = pMapping->getScriptFiles();
     if (scriptFiles.isEmpty()) {
         qCWarning(m_logBase)
@@ -104,14 +102,14 @@ void Controller::send(const QList<int>& data, unsigned int length) {
     sendBytes(msg);
 }
 
-void Controller::triggerActivity()
-{
-     // Inhibit Updates for 1000 milliseconds
+void Controller::triggerActivity() {
+    // Inhibit Updates for 1000 milliseconds
     if (m_userActivityInhibitTimer.elapsed() > 1000) {
         mixxx::ScreenSaverHelper::triggerUserActivity();
         m_userActivityInhibitTimer.start();
     }
 }
+
 void Controller::receive(const QByteArray& data, mixxx::Duration timestamp) {
     if (!m_pScriptEngineLegacy) {
         //qWarning() << "Controller::receive called with no active engine!";
diff --git a/src/controllers/midi/legacymidicontrollermappingfilehandler.cpp b/src/controllers/midi/legacymidicontrollermappingfilehandler.cpp
index e0fcea473cf..8843bc0ece3 100644
--- a/src/controllers/midi/legacymidicontrollermappingfilehandler.cpp
+++ b/src/controllers/midi/legacymidicontrollermappingfilehandler.cpp
@@ -1,12 +1,17 @@
 #include "controllers/midi/legacymidicontrollermappingfilehandler.h"
 
 #include "controllers/midi/midiutils.h"
+#include "util/logger.h"
 
 #define DEFAULT_OUTPUT_MAX 1.0
 #define DEFAULT_OUTPUT_MIN 0.0 // Anything above 0 is "on"
 #define DEFAULT_OUTPUT_ON 0x7F
 #define DEFAULT_OUTPUT_OFF 0x00
 
+namespace {
+const mixxx::Logger kLogger("LegacyMidiControllerMappingFileHandler");
+} // namespace
+
 std::shared_ptr<LegacyControllerMapping>
 LegacyMidiControllerMappingFileHandler::load(const QDomElement& root,
         const QString& filePath,
@@ -119,7 +124,7 @@ LegacyMidiControllerMappingFileHandler::load(const QDomElement& root,
         control = control.nextSiblingElement("control");
     }
 
-    qDebug() << "LegacyMidiControllerMappingFileHandler: Input mapping parsing complete.";
+    kLogger.debug() << "Input mapping parsing complete.";
 
     // Parse static output mappings
 
@@ -211,7 +216,7 @@ LegacyMidiControllerMappingFileHandler::load(const QDomElement& root,
         output = output.nextSiblingElement("output");
     }
 
-    qDebug() << "MidiMappingFileHandler: Output mapping parsing complete.";
+    kLogger.debug() << "Output mapping parsing complete.";
 
     return pMapping;
 }

From 67a4880d3cfb8ebc675746fa2c8b276c56135e63 Mon Sep 17 00:00:00 2001
From: ronso0 <ronso0@mixxx.org>
Date: Wed, 4 Sep 2024 13:03:43 +0200
Subject: [PATCH 17/36] Controller mapping error message: increase readability
 with more line breaks

---
 src/controllers/scripting/controllerscriptenginebase.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/controllers/scripting/controllerscriptenginebase.cpp b/src/controllers/scripting/controllerscriptenginebase.cpp
index c8576657997..16292b6ab39 100644
--- a/src/controllers/scripting/controllerscriptenginebase.cpp
+++ b/src/controllers/scripting/controllerscriptenginebase.cpp
@@ -109,7 +109,7 @@ void ControllerScriptEngineBase::showScriptExceptionDialog(
     if (filename.isEmpty()) {
         filename = QStringLiteral("<passed code>");
     }
-    QString errorText = QString("Uncaught exception: %1:%2: %3").arg(filename, line, errorMessage);
+    QString errorText = QString("Uncaught exception: %1:%2:\n%3").arg(filename, line, errorMessage);
 
     // Do not include backtrace in dialog key because it might contain midi
     // slider values that will differ most of the time. This would break
@@ -117,7 +117,7 @@ void ControllerScriptEngineBase::showScriptExceptionDialog(
     QString key = errorText;
 
     // Add backtrace to the error details
-    errorText += QStringLiteral("\nBacktrace: ") + backtrace;
+    errorText += QStringLiteral("\n\nBacktrace: ") + backtrace;
     qCWarning(m_logger) << "ControllerScriptHandlerBase:" << errorText;
 
     if (!m_bDisplayingExceptionDialog) {

From 79c5708d23e4dfa15f12b5de94488f9f4d55fb94 Mon Sep 17 00:00:00 2001
From: ronso0 <ronso0@mixxx.org>
Date: Wed, 4 Sep 2024 13:05:47 +0200
Subject: [PATCH 18/36] Error dialog: expand Details box for controller mapping
 errors

---
 src/controllers/midi/midicontroller.cpp                      | 3 ++-
 .../scripting/legacy/controllerscriptenginelegacy.cpp        | 5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/controllers/midi/midicontroller.cpp b/src/controllers/midi/midicontroller.cpp
index fbc30089387..4ba99d1d4b8 100644
--- a/src/controllers/midi/midicontroller.cpp
+++ b/src/controllers/midi/midicontroller.cpp
@@ -151,7 +151,8 @@ void MidiController::createOutputHandlers() {
                 " Visit the manual for a complete list: ");
         detailsText += MIXXX_MANUAL_CONTROLS_URL + QStringLiteral("\n\n");
         detailsText += failures.join("\n");
-        props->setDetails(detailsText);
+        props->setDetails(detailsText,
+                true /* use monospace font / expand Details box */);
         ErrorDialogHandler::instance()->requestErrorDialog(props);
     }
 }
diff --git a/src/controllers/scripting/legacy/controllerscriptenginelegacy.cpp b/src/controllers/scripting/legacy/controllerscriptenginelegacy.cpp
index 78e48d13aa1..bdfd52e3914 100644
--- a/src/controllers/scripting/legacy/controllerscriptenginelegacy.cpp
+++ b/src/controllers/scripting/legacy/controllerscriptenginelegacy.cpp
@@ -245,8 +245,9 @@ bool ControllerScriptEngineLegacy::evaluateScriptFile(const QFileInfo& scriptFil
         // issue). Translating this will help users to fix the issue even
         // when they don't speak english.
         props->setDetails(tr("File:") + QStringLiteral(" ") + filename +
-                QStringLiteral("\n") + tr("Error:") + QStringLiteral(" ") +
-                input.errorString());
+                        QStringLiteral("\n") + tr("Error:") + QStringLiteral(" ") +
+                        input.errorString(),
+                true /* use monospace font / expand Details box */);
 
         // Ask above layer to display the dialog & handle user response
         ErrorDialogHandler::instance()->requestErrorDialog(props);

From 8454cceaf673e016559b0292b874452191d007de Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= <daschuer@mixxx.org>
Date: Tue, 3 Sep 2024 23:04:07 +0200
Subject: [PATCH 19/36] Fix quantization with the metronome effect. It was one
 buffer off.

---
 .../backends/builtin/metronomeeffect.cpp      | 81 ++++++++++---------
 1 file changed, 44 insertions(+), 37 deletions(-)

diff --git a/src/effects/backends/builtin/metronomeeffect.cpp b/src/effects/backends/builtin/metronomeeffect.cpp
index 8af5e6b9224..61bcfbab42b 100644
--- a/src/effects/backends/builtin/metronomeeffect.cpp
+++ b/src/effects/backends/builtin/metronomeeffect.cpp
@@ -59,13 +59,13 @@ void MetronomeEffect::processChannel(
         const GroupFeatureState& groupFeatures) {
     Q_UNUSED(pInput);
 
-    MetronomeGroupState* gs = pGroupState;
-
     if (enableState == EffectEnableState::Disabled) {
-        gs->m_framesSinceClickStart = 0;
+        // assume click is fully played
         return;
     }
 
+    MetronomeGroupState* gs = pGroupState;
+
     SINT clickSize = kClickSize44100;
     const CSAMPLE* click = kClick44100;
     if (engineParameters.sampleRate() >= 96000) {
@@ -76,53 +76,60 @@ void MetronomeEffect::processChannel(
         click = kClick48000;
     }
 
-    SINT maxFrames;
-    if (m_pSyncParameter->toBool() && groupFeatures.beat_length_frames.has_value()) {
-        maxFrames = static_cast<SINT>(groupFeatures.beat_length_frames.value());
-        if (groupFeatures.beat_fraction_buffer_end.has_value()) {
-            const auto currentFrame = static_cast<SINT>(
-                    maxFrames * groupFeatures.beat_fraction_buffer_end.value());
-            if (maxFrames > clickSize &&
-                    currentFrame > clickSize &&
-                    currentFrame < maxFrames - clickSize &&
-                    gs->m_framesSinceClickStart > clickSize) {
-                // plays a single click on low speed
-                gs->m_framesSinceClickStart = currentFrame;
-            }
-        }
-    } else {
-        maxFrames = static_cast<SINT>(
-                engineParameters.sampleRate() * 60 / m_pBpmParameter->value());
-    }
-
     if (pOutput != pInput) {
         SampleUtil::copy(pOutput, pInput, engineParameters.samplesPerBuffer());
     }
 
+    if (enableState == EffectEnableState::Enabling) {
+        if (m_pSyncParameter->toBool() && groupFeatures.beat_fraction_buffer_end.has_value()) {
+            // Skip first click and sync phase
+            gs->m_framesSinceClickStart = clickSize;
+        } else {
+            // click right away after enabling
+            gs->m_framesSinceClickStart = 0;
+        }
+    }
+
     if (gs->m_framesSinceClickStart < clickSize) {
-        // still in click region, write remaining click frames.
+        // In click region, write remaining click frames.
         const SINT copyFrames =
                 math_min(engineParameters.framesPerBuffer(),
                         clickSize - gs->m_framesSinceClickStart);
         SampleUtil::addMonoToStereo(pOutput, &click[gs->m_framesSinceClickStart], copyFrames);
     }
 
-    gs->m_framesSinceClickStart += engineParameters.framesPerBuffer();
+    double bufferEnd = gs->m_framesSinceClickStart + engineParameters.framesPerBuffer();
 
-    if (gs->m_framesSinceClickStart > maxFrames) {
-        // overflow, all overflowed frames are the start of a new click sound
-        gs->m_framesSinceClickStart -= maxFrames;
-        while (gs->m_framesSinceClickStart > engineParameters.framesPerBuffer()) {
-            // loop into a valid region, this happens if the maxFrames was lowered
-            gs->m_framesSinceClickStart -= engineParameters.framesPerBuffer();
+    double nextClickStart = bufferEnd; // default to "no new click";
+    if (m_pSyncParameter->toBool() && groupFeatures.beat_length_frames.has_value()) {
+        if (groupFeatures.beat_fraction_buffer_end.has_value()) {
+            double beatToBufferEnd =
+                    groupFeatures.beat_length_frames.value() *
+                    groupFeatures.beat_fraction_buffer_end.value();
+            if (bufferEnd > beatToBufferEnd) {
+                // We have a new beat before the current buffer ends
+                nextClickStart = bufferEnd - beatToBufferEnd;
+            }
+        } else {
+            nextClickStart = groupFeatures.beat_length_frames.value();
         }
+    } else {
+        nextClickStart = engineParameters.sampleRate() * 60 / m_pBpmParameter->value();
+    }
 
-        // gs->m_framesSinceClickStart matches now already at the first frame
-        // of next pOutput.
-        const unsigned int outputOffset =
-                engineParameters.framesPerBuffer() - gs->m_framesSinceClickStart;
-        const unsigned int copyFrames =
-                math_min(gs->m_framesSinceClickStart, clickSize);
-        SampleUtil::addMonoToStereo(&pOutput[outputOffset * 2], click, copyFrames);
+    if (bufferEnd > nextClickStart) {
+        // We need to start a new click
+        SINT outputOffset = static_cast<SINT>(nextClickStart) - gs->m_framesSinceClickStart;
+        if (outputOffset > 0) {
+            if (outputOffset < engineParameters.framesPerBuffer()) {
+                const SINT copyFrames =
+                        math_min(engineParameters.framesPerBuffer() - outputOffset, clickSize);
+                SampleUtil::addMonoToStereo(&pOutput[outputOffset * 2], &click[0], copyFrames);
+                gs->m_framesSinceClickStart = -outputOffset;
+            }
+        }
+    }
+    if (gs->m_framesSinceClickStart < engineParameters.framesPerBuffer() + clickSize) {
+        gs->m_framesSinceClickStart += engineParameters.framesPerBuffer();
     }
 }

From 7f28e0841bcf55cf60da72e6e97ea810c0967b82 Mon Sep 17 00:00:00 2001
From: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com>
Date: Fri, 6 Sep 2024 15:31:02 +0200
Subject: [PATCH 20/36] feat: document ScriptConnection properties in
 engine-api.d.ts

---
 res/controllers/engine-api.d.ts | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/res/controllers/engine-api.d.ts b/res/controllers/engine-api.d.ts
index 4a2b935cd29..2474676d179 100644
--- a/res/controllers/engine-api.d.ts
+++ b/res/controllers/engine-api.d.ts
@@ -18,6 +18,17 @@ declare interface ScriptConnection {
      * Note: To execute all callback functions connected to a ControlObject at once, use {@link engine.trigger} instead
      */
     trigger(): void;
+
+    /**
+     * String representation of the unique UUID of this connection instance
+     */
+    readonly id: string;
+
+    /**
+     * whether the connection instance is actually responds to changes to the ControlObject it was created for.
+     * This is always true for a newly created instance and usually false after calling {@link disconnect}
+     */
+    readonly isConnected: boolean;
 }
 
 

From 75b294449afb2159f59dbeb306bca0814167851f Mon Sep 17 00:00:00 2001
From: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com>
Date: Fri, 6 Sep 2024 15:40:13 +0200
Subject: [PATCH 21/36] refactor: cleanup ScriptConnectionJSProxy

* use initializer lists
* remove unneeded QString member, saving 24 bytes in this frequently
  instanced class
* pass by Value+Move instead of unconditional copy in ctor
---
 .../scripting/legacy/scriptconnectionjsproxy.h      | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/controllers/scripting/legacy/scriptconnectionjsproxy.h b/src/controllers/scripting/legacy/scriptconnectionjsproxy.h
index 2b80b5e4c08..4d59f39e83d 100644
--- a/src/controllers/scripting/legacy/scriptconnectionjsproxy.h
+++ b/src/controllers/scripting/legacy/scriptconnectionjsproxy.h
@@ -1,6 +1,7 @@
 #pragma once
 
 #include <QObject>
+#include <utility>
 
 #include "controllers/scripting/legacy/scriptconnection.h"
 
@@ -10,13 +11,12 @@ class ScriptConnectionJSProxy : public QObject {
     Q_PROPERTY(QString id READ readId)
     Q_PROPERTY(bool isConnected READ readIsConnected)
   public:
-    ScriptConnectionJSProxy(const ScriptConnection& conn) {
-        m_scriptConnection = conn;
-        m_idString = conn.id.toString();
-        m_isConnected = true;
+    ScriptConnectionJSProxy(ScriptConnection conn)
+            : m_scriptConnection(std::move(conn)),
+              m_isConnected(true) {
     }
-    const QString& readId() const {
-        return m_idString;
+    QString readId() const {
+        return m_scriptConnection.id.toString();
     }
     bool readIsConnected() const {
         return m_isConnected;
@@ -26,6 +26,5 @@ class ScriptConnectionJSProxy : public QObject {
 
   private:
     ScriptConnection m_scriptConnection;
-    QString m_idString;
     bool m_isConnected;
 };

From 875a6a3270989f8d289aae19217c34495c4e7b00 Mon Sep 17 00:00:00 2001
From: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com>
Date: Fri, 6 Sep 2024 15:45:07 +0200
Subject: [PATCH 22/36] refactor: construct ScriptConnectionJSProxy more
 efficiently

and construct connectControl warning message more efficiently
---
 .../controllerscriptinterfacelegacy.cpp       | 22 +++++++++----------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/src/controllers/scripting/legacy/controllerscriptinterfacelegacy.cpp b/src/controllers/scripting/legacy/controllerscriptinterfacelegacy.cpp
index 4374fdd8588..3225e8dea2b 100644
--- a/src/controllers/scripting/legacy/controllerscriptinterfacelegacy.cpp
+++ b/src/controllers/scripting/legacy/controllerscriptinterfacelegacy.cpp
@@ -274,7 +274,7 @@ QJSValue ControllerScriptInterfaceLegacy::makeConnectionInternal(
 
     if (coScript->addScriptConnection(connection)) {
         return pJsEngine->newQObject(
-                new ScriptConnectionJSProxy(connection));
+                new ScriptConnectionJSProxy(std::move(connection)));
     }
 
     return QJSValue();
@@ -393,19 +393,17 @@ QJSValue ControllerScriptInterfaceLegacy::connectControl(const QString& group,
             // not break.
             ScriptConnection connection = coScript->firstConnection();
 
-            qCWarning(m_logger) << "Tried to make duplicate connection between (" +
-                            group + ", " + name + ") and " +
-                            passedCallback.toString() +
-                            " but this is not allowed when passing a callback "
-                            "as a string. " +
-                            "If you actually want to create duplicate "
-                            "connections, " +
-                            "use engine.makeConnection. Returning reference to "
-                            "connection " +
-                            connection.id.toString();
+            qCWarning(m_logger).nospace()
+                    << "Tried to make duplicate connection between (" << group
+                    << ", " << name << ") and " << passedCallback.toString()
+                    << " but this is not allowed when passing a callback "
+                       "as a string. If you actually want to create duplicate "
+                       "connections, use engine.makeConnection. "
+                       "Returning reference to connection "
+                    << connection.id.toString();
 
             return pJsEngine->newQObject(
-                    new ScriptConnectionJSProxy(connection));
+                    new ScriptConnectionJSProxy(std::move(connection)));
         }
     } else if (passedCallback.isQObject()) {
         // Assume a ScriptConnection and assume that the script author

From 6c67cd83e3cb5ef12cfcf9d57a85434154990313 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= <daschuer@mixxx.org>
Date: Fri, 6 Sep 2024 18:35:49 +0200
Subject: [PATCH 23/36] Introduce m_actual_speed with is what the scalers
 actually did.

This is required for determining the exact feat position in a buffer.
---
 src/engine/enginebuffer.cpp | 7 ++++++-
 src/engine/enginebuffer.h   | 5 +++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/engine/enginebuffer.cpp b/src/engine/enginebuffer.cpp
index 0a2a45e2a97..d3c3b7bf9eb 100644
--- a/src/engine/enginebuffer.cpp
+++ b/src/engine/enginebuffer.cpp
@@ -72,6 +72,7 @@ EngineBuffer::EngineBuffer(const QString& group,
           m_pReader(nullptr),
           m_playPos(kInitialPlayPosition),
           m_speed_old(0),
+          m_actual_speed(0),
           m_tempo_ratio_old(1.),
           m_scratching_old(false),
           m_reverse_old(false),
@@ -1106,6 +1107,9 @@ void EngineBuffer::processTrackLocked(
         }
     }
 
+    m_actual_speed = (m_playPos - playpos_old) / (iBufferSize / 2);
+    // qDebug() << "Ramped Speed" << m_actual_speed / m_speed_old;
+
     for (const auto& pControl : std::as_const(m_engineControls)) {
         // m_playPos is already updated here and points to the end of the played buffer
         pControl->setFrameInfo(m_playPos, trackEndPosition, m_trackSampleRateOld);
@@ -1194,6 +1198,7 @@ void EngineBuffer::process(CSAMPLE* pOutput, const int iBufferSize) {
 
         m_rate_old = 0;
         m_speed_old = 0;
+        m_actual_speed = 0;
         m_scratching_old = false;
     }
 
@@ -1571,7 +1576,7 @@ double EngineBuffer::getRateRatio() const {
 
 void EngineBuffer::collectFeatures(GroupFeatureState* pGroupFeatures) const {
     if (m_pBpmControl != nullptr) {
-        m_pBpmControl->collectFeatures(pGroupFeatures, m_speed_old);
+        m_pBpmControl->collectFeatures(pGroupFeatures, m_actual_speed);
     }
 }
 
diff --git a/src/engine/enginebuffer.h b/src/engine/enginebuffer.h
index 657e65fe930..5b79edc8615 100644
--- a/src/engine/enginebuffer.h
+++ b/src/engine/enginebuffer.h
@@ -338,6 +338,11 @@ class EngineBuffer : public EngineObject {
     // need updating.
     double m_speed_old;
 
+    // The actual speed is the speed calculated from buffer start and end position
+    // It can differ form m_speed_old which holds the requested speed.
+    // It is the average of one fuffer, in case speed ramping is applied in the scalers.
+    double m_actual_speed;
+
     // The previous callback's tempo ratio.
     double m_tempo_ratio_old;
 

From 885e9ef8cc2016f954e12f773cc4f5640846e886 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= <daschuer@mixxx.org>
Date: Fri, 6 Sep 2024 18:39:17 +0200
Subject: [PATCH 24/36] Don't snap "beat_next" and "beat_prev" to the nearest
 beat. This was a no longer required  workaround form the time, where the
 Mixxx transport was integer precise.

---
 src/engine/controls/quantizecontrol.cpp | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/engine/controls/quantizecontrol.cpp b/src/engine/controls/quantizecontrol.cpp
index a8f9b40db2f..6588d6aaf7c 100644
--- a/src/engine/controls/quantizecontrol.cpp
+++ b/src/engine/controls/quantizecontrol.cpp
@@ -67,8 +67,6 @@ void QuantizeControl::playPosChanged(mixxx::audio::FramePos position) {
     // We only need to update the prev or next if the current sample is
     // out of range of the existing beat positions or if we've been forced to
     // do so.
-    // NOTE: This bypasses the epsilon calculation, but is there a way
-    //       that could actually cause a problem?
     const auto prevBeatPosition =
             mixxx::audio::FramePos::fromEngineSamplePosMaybeInvalid(
                     m_pCOPrevBeat->get());
@@ -88,7 +86,7 @@ void QuantizeControl::lookupBeatPositions(mixxx::audio::FramePos position) {
     if (pBeats) {
         mixxx::audio::FramePos prevBeatPosition;
         mixxx::audio::FramePos nextBeatPosition;
-        pBeats->findPrevNextBeats(position, &prevBeatPosition, &nextBeatPosition, true);
+        pBeats->findPrevNextBeats(position, &prevBeatPosition, &nextBeatPosition, false);
         // FIXME: -1.0 is a valid frame position, should we set the COs to NaN?
         m_pCOPrevBeat->set(prevBeatPosition.toEngineSamplePosMaybeInvalid());
         m_pCONextBeat->set(nextBeatPosition.toEngineSamplePosMaybeInvalid());

From 8ea34577ffca807a9d7cfb71d90d78aec4da6c4d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= <daschuer@mixxx.org>
Date: Fri, 6 Sep 2024 18:41:45 +0200
Subject: [PATCH 25/36] Fix the metronome effect during scratching using
 scratch_rate.

---
 .../backends/builtin/metronomeeffect.cpp      | 23 ++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/src/effects/backends/builtin/metronomeeffect.cpp b/src/effects/backends/builtin/metronomeeffect.cpp
index 61bcfbab42b..1cfa148df48 100644
--- a/src/effects/backends/builtin/metronomeeffect.cpp
+++ b/src/effects/backends/builtin/metronomeeffect.cpp
@@ -103,9 +103,26 @@ void MetronomeEffect::processChannel(
     double nextClickStart = bufferEnd; // default to "no new click";
     if (m_pSyncParameter->toBool() && groupFeatures.beat_length_frames.has_value()) {
         if (groupFeatures.beat_fraction_buffer_end.has_value()) {
-            double beatToBufferEnd =
-                    groupFeatures.beat_length_frames.value() *
-                    groupFeatures.beat_fraction_buffer_end.value();
+            double beatLength = groupFeatures.beat_length_frames.value();
+            if (groupFeatures.scratch_rate.has_value()) {
+                if (groupFeatures.scratch_rate.value() != 0.0) {
+                    beatLength /= groupFeatures.scratch_rate.value();
+                } else {
+                    beatLength = 0;
+                }
+            }
+
+            double beatToBufferEnd;
+            if (beatLength > 0) {
+                beatToBufferEnd =
+                        beatLength *
+                        groupFeatures.beat_fraction_buffer_end.value();
+            } else {
+                beatToBufferEnd =
+                        beatLength * -1 *
+                        (1 - groupFeatures.beat_fraction_buffer_end.value());
+            }
+
             if (bufferEnd > beatToBufferEnd) {
                 // We have a new beat before the current buffer ends
                 nextClickStart = bufferEnd - beatToBufferEnd;

From 4a5f51ae7115f3d6546f28167e3a84d249ad5a64 Mon Sep 17 00:00:00 2001
From: ronso0 <ronso0@mixxx.org>
Date: Fri, 6 Sep 2024 23:54:32 +0200
Subject: [PATCH 26/36] WOverview: update immediately when the normalize option
 or Global gain changed

---
 src/waveform/waveformwidgetfactory.cpp |  5 +++++
 src/waveform/waveformwidgetfactory.h   |  3 +++
 src/widget/woverview.cpp               | 16 ++++++++++++++++
 src/widget/woverview.h                 |  1 +
 4 files changed, 25 insertions(+)

diff --git a/src/waveform/waveformwidgetfactory.cpp b/src/waveform/waveformwidgetfactory.cpp
index 4fc216b0589..bb63c331dff 100644
--- a/src/waveform/waveformwidgetfactory.cpp
+++ b/src/waveform/waveformwidgetfactory.cpp
@@ -718,6 +718,9 @@ void WaveformWidgetFactory::setVisualGain(FilterIndex index, double gain) {
     if (m_config) {
         m_config->set(ConfigKey("[Waveform]","VisualGain_" + QString::number(index)), QString::number(m_visualGain[index]));
     }
+    if (!m_overviewNormalized && index == FilterIndex::All) {
+        emit overallVisualGainChanged();
+    }
 }
 
 double WaveformWidgetFactory::getVisualGain(FilterIndex index) const {
@@ -729,6 +732,7 @@ void WaveformWidgetFactory::setOverviewNormalized(bool normalize) {
     if (m_config) {
         m_config->set(ConfigKey("[Waveform]","OverviewNormalized"), ConfigValue(m_overviewNormalized));
     }
+    emit overviewNormalizeChanged();
 }
 
 void WaveformWidgetFactory::setPlayMarkerPosition(double position) {
@@ -1397,6 +1401,7 @@ void WaveformWidgetFactory::setUntilMarkAlign(Qt::Alignment align) {
                 toUntilMarkAlignIndex(m_untilMarkAlign));
     }
 }
+
 void WaveformWidgetFactory::setUntilMarkTextPointSize(int value) {
     m_untilMarkTextPointSize = value;
     if (m_config) {
diff --git a/src/waveform/waveformwidgetfactory.h b/src/waveform/waveformwidgetfactory.h
index 1ddfae28a3b..f57cd305be6 100644
--- a/src/waveform/waveformwidgetfactory.h
+++ b/src/waveform/waveformwidgetfactory.h
@@ -169,6 +169,9 @@ class WaveformWidgetFactory : public QObject, public Singleton<WaveformWidgetFac
     void renderVuMeters(VSyncThread*);
     void swapVuMeters();
 
+    void overviewNormalizeChanged();
+    void overallVisualGainChanged();
+
   public slots:
     void slotSkinLoaded();
 
diff --git a/src/widget/woverview.cpp b/src/widget/woverview.cpp
index 1aae0bfb0fc..7ada1608a6c 100644
--- a/src/widget/woverview.cpp
+++ b/src/widget/woverview.cpp
@@ -86,6 +86,18 @@ WOverview::WOverview(
     m_pTypeControl->connectValueChanged(this, &WOverview::slotTypeControlChanged);
     slotTypeControlChanged(m_pTypeControl->get());
 
+    // Update immediately when the normalize option or the visual gain have been
+    // changed in the preferences.
+    WaveformWidgetFactory* widgetFactory = WaveformWidgetFactory::instance();
+    connect(widgetFactory,
+            &WaveformWidgetFactory::overviewNormalizeChanged,
+            this,
+            &WOverview::slotNormalizeOrVisualGainChanged);
+    connect(widgetFactory,
+            &WaveformWidgetFactory::overallVisualGainChanged,
+            this,
+            &WOverview::slotNormalizeOrVisualGainChanged);
+
     m_pPassthroughLabel = make_parented<QLabel>(this);
 
     setAcceptDrops(true);
@@ -416,6 +428,10 @@ void WOverview::slotTypeControlChanged(double v) {
     slotWaveformSummaryUpdated();
 }
 
+void WOverview::slotNormalizeOrVisualGainChanged() {
+    update();
+}
+
 void WOverview::updateCues(const QList<CuePointer> &loadedCues) {
     for (const CuePointer& currentCue : loadedCues) {
         const WaveformMarkPointer pMark = m_marks.getHotCueMark(currentCue->getHotCue());
diff --git a/src/widget/woverview.h b/src/widget/woverview.h
index b6b85093937..19f69dc9659 100644
--- a/src/widget/woverview.h
+++ b/src/widget/woverview.h
@@ -74,6 +74,7 @@ class WOverview : public WWidget, public TrackDropTarget {
     void slotCueMenuPopupAboutToHide();
 
     void slotTypeControlChanged(double v);
+    void slotNormalizeOrVisualGainChanged();
 
   private:
     // Append the waveform overview pixmap according to available data

From c3f084d1fc711b79e896e1a2c8740f58defdb97a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= <daschuer@mixxx.org>
Date: Mon, 9 Sep 2024 13:51:41 +0200
Subject: [PATCH 27/36] Don't use std::optional::value introduced in macOS
 10.13

---
 src/effects/backends/builtin/autopaneffect.cpp       |  2 +-
 src/effects/backends/builtin/echoeffect.cpp          |  2 +-
 src/effects/backends/builtin/flangereffect.cpp       |  2 +-
 .../backends/builtin/loudnesscontoureffect.cpp       |  2 +-
 src/effects/backends/builtin/metronomeeffect.cpp     | 12 ++++++------
 src/effects/backends/builtin/phasereffect.cpp        |  2 +-
 src/effects/backends/builtin/tremoloeffect.cpp       |  6 +++---
 7 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/effects/backends/builtin/autopaneffect.cpp b/src/effects/backends/builtin/autopaneffect.cpp
index 63a939fdfb4..0aab16ea246 100644
--- a/src/effects/backends/builtin/autopaneffect.cpp
+++ b/src/effects/backends/builtin/autopaneffect.cpp
@@ -91,7 +91,7 @@ void AutoPanEffect::processChannel(
     if (groupFeatures.beat_length_frames.has_value()) {
         // period is a number of beats
         double beats = std::max(roundToFraction(period, 2), 0.25);
-        period = beats * groupFeatures.beat_length_frames.value();
+        period = beats * *groupFeatures.beat_length_frames;
 
         // TODO(xxx) sync phase
         //if (groupFeatures.has_beat_fraction) {
diff --git a/src/effects/backends/builtin/echoeffect.cpp b/src/effects/backends/builtin/echoeffect.cpp
index 4921c578589..1c01137d91b 100644
--- a/src/effects/backends/builtin/echoeffect.cpp
+++ b/src/effects/backends/builtin/echoeffect.cpp
@@ -142,7 +142,7 @@ void EchoEffect::processChannel(
         } else if (period < 1 / 8.0) {
             period = 1 / 8.0;
         }
-        delay_frames = static_cast<int>(period * groupFeatures.beat_length_frames.value());
+        delay_frames = static_cast<int>(period * *groupFeatures.beat_length_frames);
     } else {
         // period is a number of seconds
         period = std::max(period, 1 / 8.0);
diff --git a/src/effects/backends/builtin/flangereffect.cpp b/src/effects/backends/builtin/flangereffect.cpp
index d1fcaa83623..426397ca4b3 100644
--- a/src/effects/backends/builtin/flangereffect.cpp
+++ b/src/effects/backends/builtin/flangereffect.cpp
@@ -123,7 +123,7 @@ void FlangerEffect::processChannel(
         if (m_pTripletParameter->toBool()) {
             lfoPeriodParameter /= 3.0;
         }
-        lfoPeriodFrames = lfoPeriodParameter * groupFeatures.beat_length_frames.value();
+        lfoPeriodFrames = lfoPeriodParameter * *groupFeatures.beat_length_frames;
     } else {
         // lfoPeriodParameter is a number of seconds
         lfoPeriodFrames = std::max(lfoPeriodParameter, kMinLfoBeats) *
diff --git a/src/effects/backends/builtin/loudnesscontoureffect.cpp b/src/effects/backends/builtin/loudnesscontoureffect.cpp
index 36073576f01..359fe96b62d 100644
--- a/src/effects/backends/builtin/loudnesscontoureffect.cpp
+++ b/src/effects/backends/builtin/loudnesscontoureffect.cpp
@@ -111,7 +111,7 @@ void LoudnessContourEffect::processChannel(
     if (enableState != EffectEnableState::Disabling) {
         bool useGain = m_pUseGain->toBool() && groupFeatures.gain.has_value();
         double loudness = m_pLoudness->value();
-        double gainKnob = groupFeatures.gain.value();
+        double gainKnob = *groupFeatures.gain;
 
         filterGainDb = loudness;
 
diff --git a/src/effects/backends/builtin/metronomeeffect.cpp b/src/effects/backends/builtin/metronomeeffect.cpp
index 1cfa148df48..bff49a3155b 100644
--- a/src/effects/backends/builtin/metronomeeffect.cpp
+++ b/src/effects/backends/builtin/metronomeeffect.cpp
@@ -103,10 +103,10 @@ void MetronomeEffect::processChannel(
     double nextClickStart = bufferEnd; // default to "no new click";
     if (m_pSyncParameter->toBool() && groupFeatures.beat_length_frames.has_value()) {
         if (groupFeatures.beat_fraction_buffer_end.has_value()) {
-            double beatLength = groupFeatures.beat_length_frames.value();
+            double beatLength = *groupFeatures.beat_length_frames;
             if (groupFeatures.scratch_rate.has_value()) {
-                if (groupFeatures.scratch_rate.value() != 0.0) {
-                    beatLength /= groupFeatures.scratch_rate.value();
+                if (*groupFeatures.scratch_rate != 0.0) {
+                    beatLength /= *groupFeatures.scratch_rate;
                 } else {
                     beatLength = 0;
                 }
@@ -116,11 +116,11 @@ void MetronomeEffect::processChannel(
             if (beatLength > 0) {
                 beatToBufferEnd =
                         beatLength *
-                        groupFeatures.beat_fraction_buffer_end.value();
+                        *groupFeatures.beat_fraction_buffer_end;
             } else {
                 beatToBufferEnd =
                         beatLength * -1 *
-                        (1 - groupFeatures.beat_fraction_buffer_end.value());
+                        (1 - *groupFeatures.beat_fraction_buffer_end);
             }
 
             if (bufferEnd > beatToBufferEnd) {
@@ -128,7 +128,7 @@ void MetronomeEffect::processChannel(
                 nextClickStart = bufferEnd - beatToBufferEnd;
             }
         } else {
-            nextClickStart = groupFeatures.beat_length_frames.value();
+            nextClickStart = *groupFeatures.beat_length_frames;
         }
     } else {
         nextClickStart = engineParameters.sampleRate() * 60 / m_pBpmParameter->value();
diff --git a/src/effects/backends/builtin/phasereffect.cpp b/src/effects/backends/builtin/phasereffect.cpp
index 26d683f7fc8..cf1e7a89d4d 100644
--- a/src/effects/backends/builtin/phasereffect.cpp
+++ b/src/effects/backends/builtin/phasereffect.cpp
@@ -138,7 +138,7 @@ void PhaserEffect::processChannel(
         if (m_pTripletParameter->toBool()) {
             periodParameter /= 3.0;
         }
-        periodSamples = periodParameter * groupFeatures.beat_length_frames.value();
+        periodSamples = periodParameter * *groupFeatures.beat_length_frames;
     } else {
         // periodParameter is a number of seconds
         periodSamples = std::max(periodParameter, 1 / 4.0) * engineParameters.sampleRate();
diff --git a/src/effects/backends/builtin/tremoloeffect.cpp b/src/effects/backends/builtin/tremoloeffect.cpp
index 3a40acafd66..6b8924689fc 100644
--- a/src/effects/backends/builtin/tremoloeffect.cpp
+++ b/src/effects/backends/builtin/tremoloeffect.cpp
@@ -139,8 +139,8 @@ void TremoloEffect::processChannel(
 
     if (enableState == EffectEnableState::Enabling || quantizeEnabling || tripletDisabling) {
         if (gf.beat_length_frames.has_value() && gf.beat_fraction_buffer_end.has_value()) {
-            currentFrame = static_cast<unsigned int>(gf.beat_fraction_buffer_end.value() *
-                    gf.beat_length_frames.value());
+            currentFrame = static_cast<unsigned int>(*gf.beat_fraction_buffer_end *
+                    *gf.beat_length_frames);
         } else {
             currentFrame = 0;
         }
@@ -158,7 +158,7 @@ void TremoloEffect::processChannel(
                 rate *= 3.0;
             }
         }
-        const auto framePerBeat = static_cast<int>(gf.beat_length_frames.value());
+        const auto framePerBeat = static_cast<int>(*gf.beat_length_frames);
         framePerPeriod = static_cast<int>(framePerBeat / rate);
     } else {
         framePerPeriod = static_cast<int>(engineParameters.sampleRate() / rate);

From e5ff7f3c37d9679064180ab4cc14f4fc133f3303 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= <daschuer@mixxx.org>
Date: Mon, 9 Sep 2024 14:49:35 +0200
Subject: [PATCH 28/36] default GroupFeatureState ctor

Co-authored-by: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com>
---
 src/engine/effects/groupfeaturestate.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/engine/effects/groupfeaturestate.h b/src/engine/effects/groupfeaturestate.h
index b5d8b61e0ba..8abbd02c49d 100644
--- a/src/engine/effects/groupfeaturestate.h
+++ b/src/engine/effects/groupfeaturestate.h
@@ -4,8 +4,7 @@
 
 /// GroupFeatureState communicates metadata about EngineChannels to EffectProcessors.
 struct GroupFeatureState {
-    GroupFeatureState() {
-    }
+    GroupFeatureState() = default;
 
     // Adjusted by the rate slider
     std::optional<double> beat_length_frames;

From 1fecf393726d7c7fc449c3c866526e4d7928400f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= <daschuer@mixxx.org>
Date: Mon, 9 Sep 2024 14:54:44 +0200
Subject: [PATCH 29/36] Improve readability in meronomeeffect.cpp

---
 src/effects/backends/builtin/metronomeeffect.cpp | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/src/effects/backends/builtin/metronomeeffect.cpp b/src/effects/backends/builtin/metronomeeffect.cpp
index bff49a3155b..bd6f96956d3 100644
--- a/src/effects/backends/builtin/metronomeeffect.cpp
+++ b/src/effects/backends/builtin/metronomeeffect.cpp
@@ -57,8 +57,6 @@ void MetronomeEffect::processChannel(
         const mixxx::EngineParameters& engineParameters,
         const EffectEnableState enableState,
         const GroupFeatureState& groupFeatures) {
-    Q_UNUSED(pInput);
-
     if (enableState == EffectEnableState::Disabled) {
         // assume click is fully played
         return;
@@ -137,13 +135,11 @@ void MetronomeEffect::processChannel(
     if (bufferEnd > nextClickStart) {
         // We need to start a new click
         SINT outputOffset = static_cast<SINT>(nextClickStart) - gs->m_framesSinceClickStart;
-        if (outputOffset > 0) {
-            if (outputOffset < engineParameters.framesPerBuffer()) {
-                const SINT copyFrames =
-                        math_min(engineParameters.framesPerBuffer() - outputOffset, clickSize);
-                SampleUtil::addMonoToStereo(&pOutput[outputOffset * 2], &click[0], copyFrames);
-                gs->m_framesSinceClickStart = -outputOffset;
-            }
+        if (outputOffset > 0 && outputOffset < engineParameters.framesPerBuffer()) {
+            const SINT copyFrames =
+                    math_min(engineParameters.framesPerBuffer() - outputOffset, clickSize);
+            SampleUtil::addMonoToStereo(&pOutput[outputOffset * 2], &click[0], copyFrames);
+            gs->m_framesSinceClickStart = -outputOffset;
         }
     }
     if (gs->m_framesSinceClickStart < engineParameters.framesPerBuffer() + clickSize) {

From 11af75178bfb283c45363bcdeb690ae9ffdefd7b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= <daschuer@mixxx.org>
Date: Mon, 9 Sep 2024 15:02:46 +0200
Subject: [PATCH 30/36] Fix use of GroupFeatureState in LoudnessContourEffect

---
 src/effects/backends/builtin/loudnesscontoureffect.cpp | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/effects/backends/builtin/loudnesscontoureffect.cpp b/src/effects/backends/builtin/loudnesscontoureffect.cpp
index 359fe96b62d..0bfe811a933 100644
--- a/src/effects/backends/builtin/loudnesscontoureffect.cpp
+++ b/src/effects/backends/builtin/loudnesscontoureffect.cpp
@@ -103,15 +103,13 @@ void LoudnessContourEffect::processChannel(
         const mixxx::EngineParameters& engineParameters,
         const EffectEnableState enableState,
         const GroupFeatureState& groupFeatures) {
-    Q_UNUSED(groupFeatures);
-
     double filterGainDb = pState->m_oldFilterGainDb;
     auto gain = static_cast<CSAMPLE_GAIN>(pState->m_oldGain);
 
     if (enableState != EffectEnableState::Disabling) {
         bool useGain = m_pUseGain->toBool() && groupFeatures.gain.has_value();
         double loudness = m_pLoudness->value();
-        double gainKnob = *groupFeatures.gain;
+        double gainKnob = groupFeatures.gain.value_or(1.0);
 
         filterGainDb = loudness;
 

From 9293b5199132a10db9152819cd4dbe917309b5cf Mon Sep 17 00:00:00 2001
From: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com>
Date: Wed, 11 Sep 2024 14:51:07 +0200
Subject: [PATCH 31/36] refactor: move metronome sampledata into separate
 translation unit

---
 CMakeLists.txt                                |    1 +
 .../backends/builtin/metronomeclick.cpp       | 4395 +++++++++++++++++
 src/effects/backends/builtin/metronomeclick.h | 4386 +---------------
 .../backends/builtin/metronomeeffect.cpp      |   12 +-
 4 files changed, 4402 insertions(+), 4392 deletions(-)
 create mode 100644 src/effects/backends/builtin/metronomeclick.cpp

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 99dcdc345ad..f558edd9a6c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -775,6 +775,7 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL
   src/effects/backends/builtin/linkwitzriley8eqeffect.cpp
   src/effects/backends/builtin/loudnesscontoureffect.cpp
   src/effects/backends/builtin/metronomeeffect.cpp
+  src/effects/backends/builtin/metronomeclick.cpp
   src/effects/backends/builtin/moogladder4filtereffect.cpp
   src/effects/backends/builtin/distortioneffect.cpp
   src/effects/backends/builtin/parametriceqeffect.cpp
diff --git a/src/effects/backends/builtin/metronomeclick.cpp b/src/effects/backends/builtin/metronomeclick.cpp
new file mode 100644
index 00000000000..a29b9584eb0
--- /dev/null
+++ b/src/effects/backends/builtin/metronomeclick.cpp
@@ -0,0 +1,4395 @@
+#include "effects/backends/builtin/metronomeclick.h"
+namespace {
+// This is a new recording from a real metronome
+// it was converted from *.wav to plain text using Audacity
+
+constexpr CSAMPLE kClick44100[] = {
+        0.03459f,
+        0.09436f,
+        0.13646f,
+        0.13397f,
+        0.12769f,
+        0.16707f,
+        0.23479f,
+        0.27845f,
+        0.26258f,
+        0.15676f,
+        -0.04469f,
+        -0.25386f,
+        -0.34708f,
+        -0.32814f,
+        -0.32287f,
+        -0.38761f,
+        -0.44187f,
+        -0.41100f,
+        -0.30597f,
+        -0.15478f,
+        0.01382f,
+        0.12843f,
+        0.14796f,
+        0.13350f,
+        0.14399f,
+        0.12870f,
+        0.00836f,
+        -0.20222f,
+        -0.40190f,
+        -0.49408f,
+        -0.45249f,
+        -0.32491f,
+        -0.17703f,
+        -0.04102f,
+        0.07596f,
+        0.16295f,
+        0.22100f,
+        0.27411f,
+        0.31737f,
+        0.30172f,
+        0.22581f,
+        0.17353f,
+        0.20625f,
+        0.29894f,
+        0.39225f,
+        0.43471f,
+        0.39620f,
+        0.30707f,
+        0.24406f,
+        0.25017f,
+        0.28685f,
+        0.26838f,
+        0.16888f,
+        0.07771f,
+        0.07703f,
+        0.12917f,
+        0.16924f,
+        0.18038f,
+        0.12173f,
+        -0.03985f,
+        -0.22585f,
+        -0.33717f,
+        -0.38322f,
+        -0.42069f,
+        -0.47394f,
+        -0.54568f,
+        -0.60043f,
+        -0.56950f,
+        -0.43692f,
+        -0.25673f,
+        -0.07543f,
+        0.09491f,
+        0.23567f,
+        0.31195f,
+        0.30476f,
+        0.22808f,
+        0.11839f,
+        0.02167f,
+        -0.02317f,
+        -0.02049f,
+        -0.02039f,
+        -0.05451f,
+        -0.09535f,
+        -0.09242f,
+        -0.02332f,
+        0.07294f,
+        0.10909f,
+        0.03442f,
+        -0.10286f,
+        -0.20934f,
+        -0.22986f,
+        -0.16333f,
+        -0.05486f,
+        0.02456f,
+        0.04289f,
+        0.04285f,
+        0.08445f,
+        0.17320f,
+        0.25566f,
+        0.26299f,
+        0.17014f,
+        0.03790f,
+        -0.03072f,
+        -0.00689f,
+        0.03881f,
+        0.04679f,
+        0.02877f,
+        0.00884f,
+        0.00138f,
+        0.03024f,
+        0.07291f,
+        0.05081f,
+        -0.04617f,
+        -0.12579f,
+        -0.12098f,
+        -0.04814f,
+        0.04824f,
+        0.12493f,
+        0.15746f,
+        0.17621f,
+        0.22541f,
+        0.28672f,
+        0.30292f,
+        0.24742f,
+        0.13678f,
+        0.01260f,
+        -0.08157f,
+        -0.13262f,
+        -0.16340f,
+        -0.19945f,
+        -0.23970f,
+        -0.25591f,
+        -0.21998f,
+        -0.14390f,
+        -0.07781f,
+        -0.05757f,
+        -0.06808f,
+        -0.06935f,
+        -0.04456f,
+        -0.01490f,
+        -0.01461f,
+        -0.05266f,
+        -0.09777f,
+        -0.10582f,
+        -0.07299f,
+        -0.04444f,
+        -0.05213f,
+        -0.07615f,
+        -0.08385f,
+        -0.06168f,
+        -0.00244f,
+        0.07425f,
+        0.11139f,
+        0.09062f,
+        0.06733f,
+        0.08443f,
+        0.12020f,
+        0.14020f,
+        0.12856f,
+        0.07336f,
+        -0.01188f,
+        -0.07367f,
+        -0.07511f,
+        -0.03639f,
+        0.00539f,
+        0.04250f,
+        0.08281f,
+        0.12148f,
+        0.14662f,
+        0.14958f,
+        0.12349f,
+        0.06494f,
+        -0.02257f,
+        -0.12207f,
+        -0.19914f,
+        -0.23050f,
+        -0.23629f,
+        -0.24047f,
+        -0.22049f,
+        -0.15182f,
+        -0.05974f,
+        0.01923f,
+        0.07074f,
+        0.08392f,
+        0.05757f,
+        0.01974f,
+        0.00129f,
+        0.00862f,
+        0.02926f,
+        0.04478f,
+        0.04602f,
+        0.04341f,
+        0.05014f,
+        0.05643f,
+        0.03546f,
+        -0.01834f,
+        -0.07537f,
+        -0.11110f,
+        -0.12691f,
+        -0.12411f,
+        -0.10754f,
+        -0.09923f,
+        -0.10206f,
+        -0.08627f,
+        -0.03778f,
+        0.02648f,
+        0.07680f,
+        0.07931f,
+        0.03101f,
+        -0.01723f,
+        -0.01654f,
+        0.03056f,
+        0.09147f,
+        0.14028f,
+        0.18082f,
+        0.23092f,
+        0.28166f,
+        0.31268f,
+        0.32659f,
+        0.32160f,
+        0.28067f,
+        0.21356f,
+        0.14683f,
+        0.07928f,
+        -0.00116f,
+        -0.08048f,
+        -0.13060f,
+        -0.14039f,
+        -0.12032f,
+        -0.08408f,
+        -0.04745f,
+        -0.03051f,
+        -0.02827f,
+        -0.01512f,
+        0.00446f,
+        0.00886f,
+        0.00775f,
+        0.02161f,
+        0.05230f,
+        0.09373f,
+        0.12782f,
+        0.13474f,
+        0.12327f,
+        0.10086f,
+        0.04818f,
+        -0.03682f,
+        -0.12249f,
+        -0.17666f,
+        -0.18403f,
+        -0.15787f,
+        -0.12867f,
+        -0.11173f,
+        -0.10847f,
+        -0.10970f,
+        -0.09328f,
+        -0.07013f,
+        -0.08650f,
+        -0.13937f,
+        -0.17932f,
+        -0.19186f,
+        -0.19026f,
+        -0.17832f,
+        -0.15854f,
+        -0.12098f,
+        -0.05565f,
+        0.00610f,
+        0.02774f,
+        0.01399f,
+        -0.01458f,
+        -0.03553f,
+        -0.03309f,
+        -0.02864f,
+        -0.03883f,
+        -0.03313f,
+        0.00129f,
+        0.03547f,
+        0.05713f,
+        0.06533f,
+        0.04814f,
+        0.01266f,
+        -0.02066f,
+        -0.04113f,
+        -0.04551f,
+        -0.05089f,
+        -0.07535f,
+        -0.08810f,
+        -0.04419f,
+        0.04547f,
+        0.12324f,
+        0.13714f,
+        0.10579f,
+        0.11708f,
+        0.18173f,
+        0.19511f,
+        0.12903f,
+        0.05601f,
+        -0.02344f,
+        -0.11597f,
+        -0.11637f,
+        0.00381f,
+        0.09555f,
+        0.07643f,
+        0.04022f,
+        0.06328f,
+        0.10965f,
+        0.12557f,
+        0.08761f,
+        -0.00397f,
+        -0.09654f,
+        -0.10482f,
+        -0.03619f,
+        -0.02738f,
+        -0.15558f,
+        -0.30618f,
+        -0.32512f,
+        -0.17980f,
+        0.05893f,
+        0.24755f,
+        0.26022f,
+        0.15746f,
+        0.10698f,
+        0.12767f,
+        0.11703f,
+        0.04428f,
+        -0.05892f,
+        -0.14889f,
+        -0.14221f,
+        -0.01032f,
+        0.12248f,
+        0.12812f,
+        0.04112f,
+        -0.01848f,
+        0.01182f,
+        0.10921f,
+        0.19406f,
+        0.19163f,
+        0.12287f,
+        0.08187f,
+        0.10396f,
+        0.13949f,
+        0.13201f,
+        0.05523f,
+        -0.05590f,
+        -0.10584f,
+        -0.06066f,
+        0.00319f,
+        0.02458f,
+        0.00266f,
+        -0.04579f,
+        -0.06606f,
+        -0.01926f,
+        0.03021f,
+        0.02058f,
+        -0.01833f,
+        -0.06103f,
+        -0.10540f,
+        -0.11843f,
+        -0.09712f,
+        -0.08664f,
+        -0.10371f,
+        -0.13938f,
+        -0.17927f,
+        -0.18908f,
+        -0.15833f,
+        -0.11590f,
+        -0.07976f,
+        -0.05598f,
+        -0.03229f,
+        0.02044f,
+        0.06564f,
+        0.03584f,
+        -0.02610f,
+        -0.04853f,
+        -0.06666f,
+        -0.09862f,
+        -0.07855f,
+        -0.00945f,
+        0.03533f,
+        0.05170f,
+        0.06937f,
+        0.06798f,
+        0.03647f,
+        0.00590f,
+        -0.02032f,
+        -0.07579f,
+        -0.15381f,
+        -0.19499f,
+        -0.16406f,
+        -0.08496f,
+        -0.00320f,
+        0.04234f,
+        0.04797f,
+        0.06657f,
+        0.13493f,
+        0.20529f,
+        0.22004f,
+        0.18459f,
+        0.12525f,
+        0.06540f,
+        0.03991f,
+        0.05305f,
+        0.06738f,
+        0.06670f,
+        0.06504f,
+        0.06147f,
+        0.04185f,
+        0.00507f,
+        -0.03448f,
+        -0.05125f,
+        -0.02913f,
+        0.01559f,
+        0.05433f,
+        0.07532f,
+        0.07889f,
+        0.07308f,
+        0.06800f,
+        0.05050f,
+        0.00521f,
+        -0.03885f,
+        -0.04959f,
+        -0.05210f,
+        -0.07879f,
+        -0.11559f,
+        -0.14183f,
+        -0.14651f,
+        -0.10790f,
+        -0.03378f,
+        0.02235f,
+        0.03398f,
+        0.02714f,
+        0.02948f,
+        0.04395f,
+        0.05421f,
+        0.03861f,
+        0.00299f,
+        -0.01504f,
+        0.00895f,
+        0.05926f,
+        0.09261f,
+        0.07086f,
+        0.00626f,
+        -0.04195f,
+        -0.03927f,
+        -0.00847f,
+        0.01482f,
+        0.01056f,
+        -0.02572f,
+        -0.06891f,
+        -0.07971f,
+        -0.05297f,
+        -0.01872f,
+        -0.00207f,
+        -0.00398f,
+        -0.00381f,
+        0.01610f,
+        0.03990f,
+        0.04023f,
+        0.01932f,
+        -0.00338f,
+        -0.00751f,
+        0.02743f,
+        0.08275f,
+        0.09694f,
+        0.05281f,
+        0.00310f,
+        -0.01163f,
+        0.00362f,
+        0.02366f,
+        0.01377f,
+        -0.03865f,
+        -0.09842f,
+        -0.12568f,
+        -0.11386f,
+        -0.07865f,
+        -0.04651f,
+        -0.03427f,
+        -0.03039f,
+        -0.02670f,
+        -0.03711f,
+        -0.06215f,
+        -0.08460f,
+        -0.09131f,
+        -0.06823f,
+        -0.01608f,
+        0.03005f,
+        0.04887f,
+        0.06172f,
+        0.07927f,
+        0.08341f,
+        0.07165f,
+        0.05462f,
+        0.03051f,
+        0.00477f,
+        -0.00508f,
+        -0.00179f,
+        -0.00285f,
+        -0.01019f,
+        -0.01545f,
+        -0.01302f,
+        0.00070f,
+        0.01781f,
+        0.02326f,
+        0.02301f,
+        0.03102f,
+        0.04078f,
+        0.04430f,
+        0.04788f,
+        0.05010f,
+        0.04386f,
+        0.03747f,
+        0.03837f,
+        0.04012f,
+        0.03893f,
+        0.03982f,
+        0.04251f,
+        0.03661f,
+        0.01758f,
+        -0.00095f,
+        -0.00688f,
+        -0.00886f,
+        -0.01248f,
+        -0.00724f,
+        0.01037f,
+        0.03237f,
+        0.05020f,
+        0.05024f,
+        0.02496f,
+        -0.01019f,
+        -0.03626f,
+        -0.05082f,
+        -0.06031f,
+        -0.07213f,
+        -0.08779f,
+        -0.09670f,
+        -0.08881f,
+        -0.06862f,
+        -0.05296f,
+        -0.05507f,
+        -0.06497f,
+        -0.06256f,
+        -0.04937f,
+        -0.03752f,
+        -0.02667f,
+        -0.01798f,
+        -0.01659f,
+        -0.01715f,
+        -0.01636f,
+        -0.01894f,
+        -0.02081f,
+        -0.01681f,
+        -0.01081f,
+        -0.00266f,
+        0.00976f,
+        0.01961f,
+        0.02005f,
+        0.00787f,
+        -0.01560f,
+        -0.03515f,
+        -0.03517f,
+        -0.01931f,
+        0.00098f,
+        0.02146f,
+        0.03971f,
+        0.05064f,
+        0.05017f,
+        0.04095f,
+        0.02953f,
+        0.01613f,
+        0.00188f,
+        -0.00294f,
+        0.00327f,
+        0.00960f,
+        0.01332f,
+        0.01695f,
+        0.01727f,
+        0.01597f,
+        0.01702f,
+        0.01760f,
+        0.02107f,
+        0.03329f,
+        0.04531f,
+        0.04560f,
+        0.03429f,
+        0.01720f,
+        0.00530f,
+        0.00873f,
+        0.02175f,
+        0.02995f,
+        0.02552f,
+        0.00884f,
+        -0.01128f,
+        -0.02336f,
+        -0.02722f,
+        -0.03135f,
+        -0.03952f,
+        -0.04668f,
+        -0.04382f,
+        -0.03009f,
+        -0.01701f,
+        -0.01214f,
+        -0.01040f,
+        -0.00535f,
+        0.00276f,
+        0.00917f,
+        0.00917f,
+        0.00376f,
+        -0.00109f,
+        -0.00011f,
+        0.00812f,
+        0.01667f,
+        0.01447f,
+        0.00214f,
+        -0.00807f,
+        -0.00921f,
+        -0.00465f,
+        -0.00107f,
+        -0.00255f,
+        -0.00626f,
+        -0.00682f,
+        -0.00359f,
+        0.00187f,
+        0.00778f,
+        0.01000f,
+        0.00710f,
+        0.00484f,
+        0.00858f,
+        0.01621f,
+        0.02208f,
+        0.02281f,
+        0.01799f,
+        0.00918f,
+        0.00085f,
+        -0.00195f,
+        0.00253f,
+        0.01246f,
+        0.02305f,
+        0.02821f,
+        0.02704f,
+        0.02144f,
+        0.00832f,
+        -0.01313f,
+        -0.03553f,
+        -0.05392f,
+        -0.06622f,
+        -0.06704f,
+        -0.05745f,
+        -0.04523f,
+        -0.03152f,
+        -0.01732f,
+        -0.00927f,
+        -0.00420f,
+        0.00578f,
+        0.01470f,
+        0.01608f,
+        0.01481f,
+        0.01288f,
+        0.00814f,
+        0.00392f,
+        0.00106f,
+        -0.00516f,
+        -0.01293f,
+        -0.01547f,
+        -0.01176f,
+        -0.00531f,
+        -0.00050f,
+        -0.00313f,
+        -0.01409f,
+        -0.02467f,
+        -0.02669f,
+        -0.02200f,
+        -0.01610f,
+        -0.01018f,
+        -0.00480f,
+        -0.00149f,
+        0.00044f,
+        0.00330f,
+        0.00943f,
+        0.01908f,
+        0.02922f,
+        0.03911f,
+        0.04968f,
+        0.05445f,
+        0.04785f,
+        0.03744f,
+        0.03068f,
+        0.02705f,
+        0.02862f,
+        0.03255f,
+        0.02670f,
+        0.01343f,
+        0.00736f,
+        0.00706f,
+        0.00310f,
+        -0.00076f,
+        -0.00043f,
+        -0.00254f,
+        -0.00989f,
+        -0.01529f,
+        -0.01277f,
+        -0.00406f,
+        0.00496f,
+        0.00916f,
+        0.00840f,
+        0.00675f,
+        0.00703f,
+        0.00834f,
+        0.00888f,
+        0.00870f,
+        0.00814f,
+        0.00586f,
+        0.00117f,
+        -0.00234f,
+        0.00107f,
+        0.00937f,
+        0.01080f,
+        0.00099f,
+        -0.00992f,
+        -0.01441f,
+        -0.01484f,
+        -0.01387f,
+        -0.01309f,
+        -0.01397f,
+        -0.01470f,
+        -0.01306f,
+        -0.01017f,
+        -0.00953f,
+        -0.01384f,
+        -0.01947f,
+        -0.01853f,
+        -0.01074f,
+        -0.00252f,
+        0.00325f,
+        0.00444f,
+        -0.00075f,
+        -0.00597f,
+        -0.00383f,
+        0.00245f,
+        0.00528f,
+        0.00279f,
+        0.00056f,
+        0.00434f,
+        0.00943f,
+        0.00780f,
+        0.00253f,
+        -0.00069f,
+        -0.00444f,
+        -0.01025f,
+        -0.01549f,
+        -0.02011f,
+        -0.02360f,
+        -0.02317f,
+        -0.01863f,
+        -0.01191f,
+        -0.00593f,
+        -0.00375f,
+        -0.00403f,
+        -0.00332f,
+        0.00001f,
+        0.00805f,
+        0.01843f,
+        0.02264f,
+        0.01888f,
+        0.01236f,
+        0.00453f,
+        -0.00255f,
+        -0.00455f,
+        -0.00347f,
+        -0.00305f,
+        -0.00222f,
+        -0.00116f,
+        -0.00113f,
+        -0.00131f,
+        -0.00330f,
+        -0.00871f,
+        -0.01252f,
+        -0.01099f,
+        -0.00728f,
+        -0.00405f,
+        -0.00148f,
+        0.00049f,
+        0.00387f,
+        0.01024f,
+        0.01637f,
+        0.01840f,
+        0.01844f,
+        0.02045f,
+        0.02204f,
+        0.01867f,
+        0.01215f,
+        0.00699f,
+        0.00492f,
+        0.00609f,
+        0.00842f,
+        0.00762f,
+        0.00176f,
+        -0.00793f,
+        -0.01681f,
+        -0.01759f,
+        -0.01103f,
+        -0.00653f,
+        -0.00699f,
+        -0.00783f,
+        -0.00746f,
+        -0.00483f,
+        0.00046f,
+        0.00343f,
+        0.00255f,
+        0.00311f,
+        0.00490f,
+        0.00426f,
+        0.00363f,
+        0.00488f,
+        0.00516f,
+        0.00389f,
+        0.00196f,
+        -0.00142f,
+        -0.00481f,
+        -0.00569f,
+        -0.00510f,
+        -0.00612f,
+        -0.00983f,
+        -0.01362f,
+        -0.01390f,
+        -0.01148f,
+        -0.00983f,
+        -0.00829f,
+        -0.00531f,
+        -0.00385f,
+        -0.00472f,
+        -0.00327f,
+        0.00131f,
+        0.00386f,
+        0.00262f,
+        -0.00075f,
+        -0.00649f,
+        -0.01300f,
+        -0.01545f,
+        -0.01281f,
+        -0.00767f,
+        -0.00151f,
+        0.00345f,
+        0.00511f,
+        0.00552f,
+        0.00618f,
+        0.00517f,
+        0.00257f,
+        0.00035f,
+        -0.00062f,
+        0.00081f,
+        0.00449f,
+        0.00662f,
+        0.00483f,
+        0.00087f,
+        -0.00231f,
+        -0.00188f,
+        0.00079f,
+        0.00003f,
+        -0.00413f,
+        -0.00568f,
+        -0.00325f,
+        0.00005f,
+        0.00261f,
+        0.00430f,
+        0.00598f,
+        0.00836f,
+        0.01013f,
+        0.01027f,
+        0.00911f,
+        0.00544f,
+        0.00005f,
+        -0.00318f,
+        -0.00422f,
+        -0.00557f,
+        -0.00576f,
+        -0.00344f,
+        -0.00097f,
+        0.00079f,
+        0.00296f,
+        0.00520f,
+        0.00723f,
+        0.00874f,
+        0.00781f,
+        0.00473f,
+        0.00280f,
+        0.00251f,
+        0.00132f,
+        -0.00091f,
+        -0.00291f,
+        -0.00509f,
+        -0.00772f,
+        -0.00921f,
+        -0.00887f,
+        -0.00758f,
+        -0.00571f,
+        -0.00279f,
+        0.00175f,
+        0.00699f,
+        0.01008f,
+        0.00993f,
+        0.00821f,
+        0.00559f,
+        0.00272f,
+        0.00164f,
+        0.00126f,
+        -0.00125f,
+        -0.00393f,
+        -0.00441f,
+        -0.00497f,
+        -0.00616f,
+        -0.00534f,
+        -0.00271f,
+        -0.00037f,
+        0.00080f,
+        0.00026f,
+        -0.00097f,
+        -0.00053f,
+        0.00148f,
+        0.00373f,
+        0.00606f,
+        0.00767f,
+        0.00730f,
+        0.00572f,
+        0.00385f,
+        0.00195f,
+        0.00085f,
+        0.00011f,
+        -0.00186f,
+        -0.00475f,
+        -0.00703f,
+        -0.00856f,
+        -0.00916f,
+        -0.00749f,
+        -0.00364f,
+        0.00023f,
+        0.00235f,
+        0.00242f,
+        0.00104f,
+        -0.00017f,
+        0.00057f,
+        0.00247f,
+        0.00335f,
+        0.00314f,
+        0.00248f,
+        0.00140f,
+        0.00089f,
+        0.00166f,
+        0.00254f,
+        0.00289f,
+        0.00284f,
+        0.00186f,
+        0.00027f,
+        -0.00105f,
+        -0.00214f,
+        -0.00285f,
+        -0.00232f,
+        -0.00094f,
+        0.00041f,
+        0.00154f,
+        0.00174f,
+        0.00068f,
+        -0.00036f,
+        -0.00042f,
+        0.00031f,
+        0.00123f,
+        0.00185f,
+        0.00262f,
+        0.00406f,
+        0.00526f,
+        0.00556f,
+        0.00519f,
+        0.00365f,
+        0.00112f,
+        -0.00027f,
+        0.00008f,
+        0.00019f,
+        -0.00101f,
+        -0.00223f,
+        -0.00197f,
+        -0.00014f,
+        0.00189f,
+        0.00295f,
+        0.00288f,
+        0.00164f,
+        -0.00026f,
+        -0.00152f,
+        -0.00197f,
+        -0.00283f,
+        -0.00435f,
+        -0.00562f,
+        -0.00587f,
+        -0.00503f,
+        -0.00393f,
+        -0.00329f,
+        -0.00291f,
+        -0.00225f,
+        -0.00120f,
+        -0.00006f,
+        0.00031f,
+        -0.00065f,
+        -0.00196f,
+        -0.00234f,
+        -0.00181f,
+        -0.00092f,
+        0.00011f,
+        0.00103f,
+        0.00125f,
+        0.00042f,
+        -0.00110f,
+        -0.00237f,
+        -0.00304f,
+        -0.00350f,
+        -0.00403f,
+        -0.00439f,
+        -0.00419f,
+        -0.00322f,
+        -0.00175f,
+        -0.00042f,
+        0.00026f,
+        0.00057f,
+        0.00099f,
+        0.00100f,
+        0.00041f,
+        0.00039f,
+        0.00139f};
+
+constexpr CSAMPLE kClick48000[] = {
+        0.01534f,
+        0.05623f,
+        0.10618f,
+        0.13596f,
+        0.13323f,
+        0.12915f,
+        0.16533f,
+        0.22630f,
+        0.26943f,
+        0.26715f,
+        0.19582f,
+        0.04604f,
+        -0.14266f,
+        -0.28995f,
+        -0.34129f,
+        -0.32696f,
+        -0.33215f,
+        -0.39098f,
+        -0.44083f,
+        -0.41410f,
+        -0.32505f,
+        -0.19452f,
+        -0.04420f,
+        0.07968f,
+        0.13807f,
+        0.14200f,
+        0.13697f,
+        0.14017f,
+        0.10844f,
+        -0.00998f,
+        -0.20339f,
+        -0.38685f,
+        -0.47964f,
+        -0.46238f,
+        -0.36563f,
+        -0.23624f,
+        -0.10653f,
+        0.01011f,
+        0.10692f,
+        0.17889f,
+        0.23127f,
+        0.27896f,
+        0.31689f,
+        0.30251f,
+        0.23580f,
+        0.18466f,
+        0.19663f,
+        0.26415f,
+        0.34964f,
+        0.41187f,
+        0.42004f,
+        0.36949f,
+        0.29331f,
+        0.24490f,
+        0.25222f,
+        0.28592f,
+        0.27035f,
+        0.18757f,
+        0.10225f,
+        0.07727f,
+        0.10667f,
+        0.14869f,
+        0.17376f,
+        0.16134f,
+        0.08241f,
+        -0.07001f,
+        -0.23485f,
+        -0.33713f,
+        -0.37946f,
+        -0.41459f,
+        -0.46094f,
+        -0.52234f,
+        -0.57817f,
+        -0.58459f,
+        -0.51238f,
+        -0.37392f,
+        -0.20807f,
+        -0.04356f,
+        0.10981f,
+        0.23755f,
+        0.30763f,
+        0.30575f,
+        0.24488f,
+        0.15134f,
+        0.05858f,
+        -0.00241f,
+        -0.02195f,
+        -0.02045f,
+        -0.03040f,
+        -0.06317f,
+        -0.09497f,
+        -0.08899f,
+        -0.02551f,
+        0.06207f,
+        0.10207f,
+        0.05498f,
+        -0.05390f,
+        -0.16271f,
+        -0.21921f,
+        -0.20327f,
+        -0.12880f,
+        -0.03603f,
+        0.02742f,
+        0.04289f,
+        0.04285f,
+        0.08079f,
+        0.15819f,
+        0.23501f,
+        0.26056f,
+        0.20848f,
+        0.10325f,
+        0.00876f,
+        -0.02254f,
+        0.00509f,
+        0.04025f,
+        0.04500f,
+        0.02840f,
+        0.01009f,
+        0.00246f,
+        0.02374f,
+        0.05983f,
+        0.05938f,
+        -0.00067f,
+        -0.08197f,
+        -0.12402f,
+        -0.10007f,
+        -0.02830f,
+        0.05780f,
+        0.12634f,
+        0.15623f,
+        0.17398f,
+        0.21555f,
+        0.26945f,
+        0.29704f,
+        0.27207f,
+        0.19491f,
+        0.08793f,
+        -0.01679f,
+        -0.09336f,
+        -0.13723f,
+        -0.16586f,
+        -0.19899f,
+        -0.23591f,
+        -0.25307f,
+        -0.22920f,
+        -0.16961f,
+        -0.10551f,
+        -0.06770f,
+        -0.06197f,
+        -0.06851f,
+        -0.06301f,
+        -0.03938f,
+        -0.01487f,
+        -0.01507f,
+        -0.05003f,
+        -0.09099f,
+        -0.10396f,
+        -0.08326f,
+        -0.05569f,
+        -0.04847f,
+        -0.06278f,
+        -0.07894f,
+        -0.07762f,
+        -0.04985f,
+        0.00664f,
+        0.07563f,
+        0.10975f,
+        0.09322f,
+        0.07214f,
+        0.07951f,
+        0.10700f,
+        0.13119f,
+        0.13475f,
+        0.10719f,
+        0.04729f,
+        -0.02576f,
+        -0.07388f,
+        -0.07271f,
+        -0.03713f,
+        0.00120f,
+        0.03576f,
+        0.07221f,
+        0.10817f,
+        0.13593f,
+        0.14808f,
+        0.13883f,
+        0.10412f,
+        0.04310f,
+        -0.03932f,
+        -0.12878f,
+        -0.19932f,
+        -0.22814f,
+        -0.23538f,
+        -0.23948f,
+        -0.22687f,
+        -0.17931f,
+        -0.10409f,
+        -0.02522f,
+        0.03756f,
+        0.07436f,
+        0.07882f,
+        0.05333f,
+        0.01917f,
+        0.00222f,
+        0.00766f,
+        0.02487f,
+        0.04022f,
+        0.04555f,
+        0.04460f,
+        0.04652f,
+        0.05254f,
+        0.05015f,
+        0.02371f,
+        -0.02616f,
+        -0.07737f,
+        -0.11019f,
+        -0.12522f,
+        -0.12464f,
+        -0.11200f,
+        -0.10214f,
+        -0.10084f,
+        -0.09437f,
+        -0.06659f,
+        -0.01692f,
+        0.03873f,
+        0.07721f,
+        0.07540f,
+        0.03103f,
+        -0.01329f,
+        -0.01665f,
+        0.01906f,
+        0.07165f,
+        0.12043f,
+        0.16104f,
+        0.20241f,
+        0.24866f,
+        0.28998f,
+        0.31528f,
+        0.32606f,
+        0.32059f,
+        0.28299f,
+        0.22281f,
+        0.16145f,
+        0.09957f,
+        0.02954f,
+        -0.04376f,
+        -0.10333f,
+        -0.13427f,
+        -0.13450f,
+        -0.11263f,
+        -0.07929f,
+        -0.04661f,
+        -0.03105f,
+        -0.02852f,
+        -0.01767f,
+        -0.00093f,
+        0.00729f,
+        0.00824f,
+        0.01441f,
+        0.03387f,
+        0.06549f,
+        0.10181f,
+        0.12890f,
+        0.13388f,
+        0.12335f,
+        0.10283f,
+        0.05709f,
+        -0.01554f,
+        -0.09408f,
+        -0.15429f,
+        -0.18039f,
+        -0.17292f,
+        -0.14784f,
+        -0.12423f,
+        -0.11114f,
+        -0.10859f,
+        -0.10940f,
+        -0.09431f,
+        -0.07347f,
+        -0.08281f,
+        -0.12316f,
+        -0.16382f,
+        -0.18598f,
+        -0.19114f,
+        -0.18586f,
+        -0.17264f,
+        -0.15081f,
+        -0.11284f,
+        -0.05297f,
+        0.00376f,
+        0.02516f,
+        0.01675f,
+        -0.00653f,
+        -0.02793f,
+        -0.03417f,
+        -0.03098f,
+        -0.03265f,
+        -0.03705f,
+        -0.02518f,
+        0.00640f,
+        0.03695f,
+        0.05685f,
+        0.06456f,
+        0.05115f,
+        0.02176f,
+        -0.00940f,
+        -0.03255f,
+        -0.04332f,
+        -0.04776f,
+        -0.05914f,
+        -0.07861f,
+        -0.08043f,
+        -0.03582f,
+        0.04641f,
+        0.11786f,
+        0.13505f,
+        0.11305f,
+        0.11355f,
+        0.15625f,
+        0.18875f,
+        0.16581f,
+        0.10259f,
+        0.03370f,
+        -0.04191f,
+        -0.11602f,
+        -0.11191f,
+        -0.00149f,
+        0.08405f,
+        0.08038f,
+        0.05064f,
+        0.05477f,
+        0.08877f,
+        0.11711f,
+        0.11088f,
+        0.05960f,
+        -0.02476f,
+        -0.09773f,
+        -0.10056f,
+        -0.03750f,
+        -0.02826f,
+        -0.13229f,
+        -0.26659f,
+        -0.31860f,
+        -0.24162f,
+        -0.06202f,
+        0.13666f,
+        0.25174f,
+        0.23457f,
+        0.14896f,
+        0.10878f,
+        0.12761f,
+        0.11783f,
+        0.05568f,
+        -0.03437f,
+        -0.12018f,
+        -0.14488f,
+        -0.07384f,
+        0.04773f,
+        0.12449f,
+        0.10423f,
+        0.02960f,
+        -0.01508f,
+        0.01482f,
+        0.10430f,
+        0.18289f,
+        0.19215f,
+        0.14309f,
+        0.09726f,
+        0.09387f,
+        0.12038f,
+        0.13664f,
+        0.10901f,
+        0.03096f,
+        -0.06275f,
+        -0.10332f,
+        -0.06181f,
+        -0.00362f,
+        0.02056f,
+        0.00856f,
+        -0.02881f,
+        -0.05731f,
+        -0.04326f,
+        0.00082f,
+        0.02708f,
+        0.01111f,
+        -0.02525f,
+        -0.06462f,
+        -0.10538f,
+        -0.11737f,
+        -0.10059f,
+        -0.08920f,
+        -0.09816f,
+        -0.12488f,
+        -0.15981f,
+        -0.18350f,
+        -0.17833f,
+        -0.14694f,
+        -0.10914f,
+        -0.07724f,
+        -0.05540f,
+        -0.03363f,
+        0.01317f,
+        0.05574f,
+        0.04479f,
+        -0.00246f,
+        -0.03815f,
+        -0.05679f,
+        -0.07863f,
+        -0.09273f,
+        -0.06389f,
+        -0.00359f,
+        0.03614f,
+        0.05118f,
+        0.06737f,
+        0.06825f,
+        0.04515f,
+        0.01680f,
+        -0.00884f,
+        -0.04699f,
+        -0.10697f,
+        -0.16692f,
+        -0.18766f,
+        -0.15173f,
+        -0.07886f,
+        -0.00374f,
+        0.03834f,
+        0.04702f,
+        0.06191f,
+        0.11226f,
+        0.17624f,
+        0.21275f,
+        0.20499f,
+        0.16421f,
+        0.10956f,
+        0.06079f,
+        0.04122f,
+        0.05331f,
+        0.06648f,
+        0.06680f,
+        0.06541f,
+        0.06256f,
+        0.04946f,
+        0.02232f,
+        -0.01271f,
+        -0.04066f,
+        -0.04490f,
+        -0.01992f,
+        0.02042f,
+        0.05524f,
+        0.07452f,
+        0.07846f,
+        0.07424f,
+        0.06943f,
+        0.05685f,
+        0.02533f,
+        -0.01570f,
+        -0.04307f,
+        -0.05037f,
+        -0.05826f,
+        -0.08430f,
+        -0.11738f,
+        -0.14149f,
+        -0.14607f,
+        -0.11467f,
+        -0.05280f,
+        0.00338f,
+        0.02911f,
+        0.03056f,
+        0.02812f,
+        0.03436f,
+        0.04658f,
+        0.05149f,
+        0.03528f,
+        0.00277f,
+        -0.01379f,
+        0.00534f,
+        0.04761f,
+        0.08218f,
+        0.07943f,
+        0.03697f,
+        -0.01511f,
+        -0.04098f,
+        -0.03062f,
+        -0.00382f,
+        0.01432f,
+        0.00921f,
+        -0.02412f,
+        -0.06350f,
+        -0.07748f,
+        -0.06067f,
+        -0.03136f,
+        -0.00957f,
+        -0.00296f,
+        -0.00391f,
+        0.00228f,
+        0.02145f,
+        0.03995f,
+        0.03893f,
+        0.01972f,
+        -0.00110f,
+        -0.00676f,
+        0.01825f,
+        0.06371f,
+        0.09090f,
+        0.07517f,
+        0.03232f,
+        -0.00177f,
+        -0.00782f,
+        0.00699f,
+        0.02280f,
+        0.01346f,
+        -0.03470f,
+        -0.08906f,
+        -0.11919f,
+        -0.11763f,
+        -0.09275f,
+        -0.06199f,
+        -0.04116f,
+        -0.03289f,
+        -0.02938f,
+        -0.02871f,
+        -0.03992f,
+        -0.06284f,
+        -0.08347f,
+        -0.09043f,
+        -0.07314f,
+        -0.03142f,
+        0.01273f,
+        0.04028f,
+        0.05481f,
+        0.06840f,
+        0.08051f,
+        0.08084f,
+        0.06932f,
+        0.05327f,
+        0.03112f,
+        0.00751f,
+        -0.00323f,
+        -0.00268f,
+        -0.00248f,
+        -0.00702f,
+        -0.01275f,
+        -0.01446f,
+        -0.00857f,
+        0.00486f,
+        0.01869f,
+        0.02324f,
+        0.02301f,
+        0.03037f,
+        0.03919f,
+        0.04344f,
+        0.04672f,
+        0.04920f,
+        0.04690f,
+        0.04111f,
+        0.03778f,
+        0.03884f,
+        0.03990f,
+        0.03902f,
+        0.03989f,
+        0.04236f,
+        0.03742f,
+        0.02175f,
+        0.00462f,
+        -0.00462f,
+        -0.00794f,
+        -0.01051f,
+        -0.01052f,
+        -0.00207f,
+        0.01504f,
+        0.03470f,
+        0.05020f,
+        0.05024f,
+        0.02781f,
+        -0.00337f,
+        -0.02908f,
+        -0.04563f,
+        -0.05615f,
+        -0.06599f,
+        -0.07839f,
+        -0.09063f,
+        -0.09483f,
+        -0.08566f,
+        -0.06745f,
+        -0.05306f,
+        -0.05488f,
+        -0.06330f,
+        -0.06316f,
+        -0.05374f,
+        -0.04241f,
+        -0.03203f,
+        -0.02298f,
+        -0.01750f,
+        -0.01674f,
+        -0.01701f,
+        -0.01662f,
+        -0.01897f,
+        -0.02069f,
+        -0.01739f,
+        -0.01216f,
+        -0.00516f,
+        0.00494f,
+        0.01499f,
+        0.01981f,
+        0.01556f,
+        0.00113f,
+        -0.01962f,
+        -0.03515f,
+        -0.03448f,
+        -0.01991f,
+        -0.00144f,
+        0.01736f,
+        0.03457f,
+        0.04667f,
+        0.05038f,
+        0.04579f,
+        0.03646f,
+        0.02535f,
+        0.01284f,
+        0.00116f,
+        -0.00252f,
+        0.00319f,
+        0.00900f,
+        0.01267f,
+        0.01602f,
+        0.01716f,
+        0.01651f,
+        0.01649f,
+        0.01726f,
+        0.01877f,
+        0.02420f,
+        0.03539f,
+        0.04534f,
+        0.04546f,
+        0.03507f,
+        0.01977f,
+        0.00806f,
+        0.00766f,
+        0.01662f,
+        0.02605f,
+        0.02799f,
+        0.01948f,
+        0.00319f,
+        -0.01369f,
+        -0.02382f,
+        -0.02737f,
+        -0.03117f,
+        -0.03850f,
+        -0.04520f,
+        -0.04464f,
+        -0.03516f,
+        -0.02290f,
+        -0.01473f,
+        -0.01147f,
+        -0.00886f,
+        -0.00353f,
+        0.00368f,
+        0.00917f,
+        0.00917f,
+        0.00430f,
+        -0.00021f,
+        -0.00037f,
+        0.00529f,
+        0.01303f,
+        0.01558f,
+        0.00939f,
+        -0.00124f,
+        -0.00835f,
+        -0.00844f,
+        -0.00434f,
+        -0.00108f,
+        -0.00244f,
+        -0.00568f,
+        -0.00669f,
+        -0.00462f,
+        -0.00032f,
+        0.00493f,
+        0.00875f,
+        0.00897f,
+        0.00648f,
+        0.00556f,
+        0.00944f,
+        0.01639f,
+        0.02178f,
+        0.02271f,
+        0.01902f,
+        0.01177f,
+        0.00398f,
+        -0.00067f,
+        0.00012f,
+        0.00631f,
+        0.01563f,
+        0.02418f,
+        0.02805f,
+        0.02673f,
+        0.02158f,
+        0.00972f,
+        -0.00910f,
+        -0.02950f,
+        -0.04748f,
+        -0.06091f,
+        -0.06662f,
+        -0.06315f,
+        -0.05348f,
+        -0.04189f,
+        -0.02922f,
+        -0.01667f,
+        -0.00927f,
+        -0.00461f,
+        0.00415f,
+        0.01252f,
+        0.01563f,
+        0.01533f,
+        0.01382f,
+        0.01084f,
+        0.00666f,
+        0.00315f,
+        -0.00010f,
+        -0.00598f,
+        -0.01299f,
+        -0.01533f,
+        -0.01227f,
+        -0.00672f,
+        -0.00194f,
+        -0.00213f,
+        -0.00902f,
+        -0.01891f,
+        -0.02543f,
+        -0.02531f,
+        -0.02075f,
+        -0.01533f,
+        -0.00991f,
+        -0.00497f,
+        -0.00186f,
+        0.00007f,
+        0.00251f,
+        0.00724f,
+        0.01485f,
+        0.02396f,
+        0.03317f,
+        0.04248f,
+        0.05081f,
+        0.05342f,
+        0.04707f,
+        0.03751f,
+        0.03127f,
+        0.02766f,
+        0.02823f,
+        0.03125f,
+        0.02912f,
+        0.01999f,
+        0.01085f,
+        0.00726f,
+        0.00602f,
+        0.00240f,
+        -0.00073f,
+        -0.00047f,
+        -0.00241f,
+        -0.00883f,
+        -0.01407f,
+        -0.01354f,
+        -0.00744f,
+        0.00073f,
+        0.00685f,
+        0.00888f,
+        0.00793f,
+        0.00681f,
+        0.00719f,
+        0.00836f,
+        0.00886f,
+        0.00872f,
+        0.00825f,
+        0.00650f,
+        0.00287f,
+        -0.00078f,
+        -0.00072f,
+        0.00433f,
+        0.00982f,
+        0.00854f,
+        -0.00064f,
+        -0.01023f,
+        -0.01435f,
+        -0.01480f,
+        -0.01404f,
+        -0.01329f,
+        -0.01367f,
+        -0.01439f,
+        -0.01388f,
+        -0.01185f,
+        -0.00995f,
+        -0.01063f,
+        -0.01482f,
+        -0.01938f,
+        -0.01844f,
+        -0.01128f,
+        -0.00376f,
+        0.00191f,
+        0.00407f,
+        0.00130f,
+        -0.00349f,
+        -0.00502f,
+        -0.00156f,
+        0.00324f,
+        0.00478f,
+        0.00253f,
+        0.00070f,
+        0.00417f,
+        0.00879f,
+        0.00814f,
+        0.00405f,
+        0.00050f,
+        -0.00275f,
+        -0.00716f,
+        -0.01228f,
+        -0.01690f,
+        -0.02089f,
+        -0.02354f,
+        -0.02289f,
+        -0.01872f,
+        -0.01258f,
+        -0.00702f,
+        -0.00432f,
+        -0.00393f,
+        -0.00362f,
+        -0.00168f,
+        0.00332f,
+        0.01148f,
+        0.01948f,
+        0.02201f,
+        0.01831f,
+        0.01231f,
+        0.00512f,
+        -0.00144f,
+        -0.00407f,
+        -0.00381f,
+        -0.00322f,
+        -0.00262f,
+        -0.00176f,
+        -0.00115f,
+        -0.00118f,
+        -0.00169f,
+        -0.00391f,
+        -0.00883f,
+        -0.01233f,
+        -0.01119f,
+        -0.00807f,
+        -0.00500f,
+        -0.00244f,
+        -0.00041f,
+        0.00205f,
+        0.00630f,
+        0.01208f,
+        0.01681f,
+        0.01841f,
+        0.01855f,
+        0.02040f,
+        0.02187f,
+        0.01930f,
+        0.01390f,
+        0.00880f,
+        0.00581f,
+        0.00549f,
+        0.00704f,
+        0.00816f,
+        0.00619f,
+        0.00019f,
+        -0.00865f,
+        -0.01681f,
+        -0.01753f,
+        -0.01210f,
+        -0.00763f,
+        -0.00684f,
+        -0.00749f,
+        -0.00764f,
+        -0.00633f,
+        -0.00298f,
+        0.00126f,
+        0.00327f,
+        0.00261f,
+        0.00315f,
+        0.00480f,
+        0.00435f,
+        0.00377f,
+        0.00450f,
+        0.00505f,
+        0.00448f,
+        0.00301f,
+        0.00069f,
+        -0.00241f,
+        -0.00500f,
+        -0.00561f,
+        -0.00515f,
+        -0.00609f,
+        -0.00941f,
+        -0.01288f,
+        -0.01382f,
+        -0.01234f,
+        -0.01055f,
+        -0.00909f,
+        -0.00710f,
+        -0.00485f,
+        -0.00406f,
+        -0.00449f,
+        -0.00293f,
+        0.00128f,
+        0.00364f,
+        0.00283f,
+        0.00009f,
+        -0.00459f,
+        -0.01031f,
+        -0.01424f,
+        -0.01433f,
+        -0.01105f,
+        -0.00606f,
+        -0.00061f,
+        0.00362f,
+        0.00512f,
+        0.00549f,
+        0.00608f,
+        0.00540f,
+        0.00337f,
+        0.00121f,
+        -0.00016f,
+        0.00002f,
+        0.00217f,
+        0.00510f,
+        0.00625f,
+        0.00434f,
+        0.00073f,
+        -0.00219f,
+        -0.00193f,
+        0.00025f,
+        0.00024f,
+        -0.00262f,
+        -0.00499f,
+        -0.00453f,
+        -0.00195f,
+        0.00085f,
+        0.00300f,
+        0.00455f,
+        0.00614f,
+        0.00833f,
+        0.00996f,
+        0.01025f,
+        0.00941f,
+        0.00668f,
+        0.00231f,
+        -0.00156f,
+        -0.00362f,
+        -0.00468f,
+        -0.00562f,
+        -0.00535f,
+        -0.00321f,
+        -0.00095f,
+        0.00067f,
+        0.00263f,
+        0.00468f,
+        0.00659f,
+        0.00814f,
+        0.00825f,
+        0.00644f,
+        0.00403f,
+        0.00272f,
+        0.00227f,
+        0.00106f,
+        -0.00098f,
+        -0.00282f,
+        -0.00482f,
+        -0.00718f,
+        -0.00878f,
+        -0.00900f,
+        -0.00816f,
+        -0.00670f,
+        -0.00458f,
+        -0.00140f,
+        0.00293f,
+        0.00743f,
+        0.01007f,
+        0.00993f,
+        0.00838f,
+        0.00607f,
+        0.00347f,
+        0.00201f,
+        0.00142f,
+        0.00002f,
+        -0.00235f,
+        -0.00409f,
+        -0.00455f,
+        -0.00517f,
+        -0.00609f,
+        -0.00532f,
+        -0.00291f,
+        -0.00074f,
+        0.00052f,
+        0.00043f,
+        -0.00048f,
+        -0.00074f,
+        0.00035f,
+        0.00228f,
+        0.00437f,
+        0.00637f,
+        0.00763f,
+        0.00725f,
+        0.00580f,
+        0.00410f,
+        0.00235f,
+        0.00117f,
+        0.00039f,
+        -0.00096f,
+        -0.00320f,
+        -0.00562f,
+        -0.00749f,
+        -0.00869f,
+        -0.00893f,
+        -0.00727f,
+        -0.00374f,
+        -0.00018f,
+        0.00195f,
+        0.00240f,
+        0.00152f,
+        0.00035f,
+        0.00019f,
+        0.00134f,
+        0.00276f,
+        0.00330f,
+        0.00303f,
+        0.00239f,
+        0.00140f,
+        0.00093f,
+        0.00153f,
+        0.00233f,
+        0.00278f,
+        0.00286f,
+        0.00234f,
+        0.00117f,
+        -0.00019f,
+        -0.00134f,
+        -0.00227f,
+        -0.00279f,
+        -0.00229f,
+        -0.00102f,
+        0.00022f,
+        0.00129f,
+        0.00168f,
+        0.00108f,
+        0.00012f,
+        -0.00039f,
+        -0.00015f,
+        0.00058f,
+        0.00136f,
+        0.00195f,
+        0.00269f,
+        0.00401f,
+        0.00512f,
+        0.00550f,
+        0.00529f,
+        0.00420f,
+        0.00223f,
+        0.00045f,
+        -0.00013f,
+        0.00012f,
+        -0.00009f,
+        -0.00120f,
+        -0.00221f,
+        -0.00197f,
+        -0.00030f,
+        0.00155f,
+        0.00268f,
+        0.00290f,
+        0.00215f,
+        0.00068f,
+        -0.00080f,
+        -0.00167f,
+        -0.00220f,
+        -0.00310f,
+        -0.00448f,
+        -0.00562f,
+        -0.00585f,
+        -0.00515f,
+        -0.00418f,
+        -0.00349f,
+        -0.00306f,
+        -0.00256f,
+        -0.00178f,
+        -0.00078f,
+        0.00005f,
+        0.00011f,
+        -0.00081f,
+        -0.00198f,
+        -0.00233f,
+        -0.00187f,
+        -0.00110f,
+        -0.00018f,
+        0.00070f,
+        0.00115f,
+        0.00086f,
+        -0.00018f,
+        -0.00150f,
+        -0.00252f,
+        -0.00311f,
+        -0.00354f,
+        -0.00402f,
+        -0.00436f,
+        -0.00423f,
+        -0.00347f,
+        -0.00225f,
+        -0.00098f,
+        -0.00008f,
+        0.00039f,
+        0.00071f,
+        0.00099f,
+        0.00090f,
+        0.00041f,
+        0.00040f,
+        0.00132f,
+        0.00021f};
+
+constexpr CSAMPLE kClick96000[] = {
+        0.01534f,
+        0.03123f,
+        0.05623f,
+        0.08369f,
+        0.10618f,
+        0.12552f,
+        0.13596f,
+        0.13482f,
+        0.13323f,
+        0.13034f,
+        0.12915f,
+        0.14724f,
+        0.16533f,
+        0.19519f,
+        0.22630f,
+        0.24937f,
+        0.26943f,
+        0.27444f,
+        0.26715f,
+        0.24443f,
+        0.19582f,
+        0.13858f,
+        0.04604f,
+        -0.04657f,
+        -0.14266f,
+        -0.23875f,
+        -0.28995f,
+        -0.33277f,
+        -0.34129f,
+        -0.33259f,
+        -0.32696f,
+        -0.32454f,
+        -0.33215f,
+        -0.36189f,
+        -0.39098f,
+        -0.41591f,
+        -0.44083f,
+        -0.42828f,
+        -0.41410f,
+        -0.37329f,
+        -0.32505f,
+        -0.26398f,
+        -0.19452f,
+        -0.12165f,
+        -0.04420f,
+        0.02703f,
+        0.07968f,
+        0.12909f,
+        0.13807f,
+        0.14704f,
+        0.14200f,
+        0.13536f,
+        0.13697f,
+        0.14179f,
+        0.14017f,
+        0.13315f,
+        0.10844f,
+        0.05316f,
+        -0.00998f,
+        -0.10672f,
+        -0.20339f,
+        -0.29512f,
+        -0.38685f,
+        -0.43730f,
+        -0.47964f,
+        -0.48149f,
+        -0.46238f,
+        -0.42423f,
+        -0.36563f,
+        -0.30417f,
+        -0.23624f,
+        -0.16901f,
+        -0.10653f,
+        -0.04405f,
+        0.01011f,
+        0.06385f,
+        0.10692f,
+        0.14688f,
+        0.17889f,
+        0.20556f,
+        0.23127f,
+        0.25567f,
+        0.27896f,
+        0.29883f,
+        0.31689f,
+        0.30970f,
+        0.30251f,
+        0.27067f,
+        0.23580f,
+        0.20868f,
+        0.18466f,
+        0.18160f,
+        0.19663f,
+        0.22157f,
+        0.26415f,
+        0.30678f,
+        0.34964f,
+        0.39237f,
+        0.41187f,
+        0.43138f,
+        0.42004f,
+        0.40235f,
+        0.36949f,
+        0.32855f,
+        0.29331f,
+        0.26436f,
+        0.24490f,
+        0.24770f,
+        0.25222f,
+        0.26907f,
+        0.28592f,
+        0.27883f,
+        0.27035f,
+        0.23328f,
+        0.18757f,
+        0.14413f,
+        0.10225f,
+        0.07758f,
+        0.07727f,
+        0.08271f,
+        0.10667f,
+        0.13028f,
+        0.14869f,
+        0.16710f,
+        0.17376f,
+        0.17888f,
+        0.16134f,
+        0.13440f,
+        0.08241f,
+        0.00818f,
+        -0.07001f,
+        -0.15545f,
+        -0.23485f,
+        -0.28599f,
+        -0.33713f,
+        -0.35831f,
+        -0.37946f,
+        -0.39737f,
+        -0.41459f,
+        -0.43648f,
+        -0.46094f,
+        -0.48938f,
+        -0.52234f,
+        -0.55302f,
+        -0.57817f,
+        -0.59880f,
+        -0.58459f,
+        -0.57038f,
+        -0.51238f,
+        -0.45147f,
+        -0.37392f,
+        -0.29115f,
+        -0.20807f,
+        -0.12479f,
+        -0.04356f,
+        0.03469f,
+        0.10981f,
+        0.17447f,
+        0.23755f,
+        0.27259f,
+        0.30763f,
+        0.30905f,
+        0.30575f,
+        0.28011f,
+        0.24488f,
+        0.20173f,
+        0.15134f,
+        0.10301f,
+        0.05858f,
+        0.01818f,
+        -0.00241f,
+        -0.02301f,
+        -0.02195f,
+        -0.02072f,
+        -0.02045f,
+        -0.02041f,
+        -0.03040f,
+        -0.04607f,
+        -0.06317f,
+        -0.08193f,
+        -0.09497f,
+        -0.09362f,
+        -0.08899f,
+        -0.05725f,
+        -0.02551f,
+        0.01785f,
+        0.06207f,
+        0.08547f,
+        0.10207f,
+        0.08929f,
+        0.05498f,
+        0.00916f,
+        -0.05390f,
+        -0.11380f,
+        -0.16271f,
+        -0.20978f,
+        -0.21921f,
+        -0.22863f,
+        -0.20327f,
+        -0.17271f,
+        -0.12880f,
+        -0.07897f,
+        -0.03603f,
+        0.00046f,
+        0.02742f,
+        0.03584f,
+        0.04289f,
+        0.04287f,
+        0.04285f,
+        0.06168f,
+        0.08079f,
+        0.11742f,
+        0.15819f,
+        0.19713f,
+        0.23501f,
+        0.25719f,
+        0.26056f,
+        0.25113f,
+        0.20848f,
+        0.16399f,
+        0.10325f,
+        0.04250f,
+        0.00876f,
+        -0.02276f,
+        -0.02254f,
+        -0.01159f,
+        0.00509f,
+        0.02608f,
+        0.04025f,
+        0.04392f,
+        0.04500f,
+        0.03672f,
+        0.02840f,
+        0.01925f,
+        0.01009f,
+        0.00588f,
+        0.00246f,
+        0.01048f,
+        0.02374f,
+        0.04022f,
+        0.05983f,
+        0.06953f,
+        0.05938f,
+        0.04388f,
+        -0.00067f,
+        -0.04522f,
+        -0.08197f,
+        -0.11854f,
+        -0.12402f,
+        -0.12181f,
+        -0.10007f,
+        -0.06661f,
+        -0.02830f,
+        0.01598f,
+        0.05780f,
+        0.09303f,
+        0.12634f,
+        0.14128f,
+        0.15623f,
+        0.16536f,
+        0.17398f,
+        0.19295f,
+        0.21555f,
+        0.24129f,
+        0.26945f,
+        0.28960f,
+        0.29704f,
+        0.29756f,
+        0.27207f,
+        0.24574f,
+        0.19491f,
+        0.14408f,
+        0.08793f,
+        0.03089f,
+        -0.01679f,
+        -0.06005f,
+        -0.09336f,
+        -0.11681f,
+        -0.13723f,
+        -0.15136f,
+        -0.16586f,
+        -0.18243f,
+        -0.19899f,
+        -0.21742f,
+        -0.23591f,
+        -0.24562f,
+        -0.25307f,
+        -0.24571f,
+        -0.22920f,
+        -0.20456f,
+        -0.16961f,
+        -0.13587f,
+        -0.10551f,
+        -0.07700f,
+        -0.06770f,
+        -0.05840f,
+        -0.06197f,
+        -0.06680f,
+        -0.06851f,
+        -0.06909f,
+        -0.06301f,
+        -0.05162f,
+        -0.03938f,
+        -0.02576f,
+        -0.01487f,
+        -0.01474f,
+        -0.01507f,
+        -0.03255f,
+        -0.05003f,
+        -0.07026f,
+        -0.09099f,
+        -0.10026f,
+        -0.10396f,
+        -0.09834f,
+        -0.08326f,
+        -0.06881f,
+        -0.05569f,
+        -0.04494f,
+        -0.04847f,
+        -0.05201f,
+        -0.06278f,
+        -0.07381f,
+        -0.07894f,
+        -0.08248f,
+        -0.07762f,
+        -0.06744f,
+        -0.04985f,
+        -0.02264f,
+        0.00664f,
+        0.04187f,
+        0.07563f,
+        0.09269f,
+        0.10975f,
+        0.10277f,
+        0.09322f,
+        0.08284f,
+        0.07214f,
+        0.07165f,
+        0.07951f,
+        0.09056f,
+        0.10700f,
+        0.12200f,
+        0.13119f,
+        0.14010f,
+        0.13475f,
+        0.12940f,
+        0.10719f,
+        0.08183f,
+        0.04729f,
+        0.00813f,
+        -0.02576f,
+        -0.05414f,
+        -0.07388f,
+        -0.07454f,
+        -0.07271f,
+        -0.05492f,
+        -0.03713f,
+        -0.01800f,
+        0.00120f,
+        0.01871f,
+        0.03576f,
+        0.05370f,
+        0.07221f,
+        0.09041f,
+        0.10817f,
+        0.12438f,
+        0.13593f,
+        0.14672f,
+        0.14808f,
+        0.14944f,
+        0.13883f,
+        0.12684f,
+        0.10412f,
+        0.07722f,
+        0.04310f,
+        0.00290f,
+        -0.03932f,
+        -0.08503f,
+        -0.12878f,
+        -0.16419f,
+        -0.19932f,
+        -0.21373f,
+        -0.22814f,
+        -0.23272f,
+        -0.23538f,
+        -0.23756f,
+        -0.23948f,
+        -0.23604f,
+        -0.22687f,
+        -0.21086f,
+        -0.17931f,
+        -0.14639f,
+        -0.10409f,
+        -0.06179f,
+        -0.02522f,
+        0.01106f,
+        0.03756f,
+        0.06122f,
+        0.07436f,
+        0.08041f,
+        0.07882f,
+        0.06672f,
+        0.05333f,
+        0.03595f,
+        0.01917f,
+        0.01070f,
+        0.00222f,
+        0.00429f,
+        0.00766f,
+        0.01538f,
+        0.02487f,
+        0.03309f,
+        0.04022f,
+        0.04498f,
+        0.04555f,
+        0.04580f,
+        0.04460f,
+        0.04343f,
+        0.04652f,
+        0.04961f,
+        0.05254f,
+        0.05543f,
+        0.05015f,
+        0.04051f,
+        0.02371f,
+        -0.00100f,
+        -0.02616f,
+        -0.05236f,
+        -0.07737f,
+        -0.09378f,
+        -0.11019f,
+        -0.11796f,
+        -0.12522f,
+        -0.12592f,
+        -0.12464f,
+        -0.11961f,
+        -0.11200f,
+        -0.10596f,
+        -0.10214f,
+        -0.09954f,
+        -0.10084f,
+        -0.10162f,
+        -0.09437f,
+        -0.08711f,
+        -0.06659f,
+        -0.04431f,
+        -0.01692f,
+        0.01260f,
+        0.03873f,
+        0.06184f,
+        0.07721f,
+        0.07836f,
+        0.07540f,
+        0.05322f,
+        0.03103f,
+        0.00887f,
+        -0.01329f,
+        -0.01697f,
+        -0.01665f,
+        -0.00258f,
+        0.01906f,
+        0.04367f,
+        0.07165f,
+        0.09801f,
+        0.12043f,
+        0.14242f,
+        0.16104f,
+        0.17966f,
+        0.20241f,
+        0.22542f,
+        0.24866f,
+        0.27197f,
+        0.28998f,
+        0.30423f,
+        0.31528f,
+        0.32167f,
+        0.32606f,
+        0.32377f,
+        0.32059f,
+        0.30179f,
+        0.28299f,
+        0.25364f,
+        0.22281f,
+        0.19211f,
+        0.16145f,
+        0.13060f,
+        0.09957f,
+        0.06649f,
+        0.02954f,
+        -0.00733f,
+        -0.04376f,
+        -0.08020f,
+        -0.10333f,
+        -0.12635f,
+        -0.13427f,
+        -0.13876f,
+        -0.13450f,
+        -0.12528f,
+        -0.11263f,
+        -0.09599f,
+        -0.07929f,
+        -0.06246f,
+        -0.04661f,
+        -0.03883f,
+        -0.03105f,
+        -0.02955f,
+        -0.02852f,
+        -0.02371f,
+        -0.01767f,
+        -0.00993f,
+        -0.00093f,
+        0.00527f,
+        0.00729f,
+        0.00875f,
+        0.00824f,
+        0.00805f,
+        0.01441f,
+        0.02078f,
+        0.03387f,
+        0.04797f,
+        0.06549f,
+        0.08452f,
+        0.10181f,
+        0.11747f,
+        0.12890f,
+        0.13208f,
+        0.13388f,
+        0.12862f,
+        0.12335f,
+        0.11312f,
+        0.10283f,
+        0.08129f,
+        0.05709f,
+        0.02351f,
+        -0.01554f,
+        -0.05472f,
+        -0.09408f,
+        -0.12941f,
+        -0.15429f,
+        -0.17700f,
+        -0.18039f,
+        -0.18377f,
+        -0.17292f,
+        -0.16090f,
+        -0.14784f,
+        -0.13443f,
+        -0.12423f,
+        -0.11645f,
+        -0.11114f,
+        -0.10964f,
+        -0.10859f,
+        -0.10916f,
+        -0.10940f,
+        -0.10186f,
+        -0.09431f,
+        -0.08410f,
+        -0.07347f,
+        -0.07529f,
+        -0.08281f,
+        -0.09887f,
+        -0.12316f,
+        -0.14547f,
+        -0.16382f,
+        -0.18022f,
+        -0.18598f,
+        -0.19174f,
+        -0.19114f,
+        -0.19041f,
+        -0.18586f,
+        -0.18038f,
+        -0.17264f,
+        -0.16355f,
+        -0.15081f,
+        -0.13355f,
+        -0.11284f,
+        -0.08283f,
+        -0.05297f,
+        -0.02461f,
+        0.00376f,
+        0.01522f,
+        0.02516f,
+        0.02306f,
+        0.01675f,
+        0.00659f,
+        -0.00653f,
+        -0.01830f,
+        -0.02793f,
+        -0.03529f,
+        -0.03417f,
+        -0.03302f,
+        -0.03098f,
+        -0.02893f,
+        -0.03265f,
+        -0.03733f,
+        -0.03705f,
+        -0.03443f,
+        -0.02518f,
+        -0.00937f,
+        0.00640f,
+        0.02210f,
+        0.03695f,
+        0.04690f,
+        0.05685f,
+        0.06079f,
+        0.06456f,
+        0.05905f,
+        0.05115f,
+        0.03806f,
+        0.02176f,
+        0.00591f,
+        -0.00940f,
+        -0.02315f,
+        -0.03255f,
+        -0.04131f,
+        -0.04332f,
+        -0.04533f,
+        -0.04776f,
+        -0.05023f,
+        -0.05914f,
+        -0.07037f,
+        -0.07861f,
+        -0.08447f,
+        -0.08043f,
+        -0.06026f,
+        -0.03582f,
+        0.00537f,
+        0.04641f,
+        0.08214f,
+        0.11786f,
+        0.12866f,
+        0.13505f,
+        0.12745f,
+        0.11305f,
+        0.10836f,
+        0.11355f,
+        0.12655f,
+        0.15625f,
+        0.18260f,
+        0.18875f,
+        0.19490f,
+        0.16581f,
+        0.13546f,
+        0.10259f,
+        0.06904f,
+        0.03370f,
+        -0.00280f,
+        -0.04191f,
+        -0.08442f,
+        -0.11602f,
+        -0.11620f,
+        -0.11191f,
+        -0.05670f,
+        -0.00149f,
+        0.04191f,
+        0.08405f,
+        0.08916f,
+        0.08038f,
+        0.06728f,
+        0.05064f,
+        0.04417f,
+        0.05477f,
+        0.06746f,
+        0.08877f,
+        0.10979f,
+        0.11711f,
+        0.12442f,
+        0.11088f,
+        0.09344f,
+        0.05960f,
+        0.01753f,
+        -0.02476f,
+        -0.06729f,
+        -0.09773f,
+        -0.10153f,
+        -0.10056f,
+        -0.06903f,
+        -0.03750f,
+        -0.03231f,
+        -0.02826f,
+        -0.07340f,
+        -0.13229f,
+        -0.19741f,
+        -0.26659f,
+        -0.30990f,
+        -0.31860f,
+        -0.30837f,
+        -0.24162f,
+        -0.17168f,
+        -0.06202f,
+        0.04764f,
+        0.13666f,
+        0.22331f,
+        0.25174f,
+        0.25756f,
+        0.23457f,
+        0.18736f,
+        0.14896f,
+        0.12577f,
+        0.10878f,
+        0.11829f,
+        0.12761f,
+        0.12272f,
+        0.11783f,
+        0.08909f,
+        0.05568f,
+        0.01304f,
+        -0.03437f,
+        -0.07885f,
+        -0.12018f,
+        -0.14795f,
+        -0.14488f,
+        -0.13443f,
+        -0.07384f,
+        -0.01325f,
+        0.04773f,
+        0.10873f,
+        0.12449f,
+        0.12708f,
+        0.10423f,
+        0.06426f,
+        0.02960f,
+        0.00222f,
+        -0.01508f,
+        -0.00116f,
+        0.01482f,
+        0.05956f,
+        0.10430f,
+        0.14391f,
+        0.18289f,
+        0.19326f,
+        0.19215f,
+        0.17468f,
+        0.14309f,
+        0.11609f,
+        0.09726f,
+        0.08373f,
+        0.09387f,
+        0.10406f,
+        0.12038f,
+        0.13670f,
+        0.13664f,
+        0.13321f,
+        0.10901f,
+        0.07374f,
+        0.03096f,
+        -0.02009f,
+        -0.06275f,
+        -0.08569f,
+        -0.10332f,
+        -0.08256f,
+        -0.06181f,
+        -0.03295f,
+        -0.00362f,
+        0.01073f,
+        0.02056f,
+        0.01863f,
+        0.00856f,
+        -0.00656f,
+        -0.02881f,
+        -0.04800f,
+        -0.05731f,
+        -0.06476f,
+        -0.04326f,
+        -0.02177f,
+        0.00082f,
+        0.02354f,
+        0.02708f,
+        0.02266f,
+        0.01111f,
+        -0.00676f,
+        -0.02525f,
+        -0.04487f,
+        -0.06462f,
+        -0.08500f,
+        -0.10538f,
+        -0.11138f,
+        -0.11737f,
+        -0.11038f,
+        -0.10059f,
+        -0.09401f,
+        -0.08920f,
+        -0.09031f,
+        -0.09816f,
+        -0.10849f,
+        -0.12488f,
+        -0.14148f,
+        -0.15981f,
+        -0.17813f,
+        -0.18350f,
+        -0.18800f,
+        -0.17833f,
+        -0.16420f,
+        -0.14694f,
+        -0.12745f,
+        -0.10914f,
+        -0.09254f,
+        -0.07724f,
+        -0.06632f,
+        -0.05540f,
+        -0.04451f,
+        -0.03363f,
+        -0.01106f,
+        0.01317f,
+        0.03497f,
+        0.05574f,
+        0.05848f,
+        0.04479f,
+        0.02599f,
+        -0.00246f,
+        -0.02784f,
+        -0.03815f,
+        -0.04845f,
+        -0.05679f,
+        -0.06512f,
+        -0.07863f,
+        -0.09331f,
+        -0.09273f,
+        -0.08351f,
+        -0.06389f,
+        -0.03215f,
+        -0.00359f,
+        0.01698f,
+        0.03614f,
+        0.04366f,
+        0.05118f,
+        0.05926f,
+        0.06737f,
+        0.06889f,
+        0.06825f,
+        0.05962f,
+        0.04515f,
+        0.03085f,
+        0.01680f,
+        0.00321f,
+        -0.00884f,
+        -0.02151f,
+        -0.04699f,
+        -0.07248f,
+        -0.10697f,
+        -0.14281f,
+        -0.16692f,
+        -0.18584f,
+        -0.18766f,
+        -0.17345f,
+        -0.15173f,
+        -0.11539f,
+        -0.07886f,
+        -0.04130f,
+        -0.00374f,
+        0.01742f,
+        0.03834f,
+        0.04443f,
+        0.04702f,
+        0.05337f,
+        0.06191f,
+        0.08086f,
+        0.11226f,
+        0.14392f,
+        0.17624f,
+        0.20598f,
+        0.21275f,
+        0.21953f,
+        0.20499f,
+        0.18870f,
+        0.16421f,
+        0.13696f,
+        0.10956f,
+        0.08207f,
+        0.06079f,
+        0.04908f,
+        0.04122f,
+        0.04725f,
+        0.05331f,
+        0.05990f,
+        0.06648f,
+        0.06711f,
+        0.06680f,
+        0.06618f,
+        0.06541f,
+        0.06420f,
+        0.06256f,
+        0.05847f,
+        0.04946f,
+        0.03922f,
+        0.02232f,
+        0.00543f,
+        -0.01271f,
+        -0.03088f,
+        -0.04066f,
+        -0.04836f,
+        -0.04490f,
+        -0.03474f,
+        -0.01992f,
+        0.00062f,
+        0.02042f,
+        0.03821f,
+        0.05524f,
+        0.06488f,
+        0.07452f,
+        0.07682f,
+        0.07846f,
+        0.07691f,
+        0.07424f,
+        0.07176f,
+        0.06943f,
+        0.06489f,
+        0.05685f,
+        0.04613f,
+        0.02533f,
+        0.00454f,
+        -0.01570f,
+        -0.03594f,
+        -0.04307f,
+        -0.04801f,
+        -0.05037f,
+        -0.05153f,
+        -0.05826f,
+        -0.07052f,
+        -0.08430f,
+        -0.10120f,
+        -0.11738f,
+        -0.12944f,
+        -0.14149f,
+        -0.14392f,
+        -0.14607f,
+        -0.13241f,
+        -0.11467f,
+        -0.08685f,
+        -0.05280f,
+        -0.02240f,
+        0.00338f,
+        0.02376f,
+        0.02911f,
+        0.03370f,
+        0.03056f,
+        0.02742f,
+        0.02812f,
+        0.02919f,
+        0.03436f,
+        0.04101f,
+        0.04658f,
+        0.05129f,
+        0.05149f,
+        0.04432f,
+        0.03528f,
+        0.01892f,
+        0.00277f,
+        -0.00551f,
+        -0.01379f,
+        -0.00568f,
+        0.00534f,
+        0.02449f,
+        0.04761f,
+        0.06685f,
+        0.08218f,
+        0.08942f,
+        0.07943f,
+        0.06665f,
+        0.03697f,
+        0.00729f,
+        -0.01511f,
+        -0.03726f,
+        -0.04098f,
+        -0.03975f,
+        -0.03062f,
+        -0.01647f,
+        -0.00382f,
+        0.00688f,
+        0.01432f,
+        0.01236f,
+        0.00921f,
+        -0.00745f,
+        -0.02412f,
+        -0.04365f,
+        -0.06350f,
+        -0.07252f,
+        -0.07748f,
+        -0.07295f,
+        -0.06067f,
+        -0.04710f,
+        -0.03136f,
+        -0.01722f,
+        -0.00957f,
+        -0.00209f,
+        -0.00296f,
+        -0.00384f,
+        -0.00391f,
+        -0.00384f,
+        0.00228f,
+        0.01143f,
+        0.02145f,
+        0.03238f,
+        0.03995f,
+        0.04010f,
+        0.03893f,
+        0.02933f,
+        0.01972f,
+        0.00933f,
+        -0.00110f,
+        -0.00486f,
+        -0.00676f,
+        0.00219f,
+        0.01825f,
+        0.03830f,
+        0.06371f,
+        0.08439f,
+        0.09090f,
+        0.09544f,
+        0.07517f,
+        0.05489f,
+        0.03232f,
+        0.00949f,
+        -0.00177f,
+        -0.00854f,
+        -0.00782f,
+        -0.00082f,
+        0.00699f,
+        0.01620f,
+        0.02280f,
+        0.01826f,
+        0.01346f,
+        -0.01062f,
+        -0.03470f,
+        -0.06160f,
+        -0.08906f,
+        -0.10667f,
+        -0.11919f,
+        -0.12306f,
+        -0.11763f,
+        -0.10892f,
+        -0.09275f,
+        -0.07676f,
+        -0.06199f,
+        -0.04723f,
+        -0.04116f,
+        -0.03554f,
+        -0.03289f,
+        -0.03111f,
+        -0.02938f,
+        -0.02768f,
+        -0.02871f,
+        -0.03349f,
+        -0.03992f,
+        -0.05142f,
+        -0.06284f,
+        -0.07316f,
+        -0.08347f,
+        -0.08734f,
+        -0.09043f,
+        -0.08375f,
+        -0.07314f,
+        -0.05538f,
+        -0.03142f,
+        -0.00846f,
+        0.01273f,
+        0.03163f,
+        0.04028f,
+        0.04891f,
+        0.05481f,
+        0.06071f,
+        0.06840f,
+        0.07647f,
+        0.08051f,
+        0.08241f,
+        0.08084f,
+        0.07544f,
+        0.06932f,
+        0.06149f,
+        0.05327f,
+        0.04220f,
+        0.03112f,
+        0.01934f,
+        0.00751f,
+        0.00130f,
+        -0.00323f,
+        -0.00419f,
+        -0.00268f,
+        -0.00199f,
+        -0.00248f,
+        -0.00365f,
+        -0.00702f,
+        -0.01034f,
+        -0.01275f,
+        -0.01517f,
+        -0.01446f,
+        -0.01335f,
+        -0.00857f,
+        -0.00226f,
+        0.00486f,
+        0.01272f,
+        0.01869f,
+        0.02120f,
+        0.02324f,
+        0.02312f,
+        0.02301f,
+        0.02669f,
+        0.03037f,
+        0.03471f,
+        0.03919f,
+        0.04182f,
+        0.04344f,
+        0.04507f,
+        0.04672f,
+        0.04818f,
+        0.04920f,
+        0.04977f,
+        0.04690f,
+        0.04404f,
+        0.04111f,
+        0.03817f,
+        0.03778f,
+        0.03820f,
+        0.03884f,
+        0.03964f,
+        0.03990f,
+        0.03935f,
+        0.03902f,
+        0.03943f,
+        0.03989f,
+        0.04112f,
+        0.04236f,
+        0.04013f,
+        0.03742f,
+        0.03049f,
+        0.02175f,
+        0.01313f,
+        0.00462f,
+        -0.00189f,
+        -0.00462f,
+        -0.00703f,
+        -0.00794f,
+        -0.00885f,
+        -0.01051f,
+        -0.01217f,
+        -0.01052f,
+        -0.00811f,
+        -0.00207f,
+        0.00602f,
+        0.01504f,
+        0.02514f,
+        0.03470f,
+        0.04289f,
+        0.05020f,
+        0.05022f,
+        0.05024f,
+        0.03943f,
+        0.02781f,
+        0.01278f,
+        -0.00337f,
+        -0.01711f,
+        -0.02908f,
+        -0.03894f,
+        -0.04563f,
+        -0.05179f,
+        -0.05615f,
+        -0.06056f,
+        -0.06599f,
+        -0.07142f,
+        -0.07839f,
+        -0.08558f,
+        -0.09063f,
+        -0.09472f,
+        -0.09483f,
+        -0.09120f,
+        -0.08566f,
+        -0.07639f,
+        -0.06745f,
+        -0.06026f,
+        -0.05306f,
+        -0.05392f,
+        -0.05488f,
+        -0.05875f,
+        -0.06330f,
+        -0.06427f,
+        -0.06316f,
+        -0.05980f,
+        -0.05374f,
+        -0.04786f,
+        -0.04241f,
+        -0.03702f,
+        -0.03203f,
+        -0.02705f,
+        -0.02298f,
+        -0.01899f,
+        -0.01750f,
+        -0.01686f,
+        -0.01674f,
+        -0.01699f,
+        -0.01701f,
+        -0.01664f,
+        -0.01662f,
+        -0.01780f,
+        -0.01897f,
+        -0.01983f,
+        -0.02069f,
+        -0.01922f,
+        -0.01739f,
+        -0.01492f,
+        -0.01216f,
+        -0.00890f,
+        -0.00516f,
+        -0.00076f,
+        0.00494f,
+        0.01046f,
+        0.01499f,
+        0.01951f,
+        0.01981f,
+        0.02001f,
+        0.01556f,
+        0.00997f,
+        0.00113f,
+        -0.00965f,
+        -0.01962f,
+        -0.02861f,
+        -0.03515f,
+        -0.03516f,
+        -0.03448f,
+        -0.02720f,
+        -0.01991f,
+        -0.01076f,
+        -0.00144f,
+        0.00795f,
+        0.01736f,
+        0.02619f,
+        0.03457f,
+        0.04165f,
+        0.04667f,
+        0.05059f,
+        0.05038f,
+        0.05003f,
+        0.04579f,
+        0.04156f,
+        0.03646f,
+        0.03121f,
+        0.02535f,
+        0.01919f,
+        0.01284f,
+        0.00629f,
+        0.00116f,
+        -0.00106f,
+        -0.00252f,
+        0.00034f,
+        0.00319f,
+        0.00610f,
+        0.00900f,
+        0.01096f,
+        0.01267f,
+        0.01435f,
+        0.01602f,
+        0.01701f,
+        0.01716f,
+        0.01711f,
+        0.01651f,
+        0.01601f,
+        0.01649f,
+        0.01698f,
+        0.01726f,
+        0.01753f,
+        0.01877f,
+        0.02036f,
+        0.02420f,
+        0.02981f,
+        0.03539f,
+        0.04091f,
+        0.04534f,
+        0.04547f,
+        0.04546f,
+        0.04027f,
+        0.03507f,
+        0.02762f,
+        0.01977f,
+        0.01352f,
+        0.00806f,
+        0.00608f,
+        0.00766f,
+        0.01064f,
+        0.01662f,
+        0.02229f,
+        0.02605f,
+        0.02982f,
+        0.02799f,
+        0.02595f,
+        0.01948f,
+        0.01182f,
+        0.00319f,
+        -0.00605f,
+        -0.01369f,
+        -0.01924f,
+        -0.02382f,
+        -0.02559f,
+        -0.02737f,
+        -0.02927f,
+        -0.03117f,
+        -0.03474f,
+        -0.03850f,
+        -0.04191f,
+        -0.04520f,
+        -0.04596f,
+        -0.04464f,
+        -0.04147f,
+        -0.03516f,
+        -0.02891f,
+        -0.02290f,
+        -0.01697f,
+        -0.01473f,
+        -0.01249f,
+        -0.01147f,
+        -0.01067f,
+        -0.00886f,
+        -0.00654f,
+        -0.00353f,
+        0.00020f,
+        0.00368f,
+        0.00662f,
+        0.00917f,
+        0.00917f,
+        0.00917f,
+        0.00679f,
+        0.00430f,
+        0.00202f,
+        -0.00021f,
+        -0.00082f,
+        -0.00037f,
+        0.00151f,
+        0.00529f,
+        0.00911f,
+        0.01303f,
+        0.01660f,
+        0.01558f,
+        0.01457f,
+        0.00939f,
+        0.00372f,
+        -0.00124f,
+        -0.00593f,
+        -0.00835f,
+        -0.00888f,
+        -0.00844f,
+        -0.00635f,
+        -0.00434f,
+        -0.00269f,
+        -0.00108f,
+        -0.00176f,
+        -0.00244f,
+        -0.00397f,
+        -0.00568f,
+        -0.00643f,
+        -0.00669f,
+        -0.00610f,
+        -0.00462f,
+        -0.00282f,
+        -0.00032f,
+        0.00222f,
+        0.00493f,
+        0.00765f,
+        0.00875f,
+        0.00977f,
+        0.00897f,
+        0.00764f,
+        0.00648f,
+        0.00544f,
+        0.00556f,
+        0.00728f,
+        0.00944f,
+        0.01294f,
+        0.01639f,
+        0.01909f,
+        0.02178f,
+        0.02238f,
+        0.02271f,
+        0.02123f,
+        0.01902f,
+        0.01582f,
+        0.01177f,
+        0.00780f,
+        0.00398f,
+        0.00061f,
+        -0.00067f,
+        -0.00194f,
+        0.00012f,
+        0.00218f,
+        0.00631f,
+        0.01087f,
+        0.01563f,
+        0.02050f,
+        0.02418f,
+        0.02655f,
+        0.02805f,
+        0.02751f,
+        0.02673f,
+        0.02415f,
+        0.02158f,
+        0.01575f,
+        0.00972f,
+        0.00075f,
+        -0.00910f,
+        -0.01921f,
+        -0.02950f,
+        -0.03903f,
+        -0.04748f,
+        -0.05526f,
+        -0.06091f,
+        -0.06624f,
+        -0.06662f,
+        -0.06700f,
+        -0.06315f,
+        -0.05874f,
+        -0.05348f,
+        -0.04787f,
+        -0.04189f,
+        -0.03560f,
+        -0.02922f,
+        -0.02270f,
+        -0.01667f,
+        -0.01297f,
+        -0.00927f,
+        -0.00694f,
+        -0.00461f,
+        -0.00043f,
+        0.00415f,
+        0.00842f,
+        0.01252f,
+        0.01500f,
+        0.01563f,
+        0.01591f,
+        0.01533f,
+        0.01471f,
+        0.01382f,
+        0.01294f,
+        0.01084f,
+        0.00866f,
+        0.00666f,
+        0.00473f,
+        0.00315f,
+        0.00184f,
+        -0.00010f,
+        -0.00296f,
+        -0.00598f,
+        -0.00955f,
+        -0.01299f,
+        -0.01416f,
+        -0.01533f,
+        -0.01398f,
+        -0.01227f,
+        -0.00969f,
+        -0.00672f,
+        -0.00415f,
+        -0.00194f,
+        -0.00092f,
+        -0.00213f,
+        -0.00398f,
+        -0.00902f,
+        -0.01405f,
+        -0.01891f,
+        -0.02377f,
+        -0.02543f,
+        -0.02635f,
+        -0.02531f,
+        -0.02316f,
+        -0.02075f,
+        -0.01804f,
+        -0.01533f,
+        -0.01261f,
+        -0.00991f,
+        -0.00744f,
+        -0.00497f,
+        -0.00338f,
+        -0.00186f,
+        -0.00082f,
+        0.00007f,
+        0.00120f,
+        0.00251f,
+        0.00443f,
+        0.00724f,
+        0.01042f,
+        0.01485f,
+        0.01930f,
+        0.02396f,
+        0.02861f,
+        0.03317f,
+        0.03772f,
+        0.04248f,
+        0.04733f,
+        0.05081f,
+        0.05300f,
+        0.05342f,
+        0.05039f,
+        0.04707f,
+        0.04229f,
+        0.03751f,
+        0.03438f,
+        0.03127f,
+        0.02933f,
+        0.02766f,
+        0.02751f,
+        0.02823f,
+        0.02944f,
+        0.03125f,
+        0.03180f,
+        0.02912f,
+        0.02608f,
+        0.01999f,
+        0.01389f,
+        0.01085f,
+        0.00806f,
+        0.00726f,
+        0.00712f,
+        0.00602f,
+        0.00420f,
+        0.00240f,
+        0.00063f,
+        -0.00073f,
+        -0.00058f,
+        -0.00047f,
+        -0.00144f,
+        -0.00241f,
+        -0.00545f,
+        -0.00883f,
+        -0.01159f,
+        -0.01407f,
+        -0.01470f,
+        -0.01354f,
+        -0.01144f,
+        -0.00744f,
+        -0.00342f,
+        0.00073f,
+        0.00487f,
+        0.00685f,
+        0.00878f,
+        0.00888f,
+        0.00853f,
+        0.00793f,
+        0.00717f,
+        0.00681f,
+        0.00694f,
+        0.00719f,
+        0.00780f,
+        0.00836f,
+        0.00861f,
+        0.00886f,
+        0.00880f,
+        0.00872f,
+        0.00851f,
+        0.00825f,
+        0.00755f,
+        0.00650f,
+        0.00503f,
+        0.00287f,
+        0.00083f,
+        -0.00078f,
+        -0.00229f,
+        -0.00072f,
+        0.00084f,
+        0.00433f,
+        0.00815f,
+        0.00982f,
+        0.01047f,
+        0.00854f,
+        0.00403f,
+        -0.00064f,
+        -0.00565f,
+        -0.01023f,
+        -0.01229f,
+        -0.01435f,
+        -0.01460f,
+        -0.01480f,
+        -0.01449f,
+        -0.01404f,
+        -0.01365f,
+        -0.01329f,
+        -0.01327f,
+        -0.01367f,
+        -0.01406f,
+        -0.01439f,
+        -0.01463f,
+        -0.01388f,
+        -0.01313f,
+        -0.01185f,
+        -0.01052f,
+        -0.00995f,
+        -0.00966f,
+        -0.01063f,
+        -0.01261f,
+        -0.01482f,
+        -0.01741f,
+        -0.01938f,
+        -0.01895f,
+        -0.01844f,
+        -0.01486f,
+        -0.01128f,
+        -0.00753f,
+        -0.00376f,
+        -0.00074f,
+        0.00191f,
+        0.00352f,
+        0.00407f,
+        0.00368f,
+        0.00130f,
+        -0.00109f,
+        -0.00349f,
+        -0.00589f,
+        -0.00502f,
+        -0.00404f,
+        -0.00156f,
+        0.00133f,
+        0.00324f,
+        0.00454f,
+        0.00478f,
+        0.00364f,
+        0.00253f,
+        0.00150f,
+        0.00070f,
+        0.00244f,
+        0.00417f,
+        0.00645f,
+        0.00879f,
+        0.00889f,
+        0.00814f,
+        0.00647f,
+        0.00405f,
+        0.00198f,
+        0.00050f,
+        -0.00103f,
+        -0.00275f,
+        -0.00449f,
+        -0.00716f,
+        -0.00983f,
+        -0.01228f,
+        -0.01469f,
+        -0.01690f,
+        -0.01903f,
+        -0.02089f,
+        -0.02250f,
+        -0.02354f,
+        -0.02334f,
+        -0.02289f,
+        -0.02080f,
+        -0.01872f,
+        -0.01567f,
+        -0.01258f,
+        -0.00976f,
+        -0.00702f,
+        -0.00532f,
+        -0.00432f,
+        -0.00381f,
+        -0.00393f,
+        -0.00395f,
+        -0.00362f,
+        -0.00321f,
+        -0.00168f,
+        -0.00015f,
+        0.00332f,
+        0.00702f,
+        0.01148f,
+        0.01625f,
+        0.01948f,
+        0.02141f,
+        0.02201f,
+        0.02028f,
+        0.01831f,
+        0.01532f,
+        0.01231f,
+        0.00872f,
+        0.00512f,
+        0.00181f,
+        -0.00144f,
+        -0.00316f,
+        -0.00407f,
+        -0.00431f,
+        -0.00381f,
+        -0.00341f,
+        -0.00322f,
+        -0.00300f,
+        -0.00262f,
+        -0.00224f,
+        -0.00176f,
+        -0.00127f,
+        -0.00115f,
+        -0.00114f,
+        -0.00118f,
+        -0.00126f,
+        -0.00169f,
+        -0.00261f,
+        -0.00391f,
+        -0.00639f,
+        -0.00883f,
+        -0.01058f,
+        -0.01233f,
+        -0.01189f,
+        -0.01119f,
+        -0.00977f,
+        -0.00807f,
+        -0.00648f,
+        -0.00500f,
+        -0.00363f,
+        -0.00244f,
+        -0.00131f,
+        -0.00041f,
+        0.00050f,
+        0.00205f,
+        0.00360f,
+        0.00630f,
+        0.00922f,
+        0.01208f,
+        0.01489f,
+        0.01681f,
+        0.01775f,
+        0.01841f,
+        0.01842f,
+        0.01855f,
+        0.01948f,
+        0.02040f,
+        0.02114f,
+        0.02187f,
+        0.02085f,
+        0.01930f,
+        0.01690f,
+        0.01390f,
+        0.01117f,
+        0.00880f,
+        0.00676f,
+        0.00581f,
+        0.00495f,
+        0.00549f,
+        0.00603f,
+        0.00704f,
+        0.00811f,
+        0.00816f,
+        0.00779f,
+        0.00619f,
+        0.00350f,
+        0.00019f,
+        -0.00426f,
+        -0.00865f,
+        -0.01273f,
+        -0.01681f,
+        -0.01717f,
+        -0.01753f,
+        -0.01511f,
+        -0.01210f,
+        -0.00970f,
+        -0.00763f,
+        -0.00663f,
+        -0.00684f,
+        -0.00710f,
+        -0.00749f,
+        -0.00781f,
+        -0.00764f,
+        -0.00747f,
+        -0.00633f,
+        -0.00512f,
+        -0.00298f,
+        -0.00055f,
+        0.00126f,
+        0.00262f,
+        0.00327f,
+        0.00286f,
+        0.00261f,
+        0.00287f,
+        0.00315f,
+        0.00398f,
+        0.00480f,
+        0.00464f,
+        0.00435f,
+        0.00406f,
+        0.00377f,
+        0.00393f,
+        0.00450f,
+        0.00492f,
+        0.00505f,
+        0.00506f,
+        0.00448f,
+        0.00389f,
+        0.00301f,
+        0.00212f,
+        0.00069f,
+        -0.00086f,
+        -0.00241f,
+        -0.00397f,
+        -0.00500f,
+        -0.00540f,
+        -0.00561f,
+        -0.00534f,
+        -0.00515f,
+        -0.00562f,
+        -0.00609f,
+        -0.00771f,
+        -0.00941f,
+        -0.01114f,
+        -0.01288f,
+        -0.01369f,
+        -0.01382f,
+        -0.01345f,
+        -0.01234f,
+        -0.01131f,
+        -0.01055f,
+        -0.00980f,
+        -0.00909f,
+        -0.00838f,
+        -0.00710f,
+        -0.00573f,
+        -0.00485f,
+        -0.00417f,
+        -0.00406f,
+        -0.00446f,
+        -0.00449f,
+        -0.00383f,
+        -0.00293f,
+        -0.00082f,
+        0.00128f,
+        0.00246f,
+        0.00364f,
+        0.00340f,
+        0.00283f,
+        0.00164f,
+        0.00009f,
+        -0.00195f,
+        -0.00459f,
+        -0.00732f,
+        -0.01031f,
+        -0.01311f,
+        -0.01424f,
+        -0.01536f,
+        -0.01433f,
+        -0.01312f,
+        -0.01105f,
+        -0.00868f,
+        -0.00606f,
+        -0.00323f,
+        -0.00061f,
+        0.00167f,
+        0.00362f,
+        0.00438f,
+        0.00512f,
+        0.00531f,
+        0.00549f,
+        0.00578f,
+        0.00608f,
+        0.00586f,
+        0.00540f,
+        0.00456f,
+        0.00337f,
+        0.00223f,
+        0.00121f,
+        0.00028f,
+        -0.00016f,
+        -0.00061f,
+        0.00002f,
+        0.00068f,
+        0.00217f,
+        0.00386f,
+        0.00510f,
+        0.00608f,
+        0.00625f,
+        0.00543f,
+        0.00434f,
+        0.00252f,
+        0.00073f,
+        -0.00073f,
+        -0.00219f,
+        -0.00213f,
+        -0.00193f,
+        -0.00097f,
+        0.00025f,
+        0.00059f,
+        0.00024f,
+        -0.00071f,
+        -0.00262f,
+        -0.00428f,
+        -0.00499f,
+        -0.00564f,
+        -0.00453f,
+        -0.00341f,
+        -0.00195f,
+        -0.00044f,
+        0.00085f,
+        0.00203f,
+        0.00300f,
+        0.00378f,
+        0.00455f,
+        0.00532f,
+        0.00614f,
+        0.00724f,
+        0.00833f,
+        0.00915f,
+        0.00996f,
+        0.01018f,
+        0.01025f,
+        0.00994f,
+        0.00941f,
+        0.00837f,
+        0.00668f,
+        0.00479f,
+        0.00231f,
+        -0.00008f,
+        -0.00156f,
+        -0.00305f,
+        -0.00362f,
+        -0.00409f,
+        -0.00468f,
+        -0.00530f,
+        -0.00562f,
+        -0.00571f,
+        -0.00535f,
+        -0.00429f,
+        -0.00321f,
+        -0.00207f,
+        -0.00095f,
+        -0.00014f,
+        0.00067f,
+        0.00164f,
+        0.00263f,
+        0.00365f,
+        0.00468f,
+        0.00566f,
+        0.00659f,
+        0.00745f,
+        0.00814f,
+        0.00868f,
+        0.00825f,
+        0.00782f,
+        0.00644f,
+        0.00503f,
+        0.00403f,
+        0.00314f,
+        0.00272f,
+        0.00259f,
+        0.00227f,
+        0.00173f,
+        0.00106f,
+        0.00003f,
+        -0.00098f,
+        -0.00190f,
+        -0.00282f,
+        -0.00382f,
+        -0.00482f,
+        -0.00597f,
+        -0.00718f,
+        -0.00810f,
+        -0.00878f,
+        -0.00915f,
+        -0.00900f,
+        -0.00875f,
+        -0.00816f,
+        -0.00756f,
+        -0.00670f,
+        -0.00585f,
+        -0.00458f,
+        -0.00324f,
+        -0.00140f,
+        0.00068f,
+        0.00293f,
+        0.00533f,
+        0.00743f,
+        0.00885f,
+        0.01007f,
+        0.01000f,
+        0.00993f,
+        0.00917f,
+        0.00838f,
+        0.00727f,
+        0.00607f,
+        0.00479f,
+        0.00347f,
+        0.00251f,
+        0.00201f,
+        0.00160f,
+        0.00142f,
+        0.00117f,
+        0.00002f,
+        -0.00113f,
+        -0.00235f,
+        -0.00359f,
+        -0.00409f,
+        -0.00431f,
+        -0.00455f,
+        -0.00481f,
+        -0.00517f,
+        -0.00572f,
+        -0.00609f,
+        -0.00571f,
+        -0.00532f,
+        -0.00412f,
+        -0.00291f,
+        -0.00181f,
+        -0.00074f,
+        -0.00002f,
+        0.00052f,
+        0.00068f,
+        0.00043f,
+        0.00009f,
+        -0.00048f,
+        -0.00094f,
+        -0.00074f,
+        -0.00054f,
+        0.00035f,
+        0.00127f,
+        0.00228f,
+        0.00331f,
+        0.00437f,
+        0.00544f,
+        0.00637f,
+        0.00711f,
+        0.00763f,
+        0.00746f,
+        0.00725f,
+        0.00653f,
+        0.00580f,
+        0.00496f,
+        0.00410f,
+        0.00323f,
+        0.00235f,
+        0.00168f,
+        0.00117f,
+        0.00073f,
+        0.00039f,
+        -0.00006f,
+        -0.00096f,
+        -0.00187f,
+        -0.00320f,
+        -0.00452f,
+        -0.00562f,
+        -0.00667f,
+        -0.00749f,
+        -0.00819f,
+        -0.00869f,
+        -0.00897f,
+        -0.00893f,
+        -0.00816f,
+        -0.00727f,
+        -0.00551f,
+        -0.00374f,
+        -0.00196f,
+        -0.00018f,
+        0.00098f,
+        0.00195f,
+        0.00237f,
+        0.00240f,
+        0.00216f,
+        0.00152f,
+        0.00091f,
+        0.00035f,
+        -0.00015f,
+        0.00019f,
+        0.00053f,
+        0.00134f,
+        0.00221f,
+        0.00276f,
+        0.00316f,
+        0.00330f,
+        0.00320f,
+        0.00303f,
+        0.00273f,
+        0.00239f,
+        0.00190f,
+        0.00140f,
+        0.00117f,
+        0.00093f,
+        0.00118f,
+        0.00153f,
+        0.00192f,
+        0.00233f,
+        0.00262f,
+        0.00278f,
+        0.00288f,
+        0.00286f,
+        0.00279f,
+        0.00234f,
+        0.00189f,
+        0.00117f,
+        0.00044f,
+        -0.00019f,
+        -0.00080f,
+        -0.00134f,
+        -0.00184f,
+        -0.00227f,
+        -0.00260f,
+        -0.00279f,
+        -0.00255f,
+        -0.00229f,
+        -0.00165f,
+        -0.00102f,
+        -0.00040f,
+        0.00022f,
+        0.00077f,
+        0.00129f,
+        0.00159f,
+        0.00168f,
+        0.00157f,
+        0.00108f,
+        0.00060f,
+        0.00012f,
+        -0.00036f,
+        -0.00039f,
+        -0.00041f,
+        -0.00015f,
+        0.00019f,
+        0.00058f,
+        0.00100f,
+        0.00136f,
+        0.00165f,
+        0.00195f,
+        0.00230f,
+        0.00269f,
+        0.00335f,
+        0.00401f,
+        0.00457f,
+        0.00512f,
+        0.00536f,
+        0.00550f,
+        0.00546f,
+        0.00529f,
+        0.00491f,
+        0.00420f,
+        0.00339f,
+        0.00223f,
+        0.00109f,
+        0.00045f,
+        -0.00019f,
+        -0.00013f,
+        0.00003f,
+        0.00012f,
+        0.00017f,
+        -0.00009f,
+        -0.00065f,
+        -0.00120f,
+        -0.00176f,
+        -0.00221f,
+        -0.00209f,
+        -0.00197f,
+        -0.00114f,
+        -0.00030f,
+        0.00061f,
+        0.00155f,
+        0.00220f,
+        0.00268f,
+        0.00294f,
+        0.00290f,
+        0.00272f,
+        0.00215f,
+        0.00155f,
+        0.00068f,
+        -0.00019f,
+        -0.00080f,
+        -0.00137f,
+        -0.00167f,
+        -0.00188f,
+        -0.00220f,
+        -0.00259f,
+        -0.00310f,
+        -0.00380f,
+        -0.00448f,
+        -0.00506f,
+        -0.00562f,
+        -0.00574f,
+        -0.00585f,
+        -0.00554f,
+        -0.00515f,
+        -0.00468f,
+        -0.00418f,
+        -0.00378f,
+        -0.00349f,
+        -0.00323f,
+        -0.00306f,
+        -0.00286f,
+        -0.00256f,
+        -0.00226f,
+        -0.00178f,
+        -0.00130f,
+        -0.00078f,
+        -0.00026f,
+        0.00005f,
+        0.00022f,
+        0.00011f,
+        -0.00033f,
+        -0.00081f,
+        -0.00142f,
+        -0.00198f,
+        -0.00215f,
+        -0.00233f,
+        -0.00212f,
+        -0.00187f,
+        -0.00151f,
+        -0.00110f,
+        -0.00065f,
+        -0.00018f,
+        0.00027f,
+        0.00070f,
+        0.00105f,
+        0.00115f,
+        0.00124f,
+        0.00086f,
+        0.00047f,
+        -0.00018f,
+        -0.00088f,
+        -0.00150f,
+        -0.00208f,
+        -0.00252f,
+        -0.00283f,
+        -0.00311f,
+        -0.00332f,
+        -0.00354f,
+        -0.00378f,
+        -0.00402f,
+        -0.00419f,
+        -0.00436f,
+        -0.00432f,
+        -0.00423f,
+        -0.00391f,
+        -0.00347f,
+        -0.00292f,
+        -0.00225f,
+        -0.00159f,
+        -0.00098f,
+        -0.00039f,
+        -0.00008f,
+        0.00023f,
+        0.00039f,
+        0.00053f,
+        0.00071f,
+        0.00090f,
+        0.00099f,
+        0.00100f,
+        0.00090f,
+        0.00063f,
+        0.00041f,
+        0.00040f,
+        0.00040f,
+        0.00086f,
+        0.00132f,
+        0.00085f,
+        0.00021f};
+} // namespace
+
+std::span<const CSAMPLE> clickForSampleRate(mixxx::audio::SampleRate size) {
+    switch (size.value()) {
+    case 44100:
+        return kClick44100;
+    case 48000:
+        return kClick48000;
+    case 98000:
+        return kClick96000;
+    }
+    // should not happen!
+    return {};
+}
diff --git a/src/effects/backends/builtin/metronomeclick.h b/src/effects/backends/builtin/metronomeclick.h
index 1e65ea43a8b..b776f8527cb 100644
--- a/src/effects/backends/builtin/metronomeclick.h
+++ b/src/effects/backends/builtin/metronomeclick.h
@@ -1,4386 +1,6 @@
 #pragma once
 
-#include "util/types.h"
+#include "audio/types.h"
+#include "util/span.h"
 
-// This is a new recording from a real metronome
-// it was converted from *.wav to plain text using Audacity
-
-constexpr SINT kClickSize44100 = 1024;
-constexpr CSAMPLE kClick44100[kClickSize44100] = {
-        0.03459f,
-        0.09436f,
-        0.13646f,
-        0.13397f,
-        0.12769f,
-        0.16707f,
-        0.23479f,
-        0.27845f,
-        0.26258f,
-        0.15676f,
-        -0.04469f,
-        -0.25386f,
-        -0.34708f,
-        -0.32814f,
-        -0.32287f,
-        -0.38761f,
-        -0.44187f,
-        -0.41100f,
-        -0.30597f,
-        -0.15478f,
-        0.01382f,
-        0.12843f,
-        0.14796f,
-        0.13350f,
-        0.14399f,
-        0.12870f,
-        0.00836f,
-        -0.20222f,
-        -0.40190f,
-        -0.49408f,
-        -0.45249f,
-        -0.32491f,
-        -0.17703f,
-        -0.04102f,
-        0.07596f,
-        0.16295f,
-        0.22100f,
-        0.27411f,
-        0.31737f,
-        0.30172f,
-        0.22581f,
-        0.17353f,
-        0.20625f,
-        0.29894f,
-        0.39225f,
-        0.43471f,
-        0.39620f,
-        0.30707f,
-        0.24406f,
-        0.25017f,
-        0.28685f,
-        0.26838f,
-        0.16888f,
-        0.07771f,
-        0.07703f,
-        0.12917f,
-        0.16924f,
-        0.18038f,
-        0.12173f,
-        -0.03985f,
-        -0.22585f,
-        -0.33717f,
-        -0.38322f,
-        -0.42069f,
-        -0.47394f,
-        -0.54568f,
-        -0.60043f,
-        -0.56950f,
-        -0.43692f,
-        -0.25673f,
-        -0.07543f,
-        0.09491f,
-        0.23567f,
-        0.31195f,
-        0.30476f,
-        0.22808f,
-        0.11839f,
-        0.02167f,
-        -0.02317f,
-        -0.02049f,
-        -0.02039f,
-        -0.05451f,
-        -0.09535f,
-        -0.09242f,
-        -0.02332f,
-        0.07294f,
-        0.10909f,
-        0.03442f,
-        -0.10286f,
-        -0.20934f,
-        -0.22986f,
-        -0.16333f,
-        -0.05486f,
-        0.02456f,
-        0.04289f,
-        0.04285f,
-        0.08445f,
-        0.17320f,
-        0.25566f,
-        0.26299f,
-        0.17014f,
-        0.03790f,
-        -0.03072f,
-        -0.00689f,
-        0.03881f,
-        0.04679f,
-        0.02877f,
-        0.00884f,
-        0.00138f,
-        0.03024f,
-        0.07291f,
-        0.05081f,
-        -0.04617f,
-        -0.12579f,
-        -0.12098f,
-        -0.04814f,
-        0.04824f,
-        0.12493f,
-        0.15746f,
-        0.17621f,
-        0.22541f,
-        0.28672f,
-        0.30292f,
-        0.24742f,
-        0.13678f,
-        0.01260f,
-        -0.08157f,
-        -0.13262f,
-        -0.16340f,
-        -0.19945f,
-        -0.23970f,
-        -0.25591f,
-        -0.21998f,
-        -0.14390f,
-        -0.07781f,
-        -0.05757f,
-        -0.06808f,
-        -0.06935f,
-        -0.04456f,
-        -0.01490f,
-        -0.01461f,
-        -0.05266f,
-        -0.09777f,
-        -0.10582f,
-        -0.07299f,
-        -0.04444f,
-        -0.05213f,
-        -0.07615f,
-        -0.08385f,
-        -0.06168f,
-        -0.00244f,
-        0.07425f,
-        0.11139f,
-        0.09062f,
-        0.06733f,
-        0.08443f,
-        0.12020f,
-        0.14020f,
-        0.12856f,
-        0.07336f,
-        -0.01188f,
-        -0.07367f,
-        -0.07511f,
-        -0.03639f,
-        0.00539f,
-        0.04250f,
-        0.08281f,
-        0.12148f,
-        0.14662f,
-        0.14958f,
-        0.12349f,
-        0.06494f,
-        -0.02257f,
-        -0.12207f,
-        -0.19914f,
-        -0.23050f,
-        -0.23629f,
-        -0.24047f,
-        -0.22049f,
-        -0.15182f,
-        -0.05974f,
-        0.01923f,
-        0.07074f,
-        0.08392f,
-        0.05757f,
-        0.01974f,
-        0.00129f,
-        0.00862f,
-        0.02926f,
-        0.04478f,
-        0.04602f,
-        0.04341f,
-        0.05014f,
-        0.05643f,
-        0.03546f,
-        -0.01834f,
-        -0.07537f,
-        -0.11110f,
-        -0.12691f,
-        -0.12411f,
-        -0.10754f,
-        -0.09923f,
-        -0.10206f,
-        -0.08627f,
-        -0.03778f,
-        0.02648f,
-        0.07680f,
-        0.07931f,
-        0.03101f,
-        -0.01723f,
-        -0.01654f,
-        0.03056f,
-        0.09147f,
-        0.14028f,
-        0.18082f,
-        0.23092f,
-        0.28166f,
-        0.31268f,
-        0.32659f,
-        0.32160f,
-        0.28067f,
-        0.21356f,
-        0.14683f,
-        0.07928f,
-        -0.00116f,
-        -0.08048f,
-        -0.13060f,
-        -0.14039f,
-        -0.12032f,
-        -0.08408f,
-        -0.04745f,
-        -0.03051f,
-        -0.02827f,
-        -0.01512f,
-        0.00446f,
-        0.00886f,
-        0.00775f,
-        0.02161f,
-        0.05230f,
-        0.09373f,
-        0.12782f,
-        0.13474f,
-        0.12327f,
-        0.10086f,
-        0.04818f,
-        -0.03682f,
-        -0.12249f,
-        -0.17666f,
-        -0.18403f,
-        -0.15787f,
-        -0.12867f,
-        -0.11173f,
-        -0.10847f,
-        -0.10970f,
-        -0.09328f,
-        -0.07013f,
-        -0.08650f,
-        -0.13937f,
-        -0.17932f,
-        -0.19186f,
-        -0.19026f,
-        -0.17832f,
-        -0.15854f,
-        -0.12098f,
-        -0.05565f,
-        0.00610f,
-        0.02774f,
-        0.01399f,
-        -0.01458f,
-        -0.03553f,
-        -0.03309f,
-        -0.02864f,
-        -0.03883f,
-        -0.03313f,
-        0.00129f,
-        0.03547f,
-        0.05713f,
-        0.06533f,
-        0.04814f,
-        0.01266f,
-        -0.02066f,
-        -0.04113f,
-        -0.04551f,
-        -0.05089f,
-        -0.07535f,
-        -0.08810f,
-        -0.04419f,
-        0.04547f,
-        0.12324f,
-        0.13714f,
-        0.10579f,
-        0.11708f,
-        0.18173f,
-        0.19511f,
-        0.12903f,
-        0.05601f,
-        -0.02344f,
-        -0.11597f,
-        -0.11637f,
-        0.00381f,
-        0.09555f,
-        0.07643f,
-        0.04022f,
-        0.06328f,
-        0.10965f,
-        0.12557f,
-        0.08761f,
-        -0.00397f,
-        -0.09654f,
-        -0.10482f,
-        -0.03619f,
-        -0.02738f,
-        -0.15558f,
-        -0.30618f,
-        -0.32512f,
-        -0.17980f,
-        0.05893f,
-        0.24755f,
-        0.26022f,
-        0.15746f,
-        0.10698f,
-        0.12767f,
-        0.11703f,
-        0.04428f,
-        -0.05892f,
-        -0.14889f,
-        -0.14221f,
-        -0.01032f,
-        0.12248f,
-        0.12812f,
-        0.04112f,
-        -0.01848f,
-        0.01182f,
-        0.10921f,
-        0.19406f,
-        0.19163f,
-        0.12287f,
-        0.08187f,
-        0.10396f,
-        0.13949f,
-        0.13201f,
-        0.05523f,
-        -0.05590f,
-        -0.10584f,
-        -0.06066f,
-        0.00319f,
-        0.02458f,
-        0.00266f,
-        -0.04579f,
-        -0.06606f,
-        -0.01926f,
-        0.03021f,
-        0.02058f,
-        -0.01833f,
-        -0.06103f,
-        -0.10540f,
-        -0.11843f,
-        -0.09712f,
-        -0.08664f,
-        -0.10371f,
-        -0.13938f,
-        -0.17927f,
-        -0.18908f,
-        -0.15833f,
-        -0.11590f,
-        -0.07976f,
-        -0.05598f,
-        -0.03229f,
-        0.02044f,
-        0.06564f,
-        0.03584f,
-        -0.02610f,
-        -0.04853f,
-        -0.06666f,
-        -0.09862f,
-        -0.07855f,
-        -0.00945f,
-        0.03533f,
-        0.05170f,
-        0.06937f,
-        0.06798f,
-        0.03647f,
-        0.00590f,
-        -0.02032f,
-        -0.07579f,
-        -0.15381f,
-        -0.19499f,
-        -0.16406f,
-        -0.08496f,
-        -0.00320f,
-        0.04234f,
-        0.04797f,
-        0.06657f,
-        0.13493f,
-        0.20529f,
-        0.22004f,
-        0.18459f,
-        0.12525f,
-        0.06540f,
-        0.03991f,
-        0.05305f,
-        0.06738f,
-        0.06670f,
-        0.06504f,
-        0.06147f,
-        0.04185f,
-        0.00507f,
-        -0.03448f,
-        -0.05125f,
-        -0.02913f,
-        0.01559f,
-        0.05433f,
-        0.07532f,
-        0.07889f,
-        0.07308f,
-        0.06800f,
-        0.05050f,
-        0.00521f,
-        -0.03885f,
-        -0.04959f,
-        -0.05210f,
-        -0.07879f,
-        -0.11559f,
-        -0.14183f,
-        -0.14651f,
-        -0.10790f,
-        -0.03378f,
-        0.02235f,
-        0.03398f,
-        0.02714f,
-        0.02948f,
-        0.04395f,
-        0.05421f,
-        0.03861f,
-        0.00299f,
-        -0.01504f,
-        0.00895f,
-        0.05926f,
-        0.09261f,
-        0.07086f,
-        0.00626f,
-        -0.04195f,
-        -0.03927f,
-        -0.00847f,
-        0.01482f,
-        0.01056f,
-        -0.02572f,
-        -0.06891f,
-        -0.07971f,
-        -0.05297f,
-        -0.01872f,
-        -0.00207f,
-        -0.00398f,
-        -0.00381f,
-        0.01610f,
-        0.03990f,
-        0.04023f,
-        0.01932f,
-        -0.00338f,
-        -0.00751f,
-        0.02743f,
-        0.08275f,
-        0.09694f,
-        0.05281f,
-        0.00310f,
-        -0.01163f,
-        0.00362f,
-        0.02366f,
-        0.01377f,
-        -0.03865f,
-        -0.09842f,
-        -0.12568f,
-        -0.11386f,
-        -0.07865f,
-        -0.04651f,
-        -0.03427f,
-        -0.03039f,
-        -0.02670f,
-        -0.03711f,
-        -0.06215f,
-        -0.08460f,
-        -0.09131f,
-        -0.06823f,
-        -0.01608f,
-        0.03005f,
-        0.04887f,
-        0.06172f,
-        0.07927f,
-        0.08341f,
-        0.07165f,
-        0.05462f,
-        0.03051f,
-        0.00477f,
-        -0.00508f,
-        -0.00179f,
-        -0.00285f,
-        -0.01019f,
-        -0.01545f,
-        -0.01302f,
-        0.00070f,
-        0.01781f,
-        0.02326f,
-        0.02301f,
-        0.03102f,
-        0.04078f,
-        0.04430f,
-        0.04788f,
-        0.05010f,
-        0.04386f,
-        0.03747f,
-        0.03837f,
-        0.04012f,
-        0.03893f,
-        0.03982f,
-        0.04251f,
-        0.03661f,
-        0.01758f,
-        -0.00095f,
-        -0.00688f,
-        -0.00886f,
-        -0.01248f,
-        -0.00724f,
-        0.01037f,
-        0.03237f,
-        0.05020f,
-        0.05024f,
-        0.02496f,
-        -0.01019f,
-        -0.03626f,
-        -0.05082f,
-        -0.06031f,
-        -0.07213f,
-        -0.08779f,
-        -0.09670f,
-        -0.08881f,
-        -0.06862f,
-        -0.05296f,
-        -0.05507f,
-        -0.06497f,
-        -0.06256f,
-        -0.04937f,
-        -0.03752f,
-        -0.02667f,
-        -0.01798f,
-        -0.01659f,
-        -0.01715f,
-        -0.01636f,
-        -0.01894f,
-        -0.02081f,
-        -0.01681f,
-        -0.01081f,
-        -0.00266f,
-        0.00976f,
-        0.01961f,
-        0.02005f,
-        0.00787f,
-        -0.01560f,
-        -0.03515f,
-        -0.03517f,
-        -0.01931f,
-        0.00098f,
-        0.02146f,
-        0.03971f,
-        0.05064f,
-        0.05017f,
-        0.04095f,
-        0.02953f,
-        0.01613f,
-        0.00188f,
-        -0.00294f,
-        0.00327f,
-        0.00960f,
-        0.01332f,
-        0.01695f,
-        0.01727f,
-        0.01597f,
-        0.01702f,
-        0.01760f,
-        0.02107f,
-        0.03329f,
-        0.04531f,
-        0.04560f,
-        0.03429f,
-        0.01720f,
-        0.00530f,
-        0.00873f,
-        0.02175f,
-        0.02995f,
-        0.02552f,
-        0.00884f,
-        -0.01128f,
-        -0.02336f,
-        -0.02722f,
-        -0.03135f,
-        -0.03952f,
-        -0.04668f,
-        -0.04382f,
-        -0.03009f,
-        -0.01701f,
-        -0.01214f,
-        -0.01040f,
-        -0.00535f,
-        0.00276f,
-        0.00917f,
-        0.00917f,
-        0.00376f,
-        -0.00109f,
-        -0.00011f,
-        0.00812f,
-        0.01667f,
-        0.01447f,
-        0.00214f,
-        -0.00807f,
-        -0.00921f,
-        -0.00465f,
-        -0.00107f,
-        -0.00255f,
-        -0.00626f,
-        -0.00682f,
-        -0.00359f,
-        0.00187f,
-        0.00778f,
-        0.01000f,
-        0.00710f,
-        0.00484f,
-        0.00858f,
-        0.01621f,
-        0.02208f,
-        0.02281f,
-        0.01799f,
-        0.00918f,
-        0.00085f,
-        -0.00195f,
-        0.00253f,
-        0.01246f,
-        0.02305f,
-        0.02821f,
-        0.02704f,
-        0.02144f,
-        0.00832f,
-        -0.01313f,
-        -0.03553f,
-        -0.05392f,
-        -0.06622f,
-        -0.06704f,
-        -0.05745f,
-        -0.04523f,
-        -0.03152f,
-        -0.01732f,
-        -0.00927f,
-        -0.00420f,
-        0.00578f,
-        0.01470f,
-        0.01608f,
-        0.01481f,
-        0.01288f,
-        0.00814f,
-        0.00392f,
-        0.00106f,
-        -0.00516f,
-        -0.01293f,
-        -0.01547f,
-        -0.01176f,
-        -0.00531f,
-        -0.00050f,
-        -0.00313f,
-        -0.01409f,
-        -0.02467f,
-        -0.02669f,
-        -0.02200f,
-        -0.01610f,
-        -0.01018f,
-        -0.00480f,
-        -0.00149f,
-        0.00044f,
-        0.00330f,
-        0.00943f,
-        0.01908f,
-        0.02922f,
-        0.03911f,
-        0.04968f,
-        0.05445f,
-        0.04785f,
-        0.03744f,
-        0.03068f,
-        0.02705f,
-        0.02862f,
-        0.03255f,
-        0.02670f,
-        0.01343f,
-        0.00736f,
-        0.00706f,
-        0.00310f,
-        -0.00076f,
-        -0.00043f,
-        -0.00254f,
-        -0.00989f,
-        -0.01529f,
-        -0.01277f,
-        -0.00406f,
-        0.00496f,
-        0.00916f,
-        0.00840f,
-        0.00675f,
-        0.00703f,
-        0.00834f,
-        0.00888f,
-        0.00870f,
-        0.00814f,
-        0.00586f,
-        0.00117f,
-        -0.00234f,
-        0.00107f,
-        0.00937f,
-        0.01080f,
-        0.00099f,
-        -0.00992f,
-        -0.01441f,
-        -0.01484f,
-        -0.01387f,
-        -0.01309f,
-        -0.01397f,
-        -0.01470f,
-        -0.01306f,
-        -0.01017f,
-        -0.00953f,
-        -0.01384f,
-        -0.01947f,
-        -0.01853f,
-        -0.01074f,
-        -0.00252f,
-        0.00325f,
-        0.00444f,
-        -0.00075f,
-        -0.00597f,
-        -0.00383f,
-        0.00245f,
-        0.00528f,
-        0.00279f,
-        0.00056f,
-        0.00434f,
-        0.00943f,
-        0.00780f,
-        0.00253f,
-        -0.00069f,
-        -0.00444f,
-        -0.01025f,
-        -0.01549f,
-        -0.02011f,
-        -0.02360f,
-        -0.02317f,
-        -0.01863f,
-        -0.01191f,
-        -0.00593f,
-        -0.00375f,
-        -0.00403f,
-        -0.00332f,
-        0.00001f,
-        0.00805f,
-        0.01843f,
-        0.02264f,
-        0.01888f,
-        0.01236f,
-        0.00453f,
-        -0.00255f,
-        -0.00455f,
-        -0.00347f,
-        -0.00305f,
-        -0.00222f,
-        -0.00116f,
-        -0.00113f,
-        -0.00131f,
-        -0.00330f,
-        -0.00871f,
-        -0.01252f,
-        -0.01099f,
-        -0.00728f,
-        -0.00405f,
-        -0.00148f,
-        0.00049f,
-        0.00387f,
-        0.01024f,
-        0.01637f,
-        0.01840f,
-        0.01844f,
-        0.02045f,
-        0.02204f,
-        0.01867f,
-        0.01215f,
-        0.00699f,
-        0.00492f,
-        0.00609f,
-        0.00842f,
-        0.00762f,
-        0.00176f,
-        -0.00793f,
-        -0.01681f,
-        -0.01759f,
-        -0.01103f,
-        -0.00653f,
-        -0.00699f,
-        -0.00783f,
-        -0.00746f,
-        -0.00483f,
-        0.00046f,
-        0.00343f,
-        0.00255f,
-        0.00311f,
-        0.00490f,
-        0.00426f,
-        0.00363f,
-        0.00488f,
-        0.00516f,
-        0.00389f,
-        0.00196f,
-        -0.00142f,
-        -0.00481f,
-        -0.00569f,
-        -0.00510f,
-        -0.00612f,
-        -0.00983f,
-        -0.01362f,
-        -0.01390f,
-        -0.01148f,
-        -0.00983f,
-        -0.00829f,
-        -0.00531f,
-        -0.00385f,
-        -0.00472f,
-        -0.00327f,
-        0.00131f,
-        0.00386f,
-        0.00262f,
-        -0.00075f,
-        -0.00649f,
-        -0.01300f,
-        -0.01545f,
-        -0.01281f,
-        -0.00767f,
-        -0.00151f,
-        0.00345f,
-        0.00511f,
-        0.00552f,
-        0.00618f,
-        0.00517f,
-        0.00257f,
-        0.00035f,
-        -0.00062f,
-        0.00081f,
-        0.00449f,
-        0.00662f,
-        0.00483f,
-        0.00087f,
-        -0.00231f,
-        -0.00188f,
-        0.00079f,
-        0.00003f,
-        -0.00413f,
-        -0.00568f,
-        -0.00325f,
-        0.00005f,
-        0.00261f,
-        0.00430f,
-        0.00598f,
-        0.00836f,
-        0.01013f,
-        0.01027f,
-        0.00911f,
-        0.00544f,
-        0.00005f,
-        -0.00318f,
-        -0.00422f,
-        -0.00557f,
-        -0.00576f,
-        -0.00344f,
-        -0.00097f,
-        0.00079f,
-        0.00296f,
-        0.00520f,
-        0.00723f,
-        0.00874f,
-        0.00781f,
-        0.00473f,
-        0.00280f,
-        0.00251f,
-        0.00132f,
-        -0.00091f,
-        -0.00291f,
-        -0.00509f,
-        -0.00772f,
-        -0.00921f,
-        -0.00887f,
-        -0.00758f,
-        -0.00571f,
-        -0.00279f,
-        0.00175f,
-        0.00699f,
-        0.01008f,
-        0.00993f,
-        0.00821f,
-        0.00559f,
-        0.00272f,
-        0.00164f,
-        0.00126f,
-        -0.00125f,
-        -0.00393f,
-        -0.00441f,
-        -0.00497f,
-        -0.00616f,
-        -0.00534f,
-        -0.00271f,
-        -0.00037f,
-        0.00080f,
-        0.00026f,
-        -0.00097f,
-        -0.00053f,
-        0.00148f,
-        0.00373f,
-        0.00606f,
-        0.00767f,
-        0.00730f,
-        0.00572f,
-        0.00385f,
-        0.00195f,
-        0.00085f,
-        0.00011f,
-        -0.00186f,
-        -0.00475f,
-        -0.00703f,
-        -0.00856f,
-        -0.00916f,
-        -0.00749f,
-        -0.00364f,
-        0.00023f,
-        0.00235f,
-        0.00242f,
-        0.00104f,
-        -0.00017f,
-        0.00057f,
-        0.00247f,
-        0.00335f,
-        0.00314f,
-        0.00248f,
-        0.00140f,
-        0.00089f,
-        0.00166f,
-        0.00254f,
-        0.00289f,
-        0.00284f,
-        0.00186f,
-        0.00027f,
-        -0.00105f,
-        -0.00214f,
-        -0.00285f,
-        -0.00232f,
-        -0.00094f,
-        0.00041f,
-        0.00154f,
-        0.00174f,
-        0.00068f,
-        -0.00036f,
-        -0.00042f,
-        0.00031f,
-        0.00123f,
-        0.00185f,
-        0.00262f,
-        0.00406f,
-        0.00526f,
-        0.00556f,
-        0.00519f,
-        0.00365f,
-        0.00112f,
-        -0.00027f,
-        0.00008f,
-        0.00019f,
-        -0.00101f,
-        -0.00223f,
-        -0.00197f,
-        -0.00014f,
-        0.00189f,
-        0.00295f,
-        0.00288f,
-        0.00164f,
-        -0.00026f,
-        -0.00152f,
-        -0.00197f,
-        -0.00283f,
-        -0.00435f,
-        -0.00562f,
-        -0.00587f,
-        -0.00503f,
-        -0.00393f,
-        -0.00329f,
-        -0.00291f,
-        -0.00225f,
-        -0.00120f,
-        -0.00006f,
-        0.00031f,
-        -0.00065f,
-        -0.00196f,
-        -0.00234f,
-        -0.00181f,
-        -0.00092f,
-        0.00011f,
-        0.00103f,
-        0.00125f,
-        0.00042f,
-        -0.00110f,
-        -0.00237f,
-        -0.00304f,
-        -0.00350f,
-        -0.00403f,
-        -0.00439f,
-        -0.00419f,
-        -0.00322f,
-        -0.00175f,
-        -0.00042f,
-        0.00026f,
-        0.00057f,
-        0.00099f,
-        0.00100f,
-        0.00041f,
-        0.00039f,
-        0.00139f};
-
-constexpr unsigned int kClickSize48000 = 1116;
-constexpr CSAMPLE kClick48000[kClickSize48000] = {
-        0.01534f,
-        0.05623f,
-        0.10618f,
-        0.13596f,
-        0.13323f,
-        0.12915f,
-        0.16533f,
-        0.22630f,
-        0.26943f,
-        0.26715f,
-        0.19582f,
-        0.04604f,
-        -0.14266f,
-        -0.28995f,
-        -0.34129f,
-        -0.32696f,
-        -0.33215f,
-        -0.39098f,
-        -0.44083f,
-        -0.41410f,
-        -0.32505f,
-        -0.19452f,
-        -0.04420f,
-        0.07968f,
-        0.13807f,
-        0.14200f,
-        0.13697f,
-        0.14017f,
-        0.10844f,
-        -0.00998f,
-        -0.20339f,
-        -0.38685f,
-        -0.47964f,
-        -0.46238f,
-        -0.36563f,
-        -0.23624f,
-        -0.10653f,
-        0.01011f,
-        0.10692f,
-        0.17889f,
-        0.23127f,
-        0.27896f,
-        0.31689f,
-        0.30251f,
-        0.23580f,
-        0.18466f,
-        0.19663f,
-        0.26415f,
-        0.34964f,
-        0.41187f,
-        0.42004f,
-        0.36949f,
-        0.29331f,
-        0.24490f,
-        0.25222f,
-        0.28592f,
-        0.27035f,
-        0.18757f,
-        0.10225f,
-        0.07727f,
-        0.10667f,
-        0.14869f,
-        0.17376f,
-        0.16134f,
-        0.08241f,
-        -0.07001f,
-        -0.23485f,
-        -0.33713f,
-        -0.37946f,
-        -0.41459f,
-        -0.46094f,
-        -0.52234f,
-        -0.57817f,
-        -0.58459f,
-        -0.51238f,
-        -0.37392f,
-        -0.20807f,
-        -0.04356f,
-        0.10981f,
-        0.23755f,
-        0.30763f,
-        0.30575f,
-        0.24488f,
-        0.15134f,
-        0.05858f,
-        -0.00241f,
-        -0.02195f,
-        -0.02045f,
-        -0.03040f,
-        -0.06317f,
-        -0.09497f,
-        -0.08899f,
-        -0.02551f,
-        0.06207f,
-        0.10207f,
-        0.05498f,
-        -0.05390f,
-        -0.16271f,
-        -0.21921f,
-        -0.20327f,
-        -0.12880f,
-        -0.03603f,
-        0.02742f,
-        0.04289f,
-        0.04285f,
-        0.08079f,
-        0.15819f,
-        0.23501f,
-        0.26056f,
-        0.20848f,
-        0.10325f,
-        0.00876f,
-        -0.02254f,
-        0.00509f,
-        0.04025f,
-        0.04500f,
-        0.02840f,
-        0.01009f,
-        0.00246f,
-        0.02374f,
-        0.05983f,
-        0.05938f,
-        -0.00067f,
-        -0.08197f,
-        -0.12402f,
-        -0.10007f,
-        -0.02830f,
-        0.05780f,
-        0.12634f,
-        0.15623f,
-        0.17398f,
-        0.21555f,
-        0.26945f,
-        0.29704f,
-        0.27207f,
-        0.19491f,
-        0.08793f,
-        -0.01679f,
-        -0.09336f,
-        -0.13723f,
-        -0.16586f,
-        -0.19899f,
-        -0.23591f,
-        -0.25307f,
-        -0.22920f,
-        -0.16961f,
-        -0.10551f,
-        -0.06770f,
-        -0.06197f,
-        -0.06851f,
-        -0.06301f,
-        -0.03938f,
-        -0.01487f,
-        -0.01507f,
-        -0.05003f,
-        -0.09099f,
-        -0.10396f,
-        -0.08326f,
-        -0.05569f,
-        -0.04847f,
-        -0.06278f,
-        -0.07894f,
-        -0.07762f,
-        -0.04985f,
-        0.00664f,
-        0.07563f,
-        0.10975f,
-        0.09322f,
-        0.07214f,
-        0.07951f,
-        0.10700f,
-        0.13119f,
-        0.13475f,
-        0.10719f,
-        0.04729f,
-        -0.02576f,
-        -0.07388f,
-        -0.07271f,
-        -0.03713f,
-        0.00120f,
-        0.03576f,
-        0.07221f,
-        0.10817f,
-        0.13593f,
-        0.14808f,
-        0.13883f,
-        0.10412f,
-        0.04310f,
-        -0.03932f,
-        -0.12878f,
-        -0.19932f,
-        -0.22814f,
-        -0.23538f,
-        -0.23948f,
-        -0.22687f,
-        -0.17931f,
-        -0.10409f,
-        -0.02522f,
-        0.03756f,
-        0.07436f,
-        0.07882f,
-        0.05333f,
-        0.01917f,
-        0.00222f,
-        0.00766f,
-        0.02487f,
-        0.04022f,
-        0.04555f,
-        0.04460f,
-        0.04652f,
-        0.05254f,
-        0.05015f,
-        0.02371f,
-        -0.02616f,
-        -0.07737f,
-        -0.11019f,
-        -0.12522f,
-        -0.12464f,
-        -0.11200f,
-        -0.10214f,
-        -0.10084f,
-        -0.09437f,
-        -0.06659f,
-        -0.01692f,
-        0.03873f,
-        0.07721f,
-        0.07540f,
-        0.03103f,
-        -0.01329f,
-        -0.01665f,
-        0.01906f,
-        0.07165f,
-        0.12043f,
-        0.16104f,
-        0.20241f,
-        0.24866f,
-        0.28998f,
-        0.31528f,
-        0.32606f,
-        0.32059f,
-        0.28299f,
-        0.22281f,
-        0.16145f,
-        0.09957f,
-        0.02954f,
-        -0.04376f,
-        -0.10333f,
-        -0.13427f,
-        -0.13450f,
-        -0.11263f,
-        -0.07929f,
-        -0.04661f,
-        -0.03105f,
-        -0.02852f,
-        -0.01767f,
-        -0.00093f,
-        0.00729f,
-        0.00824f,
-        0.01441f,
-        0.03387f,
-        0.06549f,
-        0.10181f,
-        0.12890f,
-        0.13388f,
-        0.12335f,
-        0.10283f,
-        0.05709f,
-        -0.01554f,
-        -0.09408f,
-        -0.15429f,
-        -0.18039f,
-        -0.17292f,
-        -0.14784f,
-        -0.12423f,
-        -0.11114f,
-        -0.10859f,
-        -0.10940f,
-        -0.09431f,
-        -0.07347f,
-        -0.08281f,
-        -0.12316f,
-        -0.16382f,
-        -0.18598f,
-        -0.19114f,
-        -0.18586f,
-        -0.17264f,
-        -0.15081f,
-        -0.11284f,
-        -0.05297f,
-        0.00376f,
-        0.02516f,
-        0.01675f,
-        -0.00653f,
-        -0.02793f,
-        -0.03417f,
-        -0.03098f,
-        -0.03265f,
-        -0.03705f,
-        -0.02518f,
-        0.00640f,
-        0.03695f,
-        0.05685f,
-        0.06456f,
-        0.05115f,
-        0.02176f,
-        -0.00940f,
-        -0.03255f,
-        -0.04332f,
-        -0.04776f,
-        -0.05914f,
-        -0.07861f,
-        -0.08043f,
-        -0.03582f,
-        0.04641f,
-        0.11786f,
-        0.13505f,
-        0.11305f,
-        0.11355f,
-        0.15625f,
-        0.18875f,
-        0.16581f,
-        0.10259f,
-        0.03370f,
-        -0.04191f,
-        -0.11602f,
-        -0.11191f,
-        -0.00149f,
-        0.08405f,
-        0.08038f,
-        0.05064f,
-        0.05477f,
-        0.08877f,
-        0.11711f,
-        0.11088f,
-        0.05960f,
-        -0.02476f,
-        -0.09773f,
-        -0.10056f,
-        -0.03750f,
-        -0.02826f,
-        -0.13229f,
-        -0.26659f,
-        -0.31860f,
-        -0.24162f,
-        -0.06202f,
-        0.13666f,
-        0.25174f,
-        0.23457f,
-        0.14896f,
-        0.10878f,
-        0.12761f,
-        0.11783f,
-        0.05568f,
-        -0.03437f,
-        -0.12018f,
-        -0.14488f,
-        -0.07384f,
-        0.04773f,
-        0.12449f,
-        0.10423f,
-        0.02960f,
-        -0.01508f,
-        0.01482f,
-        0.10430f,
-        0.18289f,
-        0.19215f,
-        0.14309f,
-        0.09726f,
-        0.09387f,
-        0.12038f,
-        0.13664f,
-        0.10901f,
-        0.03096f,
-        -0.06275f,
-        -0.10332f,
-        -0.06181f,
-        -0.00362f,
-        0.02056f,
-        0.00856f,
-        -0.02881f,
-        -0.05731f,
-        -0.04326f,
-        0.00082f,
-        0.02708f,
-        0.01111f,
-        -0.02525f,
-        -0.06462f,
-        -0.10538f,
-        -0.11737f,
-        -0.10059f,
-        -0.08920f,
-        -0.09816f,
-        -0.12488f,
-        -0.15981f,
-        -0.18350f,
-        -0.17833f,
-        -0.14694f,
-        -0.10914f,
-        -0.07724f,
-        -0.05540f,
-        -0.03363f,
-        0.01317f,
-        0.05574f,
-        0.04479f,
-        -0.00246f,
-        -0.03815f,
-        -0.05679f,
-        -0.07863f,
-        -0.09273f,
-        -0.06389f,
-        -0.00359f,
-        0.03614f,
-        0.05118f,
-        0.06737f,
-        0.06825f,
-        0.04515f,
-        0.01680f,
-        -0.00884f,
-        -0.04699f,
-        -0.10697f,
-        -0.16692f,
-        -0.18766f,
-        -0.15173f,
-        -0.07886f,
-        -0.00374f,
-        0.03834f,
-        0.04702f,
-        0.06191f,
-        0.11226f,
-        0.17624f,
-        0.21275f,
-        0.20499f,
-        0.16421f,
-        0.10956f,
-        0.06079f,
-        0.04122f,
-        0.05331f,
-        0.06648f,
-        0.06680f,
-        0.06541f,
-        0.06256f,
-        0.04946f,
-        0.02232f,
-        -0.01271f,
-        -0.04066f,
-        -0.04490f,
-        -0.01992f,
-        0.02042f,
-        0.05524f,
-        0.07452f,
-        0.07846f,
-        0.07424f,
-        0.06943f,
-        0.05685f,
-        0.02533f,
-        -0.01570f,
-        -0.04307f,
-        -0.05037f,
-        -0.05826f,
-        -0.08430f,
-        -0.11738f,
-        -0.14149f,
-        -0.14607f,
-        -0.11467f,
-        -0.05280f,
-        0.00338f,
-        0.02911f,
-        0.03056f,
-        0.02812f,
-        0.03436f,
-        0.04658f,
-        0.05149f,
-        0.03528f,
-        0.00277f,
-        -0.01379f,
-        0.00534f,
-        0.04761f,
-        0.08218f,
-        0.07943f,
-        0.03697f,
-        -0.01511f,
-        -0.04098f,
-        -0.03062f,
-        -0.00382f,
-        0.01432f,
-        0.00921f,
-        -0.02412f,
-        -0.06350f,
-        -0.07748f,
-        -0.06067f,
-        -0.03136f,
-        -0.00957f,
-        -0.00296f,
-        -0.00391f,
-        0.00228f,
-        0.02145f,
-        0.03995f,
-        0.03893f,
-        0.01972f,
-        -0.00110f,
-        -0.00676f,
-        0.01825f,
-        0.06371f,
-        0.09090f,
-        0.07517f,
-        0.03232f,
-        -0.00177f,
-        -0.00782f,
-        0.00699f,
-        0.02280f,
-        0.01346f,
-        -0.03470f,
-        -0.08906f,
-        -0.11919f,
-        -0.11763f,
-        -0.09275f,
-        -0.06199f,
-        -0.04116f,
-        -0.03289f,
-        -0.02938f,
-        -0.02871f,
-        -0.03992f,
-        -0.06284f,
-        -0.08347f,
-        -0.09043f,
-        -0.07314f,
-        -0.03142f,
-        0.01273f,
-        0.04028f,
-        0.05481f,
-        0.06840f,
-        0.08051f,
-        0.08084f,
-        0.06932f,
-        0.05327f,
-        0.03112f,
-        0.00751f,
-        -0.00323f,
-        -0.00268f,
-        -0.00248f,
-        -0.00702f,
-        -0.01275f,
-        -0.01446f,
-        -0.00857f,
-        0.00486f,
-        0.01869f,
-        0.02324f,
-        0.02301f,
-        0.03037f,
-        0.03919f,
-        0.04344f,
-        0.04672f,
-        0.04920f,
-        0.04690f,
-        0.04111f,
-        0.03778f,
-        0.03884f,
-        0.03990f,
-        0.03902f,
-        0.03989f,
-        0.04236f,
-        0.03742f,
-        0.02175f,
-        0.00462f,
-        -0.00462f,
-        -0.00794f,
-        -0.01051f,
-        -0.01052f,
-        -0.00207f,
-        0.01504f,
-        0.03470f,
-        0.05020f,
-        0.05024f,
-        0.02781f,
-        -0.00337f,
-        -0.02908f,
-        -0.04563f,
-        -0.05615f,
-        -0.06599f,
-        -0.07839f,
-        -0.09063f,
-        -0.09483f,
-        -0.08566f,
-        -0.06745f,
-        -0.05306f,
-        -0.05488f,
-        -0.06330f,
-        -0.06316f,
-        -0.05374f,
-        -0.04241f,
-        -0.03203f,
-        -0.02298f,
-        -0.01750f,
-        -0.01674f,
-        -0.01701f,
-        -0.01662f,
-        -0.01897f,
-        -0.02069f,
-        -0.01739f,
-        -0.01216f,
-        -0.00516f,
-        0.00494f,
-        0.01499f,
-        0.01981f,
-        0.01556f,
-        0.00113f,
-        -0.01962f,
-        -0.03515f,
-        -0.03448f,
-        -0.01991f,
-        -0.00144f,
-        0.01736f,
-        0.03457f,
-        0.04667f,
-        0.05038f,
-        0.04579f,
-        0.03646f,
-        0.02535f,
-        0.01284f,
-        0.00116f,
-        -0.00252f,
-        0.00319f,
-        0.00900f,
-        0.01267f,
-        0.01602f,
-        0.01716f,
-        0.01651f,
-        0.01649f,
-        0.01726f,
-        0.01877f,
-        0.02420f,
-        0.03539f,
-        0.04534f,
-        0.04546f,
-        0.03507f,
-        0.01977f,
-        0.00806f,
-        0.00766f,
-        0.01662f,
-        0.02605f,
-        0.02799f,
-        0.01948f,
-        0.00319f,
-        -0.01369f,
-        -0.02382f,
-        -0.02737f,
-        -0.03117f,
-        -0.03850f,
-        -0.04520f,
-        -0.04464f,
-        -0.03516f,
-        -0.02290f,
-        -0.01473f,
-        -0.01147f,
-        -0.00886f,
-        -0.00353f,
-        0.00368f,
-        0.00917f,
-        0.00917f,
-        0.00430f,
-        -0.00021f,
-        -0.00037f,
-        0.00529f,
-        0.01303f,
-        0.01558f,
-        0.00939f,
-        -0.00124f,
-        -0.00835f,
-        -0.00844f,
-        -0.00434f,
-        -0.00108f,
-        -0.00244f,
-        -0.00568f,
-        -0.00669f,
-        -0.00462f,
-        -0.00032f,
-        0.00493f,
-        0.00875f,
-        0.00897f,
-        0.00648f,
-        0.00556f,
-        0.00944f,
-        0.01639f,
-        0.02178f,
-        0.02271f,
-        0.01902f,
-        0.01177f,
-        0.00398f,
-        -0.00067f,
-        0.00012f,
-        0.00631f,
-        0.01563f,
-        0.02418f,
-        0.02805f,
-        0.02673f,
-        0.02158f,
-        0.00972f,
-        -0.00910f,
-        -0.02950f,
-        -0.04748f,
-        -0.06091f,
-        -0.06662f,
-        -0.06315f,
-        -0.05348f,
-        -0.04189f,
-        -0.02922f,
-        -0.01667f,
-        -0.00927f,
-        -0.00461f,
-        0.00415f,
-        0.01252f,
-        0.01563f,
-        0.01533f,
-        0.01382f,
-        0.01084f,
-        0.00666f,
-        0.00315f,
-        -0.00010f,
-        -0.00598f,
-        -0.01299f,
-        -0.01533f,
-        -0.01227f,
-        -0.00672f,
-        -0.00194f,
-        -0.00213f,
-        -0.00902f,
-        -0.01891f,
-        -0.02543f,
-        -0.02531f,
-        -0.02075f,
-        -0.01533f,
-        -0.00991f,
-        -0.00497f,
-        -0.00186f,
-        0.00007f,
-        0.00251f,
-        0.00724f,
-        0.01485f,
-        0.02396f,
-        0.03317f,
-        0.04248f,
-        0.05081f,
-        0.05342f,
-        0.04707f,
-        0.03751f,
-        0.03127f,
-        0.02766f,
-        0.02823f,
-        0.03125f,
-        0.02912f,
-        0.01999f,
-        0.01085f,
-        0.00726f,
-        0.00602f,
-        0.00240f,
-        -0.00073f,
-        -0.00047f,
-        -0.00241f,
-        -0.00883f,
-        -0.01407f,
-        -0.01354f,
-        -0.00744f,
-        0.00073f,
-        0.00685f,
-        0.00888f,
-        0.00793f,
-        0.00681f,
-        0.00719f,
-        0.00836f,
-        0.00886f,
-        0.00872f,
-        0.00825f,
-        0.00650f,
-        0.00287f,
-        -0.00078f,
-        -0.00072f,
-        0.00433f,
-        0.00982f,
-        0.00854f,
-        -0.00064f,
-        -0.01023f,
-        -0.01435f,
-        -0.01480f,
-        -0.01404f,
-        -0.01329f,
-        -0.01367f,
-        -0.01439f,
-        -0.01388f,
-        -0.01185f,
-        -0.00995f,
-        -0.01063f,
-        -0.01482f,
-        -0.01938f,
-        -0.01844f,
-        -0.01128f,
-        -0.00376f,
-        0.00191f,
-        0.00407f,
-        0.00130f,
-        -0.00349f,
-        -0.00502f,
-        -0.00156f,
-        0.00324f,
-        0.00478f,
-        0.00253f,
-        0.00070f,
-        0.00417f,
-        0.00879f,
-        0.00814f,
-        0.00405f,
-        0.00050f,
-        -0.00275f,
-        -0.00716f,
-        -0.01228f,
-        -0.01690f,
-        -0.02089f,
-        -0.02354f,
-        -0.02289f,
-        -0.01872f,
-        -0.01258f,
-        -0.00702f,
-        -0.00432f,
-        -0.00393f,
-        -0.00362f,
-        -0.00168f,
-        0.00332f,
-        0.01148f,
-        0.01948f,
-        0.02201f,
-        0.01831f,
-        0.01231f,
-        0.00512f,
-        -0.00144f,
-        -0.00407f,
-        -0.00381f,
-        -0.00322f,
-        -0.00262f,
-        -0.00176f,
-        -0.00115f,
-        -0.00118f,
-        -0.00169f,
-        -0.00391f,
-        -0.00883f,
-        -0.01233f,
-        -0.01119f,
-        -0.00807f,
-        -0.00500f,
-        -0.00244f,
-        -0.00041f,
-        0.00205f,
-        0.00630f,
-        0.01208f,
-        0.01681f,
-        0.01841f,
-        0.01855f,
-        0.02040f,
-        0.02187f,
-        0.01930f,
-        0.01390f,
-        0.00880f,
-        0.00581f,
-        0.00549f,
-        0.00704f,
-        0.00816f,
-        0.00619f,
-        0.00019f,
-        -0.00865f,
-        -0.01681f,
-        -0.01753f,
-        -0.01210f,
-        -0.00763f,
-        -0.00684f,
-        -0.00749f,
-        -0.00764f,
-        -0.00633f,
-        -0.00298f,
-        0.00126f,
-        0.00327f,
-        0.00261f,
-        0.00315f,
-        0.00480f,
-        0.00435f,
-        0.00377f,
-        0.00450f,
-        0.00505f,
-        0.00448f,
-        0.00301f,
-        0.00069f,
-        -0.00241f,
-        -0.00500f,
-        -0.00561f,
-        -0.00515f,
-        -0.00609f,
-        -0.00941f,
-        -0.01288f,
-        -0.01382f,
-        -0.01234f,
-        -0.01055f,
-        -0.00909f,
-        -0.00710f,
-        -0.00485f,
-        -0.00406f,
-        -0.00449f,
-        -0.00293f,
-        0.00128f,
-        0.00364f,
-        0.00283f,
-        0.00009f,
-        -0.00459f,
-        -0.01031f,
-        -0.01424f,
-        -0.01433f,
-        -0.01105f,
-        -0.00606f,
-        -0.00061f,
-        0.00362f,
-        0.00512f,
-        0.00549f,
-        0.00608f,
-        0.00540f,
-        0.00337f,
-        0.00121f,
-        -0.00016f,
-        0.00002f,
-        0.00217f,
-        0.00510f,
-        0.00625f,
-        0.00434f,
-        0.00073f,
-        -0.00219f,
-        -0.00193f,
-        0.00025f,
-        0.00024f,
-        -0.00262f,
-        -0.00499f,
-        -0.00453f,
-        -0.00195f,
-        0.00085f,
-        0.00300f,
-        0.00455f,
-        0.00614f,
-        0.00833f,
-        0.00996f,
-        0.01025f,
-        0.00941f,
-        0.00668f,
-        0.00231f,
-        -0.00156f,
-        -0.00362f,
-        -0.00468f,
-        -0.00562f,
-        -0.00535f,
-        -0.00321f,
-        -0.00095f,
-        0.00067f,
-        0.00263f,
-        0.00468f,
-        0.00659f,
-        0.00814f,
-        0.00825f,
-        0.00644f,
-        0.00403f,
-        0.00272f,
-        0.00227f,
-        0.00106f,
-        -0.00098f,
-        -0.00282f,
-        -0.00482f,
-        -0.00718f,
-        -0.00878f,
-        -0.00900f,
-        -0.00816f,
-        -0.00670f,
-        -0.00458f,
-        -0.00140f,
-        0.00293f,
-        0.00743f,
-        0.01007f,
-        0.00993f,
-        0.00838f,
-        0.00607f,
-        0.00347f,
-        0.00201f,
-        0.00142f,
-        0.00002f,
-        -0.00235f,
-        -0.00409f,
-        -0.00455f,
-        -0.00517f,
-        -0.00609f,
-        -0.00532f,
-        -0.00291f,
-        -0.00074f,
-        0.00052f,
-        0.00043f,
-        -0.00048f,
-        -0.00074f,
-        0.00035f,
-        0.00228f,
-        0.00437f,
-        0.00637f,
-        0.00763f,
-        0.00725f,
-        0.00580f,
-        0.00410f,
-        0.00235f,
-        0.00117f,
-        0.00039f,
-        -0.00096f,
-        -0.00320f,
-        -0.00562f,
-        -0.00749f,
-        -0.00869f,
-        -0.00893f,
-        -0.00727f,
-        -0.00374f,
-        -0.00018f,
-        0.00195f,
-        0.00240f,
-        0.00152f,
-        0.00035f,
-        0.00019f,
-        0.00134f,
-        0.00276f,
-        0.00330f,
-        0.00303f,
-        0.00239f,
-        0.00140f,
-        0.00093f,
-        0.00153f,
-        0.00233f,
-        0.00278f,
-        0.00286f,
-        0.00234f,
-        0.00117f,
-        -0.00019f,
-        -0.00134f,
-        -0.00227f,
-        -0.00279f,
-        -0.00229f,
-        -0.00102f,
-        0.00022f,
-        0.00129f,
-        0.00168f,
-        0.00108f,
-        0.00012f,
-        -0.00039f,
-        -0.00015f,
-        0.00058f,
-        0.00136f,
-        0.00195f,
-        0.00269f,
-        0.00401f,
-        0.00512f,
-        0.00550f,
-        0.00529f,
-        0.00420f,
-        0.00223f,
-        0.00045f,
-        -0.00013f,
-        0.00012f,
-        -0.00009f,
-        -0.00120f,
-        -0.00221f,
-        -0.00197f,
-        -0.00030f,
-        0.00155f,
-        0.00268f,
-        0.00290f,
-        0.00215f,
-        0.00068f,
-        -0.00080f,
-        -0.00167f,
-        -0.00220f,
-        -0.00310f,
-        -0.00448f,
-        -0.00562f,
-        -0.00585f,
-        -0.00515f,
-        -0.00418f,
-        -0.00349f,
-        -0.00306f,
-        -0.00256f,
-        -0.00178f,
-        -0.00078f,
-        0.00005f,
-        0.00011f,
-        -0.00081f,
-        -0.00198f,
-        -0.00233f,
-        -0.00187f,
-        -0.00110f,
-        -0.00018f,
-        0.00070f,
-        0.00115f,
-        0.00086f,
-        -0.00018f,
-        -0.00150f,
-        -0.00252f,
-        -0.00311f,
-        -0.00354f,
-        -0.00402f,
-        -0.00436f,
-        -0.00423f,
-        -0.00347f,
-        -0.00225f,
-        -0.00098f,
-        -0.00008f,
-        0.00039f,
-        0.00071f,
-        0.00099f,
-        0.00090f,
-        0.00041f,
-        0.00040f,
-        0.00132f,
-        0.00021f};
-
-constexpr unsigned int kClickSize96000 = 2231;
-constexpr CSAMPLE kClick96000[kClickSize96000] = {
-        0.01534f,
-        0.03123f,
-        0.05623f,
-        0.08369f,
-        0.10618f,
-        0.12552f,
-        0.13596f,
-        0.13482f,
-        0.13323f,
-        0.13034f,
-        0.12915f,
-        0.14724f,
-        0.16533f,
-        0.19519f,
-        0.22630f,
-        0.24937f,
-        0.26943f,
-        0.27444f,
-        0.26715f,
-        0.24443f,
-        0.19582f,
-        0.13858f,
-        0.04604f,
-        -0.04657f,
-        -0.14266f,
-        -0.23875f,
-        -0.28995f,
-        -0.33277f,
-        -0.34129f,
-        -0.33259f,
-        -0.32696f,
-        -0.32454f,
-        -0.33215f,
-        -0.36189f,
-        -0.39098f,
-        -0.41591f,
-        -0.44083f,
-        -0.42828f,
-        -0.41410f,
-        -0.37329f,
-        -0.32505f,
-        -0.26398f,
-        -0.19452f,
-        -0.12165f,
-        -0.04420f,
-        0.02703f,
-        0.07968f,
-        0.12909f,
-        0.13807f,
-        0.14704f,
-        0.14200f,
-        0.13536f,
-        0.13697f,
-        0.14179f,
-        0.14017f,
-        0.13315f,
-        0.10844f,
-        0.05316f,
-        -0.00998f,
-        -0.10672f,
-        -0.20339f,
-        -0.29512f,
-        -0.38685f,
-        -0.43730f,
-        -0.47964f,
-        -0.48149f,
-        -0.46238f,
-        -0.42423f,
-        -0.36563f,
-        -0.30417f,
-        -0.23624f,
-        -0.16901f,
-        -0.10653f,
-        -0.04405f,
-        0.01011f,
-        0.06385f,
-        0.10692f,
-        0.14688f,
-        0.17889f,
-        0.20556f,
-        0.23127f,
-        0.25567f,
-        0.27896f,
-        0.29883f,
-        0.31689f,
-        0.30970f,
-        0.30251f,
-        0.27067f,
-        0.23580f,
-        0.20868f,
-        0.18466f,
-        0.18160f,
-        0.19663f,
-        0.22157f,
-        0.26415f,
-        0.30678f,
-        0.34964f,
-        0.39237f,
-        0.41187f,
-        0.43138f,
-        0.42004f,
-        0.40235f,
-        0.36949f,
-        0.32855f,
-        0.29331f,
-        0.26436f,
-        0.24490f,
-        0.24770f,
-        0.25222f,
-        0.26907f,
-        0.28592f,
-        0.27883f,
-        0.27035f,
-        0.23328f,
-        0.18757f,
-        0.14413f,
-        0.10225f,
-        0.07758f,
-        0.07727f,
-        0.08271f,
-        0.10667f,
-        0.13028f,
-        0.14869f,
-        0.16710f,
-        0.17376f,
-        0.17888f,
-        0.16134f,
-        0.13440f,
-        0.08241f,
-        0.00818f,
-        -0.07001f,
-        -0.15545f,
-        -0.23485f,
-        -0.28599f,
-        -0.33713f,
-        -0.35831f,
-        -0.37946f,
-        -0.39737f,
-        -0.41459f,
-        -0.43648f,
-        -0.46094f,
-        -0.48938f,
-        -0.52234f,
-        -0.55302f,
-        -0.57817f,
-        -0.59880f,
-        -0.58459f,
-        -0.57038f,
-        -0.51238f,
-        -0.45147f,
-        -0.37392f,
-        -0.29115f,
-        -0.20807f,
-        -0.12479f,
-        -0.04356f,
-        0.03469f,
-        0.10981f,
-        0.17447f,
-        0.23755f,
-        0.27259f,
-        0.30763f,
-        0.30905f,
-        0.30575f,
-        0.28011f,
-        0.24488f,
-        0.20173f,
-        0.15134f,
-        0.10301f,
-        0.05858f,
-        0.01818f,
-        -0.00241f,
-        -0.02301f,
-        -0.02195f,
-        -0.02072f,
-        -0.02045f,
-        -0.02041f,
-        -0.03040f,
-        -0.04607f,
-        -0.06317f,
-        -0.08193f,
-        -0.09497f,
-        -0.09362f,
-        -0.08899f,
-        -0.05725f,
-        -0.02551f,
-        0.01785f,
-        0.06207f,
-        0.08547f,
-        0.10207f,
-        0.08929f,
-        0.05498f,
-        0.00916f,
-        -0.05390f,
-        -0.11380f,
-        -0.16271f,
-        -0.20978f,
-        -0.21921f,
-        -0.22863f,
-        -0.20327f,
-        -0.17271f,
-        -0.12880f,
-        -0.07897f,
-        -0.03603f,
-        0.00046f,
-        0.02742f,
-        0.03584f,
-        0.04289f,
-        0.04287f,
-        0.04285f,
-        0.06168f,
-        0.08079f,
-        0.11742f,
-        0.15819f,
-        0.19713f,
-        0.23501f,
-        0.25719f,
-        0.26056f,
-        0.25113f,
-        0.20848f,
-        0.16399f,
-        0.10325f,
-        0.04250f,
-        0.00876f,
-        -0.02276f,
-        -0.02254f,
-        -0.01159f,
-        0.00509f,
-        0.02608f,
-        0.04025f,
-        0.04392f,
-        0.04500f,
-        0.03672f,
-        0.02840f,
-        0.01925f,
-        0.01009f,
-        0.00588f,
-        0.00246f,
-        0.01048f,
-        0.02374f,
-        0.04022f,
-        0.05983f,
-        0.06953f,
-        0.05938f,
-        0.04388f,
-        -0.00067f,
-        -0.04522f,
-        -0.08197f,
-        -0.11854f,
-        -0.12402f,
-        -0.12181f,
-        -0.10007f,
-        -0.06661f,
-        -0.02830f,
-        0.01598f,
-        0.05780f,
-        0.09303f,
-        0.12634f,
-        0.14128f,
-        0.15623f,
-        0.16536f,
-        0.17398f,
-        0.19295f,
-        0.21555f,
-        0.24129f,
-        0.26945f,
-        0.28960f,
-        0.29704f,
-        0.29756f,
-        0.27207f,
-        0.24574f,
-        0.19491f,
-        0.14408f,
-        0.08793f,
-        0.03089f,
-        -0.01679f,
-        -0.06005f,
-        -0.09336f,
-        -0.11681f,
-        -0.13723f,
-        -0.15136f,
-        -0.16586f,
-        -0.18243f,
-        -0.19899f,
-        -0.21742f,
-        -0.23591f,
-        -0.24562f,
-        -0.25307f,
-        -0.24571f,
-        -0.22920f,
-        -0.20456f,
-        -0.16961f,
-        -0.13587f,
-        -0.10551f,
-        -0.07700f,
-        -0.06770f,
-        -0.05840f,
-        -0.06197f,
-        -0.06680f,
-        -0.06851f,
-        -0.06909f,
-        -0.06301f,
-        -0.05162f,
-        -0.03938f,
-        -0.02576f,
-        -0.01487f,
-        -0.01474f,
-        -0.01507f,
-        -0.03255f,
-        -0.05003f,
-        -0.07026f,
-        -0.09099f,
-        -0.10026f,
-        -0.10396f,
-        -0.09834f,
-        -0.08326f,
-        -0.06881f,
-        -0.05569f,
-        -0.04494f,
-        -0.04847f,
-        -0.05201f,
-        -0.06278f,
-        -0.07381f,
-        -0.07894f,
-        -0.08248f,
-        -0.07762f,
-        -0.06744f,
-        -0.04985f,
-        -0.02264f,
-        0.00664f,
-        0.04187f,
-        0.07563f,
-        0.09269f,
-        0.10975f,
-        0.10277f,
-        0.09322f,
-        0.08284f,
-        0.07214f,
-        0.07165f,
-        0.07951f,
-        0.09056f,
-        0.10700f,
-        0.12200f,
-        0.13119f,
-        0.14010f,
-        0.13475f,
-        0.12940f,
-        0.10719f,
-        0.08183f,
-        0.04729f,
-        0.00813f,
-        -0.02576f,
-        -0.05414f,
-        -0.07388f,
-        -0.07454f,
-        -0.07271f,
-        -0.05492f,
-        -0.03713f,
-        -0.01800f,
-        0.00120f,
-        0.01871f,
-        0.03576f,
-        0.05370f,
-        0.07221f,
-        0.09041f,
-        0.10817f,
-        0.12438f,
-        0.13593f,
-        0.14672f,
-        0.14808f,
-        0.14944f,
-        0.13883f,
-        0.12684f,
-        0.10412f,
-        0.07722f,
-        0.04310f,
-        0.00290f,
-        -0.03932f,
-        -0.08503f,
-        -0.12878f,
-        -0.16419f,
-        -0.19932f,
-        -0.21373f,
-        -0.22814f,
-        -0.23272f,
-        -0.23538f,
-        -0.23756f,
-        -0.23948f,
-        -0.23604f,
-        -0.22687f,
-        -0.21086f,
-        -0.17931f,
-        -0.14639f,
-        -0.10409f,
-        -0.06179f,
-        -0.02522f,
-        0.01106f,
-        0.03756f,
-        0.06122f,
-        0.07436f,
-        0.08041f,
-        0.07882f,
-        0.06672f,
-        0.05333f,
-        0.03595f,
-        0.01917f,
-        0.01070f,
-        0.00222f,
-        0.00429f,
-        0.00766f,
-        0.01538f,
-        0.02487f,
-        0.03309f,
-        0.04022f,
-        0.04498f,
-        0.04555f,
-        0.04580f,
-        0.04460f,
-        0.04343f,
-        0.04652f,
-        0.04961f,
-        0.05254f,
-        0.05543f,
-        0.05015f,
-        0.04051f,
-        0.02371f,
-        -0.00100f,
-        -0.02616f,
-        -0.05236f,
-        -0.07737f,
-        -0.09378f,
-        -0.11019f,
-        -0.11796f,
-        -0.12522f,
-        -0.12592f,
-        -0.12464f,
-        -0.11961f,
-        -0.11200f,
-        -0.10596f,
-        -0.10214f,
-        -0.09954f,
-        -0.10084f,
-        -0.10162f,
-        -0.09437f,
-        -0.08711f,
-        -0.06659f,
-        -0.04431f,
-        -0.01692f,
-        0.01260f,
-        0.03873f,
-        0.06184f,
-        0.07721f,
-        0.07836f,
-        0.07540f,
-        0.05322f,
-        0.03103f,
-        0.00887f,
-        -0.01329f,
-        -0.01697f,
-        -0.01665f,
-        -0.00258f,
-        0.01906f,
-        0.04367f,
-        0.07165f,
-        0.09801f,
-        0.12043f,
-        0.14242f,
-        0.16104f,
-        0.17966f,
-        0.20241f,
-        0.22542f,
-        0.24866f,
-        0.27197f,
-        0.28998f,
-        0.30423f,
-        0.31528f,
-        0.32167f,
-        0.32606f,
-        0.32377f,
-        0.32059f,
-        0.30179f,
-        0.28299f,
-        0.25364f,
-        0.22281f,
-        0.19211f,
-        0.16145f,
-        0.13060f,
-        0.09957f,
-        0.06649f,
-        0.02954f,
-        -0.00733f,
-        -0.04376f,
-        -0.08020f,
-        -0.10333f,
-        -0.12635f,
-        -0.13427f,
-        -0.13876f,
-        -0.13450f,
-        -0.12528f,
-        -0.11263f,
-        -0.09599f,
-        -0.07929f,
-        -0.06246f,
-        -0.04661f,
-        -0.03883f,
-        -0.03105f,
-        -0.02955f,
-        -0.02852f,
-        -0.02371f,
-        -0.01767f,
-        -0.00993f,
-        -0.00093f,
-        0.00527f,
-        0.00729f,
-        0.00875f,
-        0.00824f,
-        0.00805f,
-        0.01441f,
-        0.02078f,
-        0.03387f,
-        0.04797f,
-        0.06549f,
-        0.08452f,
-        0.10181f,
-        0.11747f,
-        0.12890f,
-        0.13208f,
-        0.13388f,
-        0.12862f,
-        0.12335f,
-        0.11312f,
-        0.10283f,
-        0.08129f,
-        0.05709f,
-        0.02351f,
-        -0.01554f,
-        -0.05472f,
-        -0.09408f,
-        -0.12941f,
-        -0.15429f,
-        -0.17700f,
-        -0.18039f,
-        -0.18377f,
-        -0.17292f,
-        -0.16090f,
-        -0.14784f,
-        -0.13443f,
-        -0.12423f,
-        -0.11645f,
-        -0.11114f,
-        -0.10964f,
-        -0.10859f,
-        -0.10916f,
-        -0.10940f,
-        -0.10186f,
-        -0.09431f,
-        -0.08410f,
-        -0.07347f,
-        -0.07529f,
-        -0.08281f,
-        -0.09887f,
-        -0.12316f,
-        -0.14547f,
-        -0.16382f,
-        -0.18022f,
-        -0.18598f,
-        -0.19174f,
-        -0.19114f,
-        -0.19041f,
-        -0.18586f,
-        -0.18038f,
-        -0.17264f,
-        -0.16355f,
-        -0.15081f,
-        -0.13355f,
-        -0.11284f,
-        -0.08283f,
-        -0.05297f,
-        -0.02461f,
-        0.00376f,
-        0.01522f,
-        0.02516f,
-        0.02306f,
-        0.01675f,
-        0.00659f,
-        -0.00653f,
-        -0.01830f,
-        -0.02793f,
-        -0.03529f,
-        -0.03417f,
-        -0.03302f,
-        -0.03098f,
-        -0.02893f,
-        -0.03265f,
-        -0.03733f,
-        -0.03705f,
-        -0.03443f,
-        -0.02518f,
-        -0.00937f,
-        0.00640f,
-        0.02210f,
-        0.03695f,
-        0.04690f,
-        0.05685f,
-        0.06079f,
-        0.06456f,
-        0.05905f,
-        0.05115f,
-        0.03806f,
-        0.02176f,
-        0.00591f,
-        -0.00940f,
-        -0.02315f,
-        -0.03255f,
-        -0.04131f,
-        -0.04332f,
-        -0.04533f,
-        -0.04776f,
-        -0.05023f,
-        -0.05914f,
-        -0.07037f,
-        -0.07861f,
-        -0.08447f,
-        -0.08043f,
-        -0.06026f,
-        -0.03582f,
-        0.00537f,
-        0.04641f,
-        0.08214f,
-        0.11786f,
-        0.12866f,
-        0.13505f,
-        0.12745f,
-        0.11305f,
-        0.10836f,
-        0.11355f,
-        0.12655f,
-        0.15625f,
-        0.18260f,
-        0.18875f,
-        0.19490f,
-        0.16581f,
-        0.13546f,
-        0.10259f,
-        0.06904f,
-        0.03370f,
-        -0.00280f,
-        -0.04191f,
-        -0.08442f,
-        -0.11602f,
-        -0.11620f,
-        -0.11191f,
-        -0.05670f,
-        -0.00149f,
-        0.04191f,
-        0.08405f,
-        0.08916f,
-        0.08038f,
-        0.06728f,
-        0.05064f,
-        0.04417f,
-        0.05477f,
-        0.06746f,
-        0.08877f,
-        0.10979f,
-        0.11711f,
-        0.12442f,
-        0.11088f,
-        0.09344f,
-        0.05960f,
-        0.01753f,
-        -0.02476f,
-        -0.06729f,
-        -0.09773f,
-        -0.10153f,
-        -0.10056f,
-        -0.06903f,
-        -0.03750f,
-        -0.03231f,
-        -0.02826f,
-        -0.07340f,
-        -0.13229f,
-        -0.19741f,
-        -0.26659f,
-        -0.30990f,
-        -0.31860f,
-        -0.30837f,
-        -0.24162f,
-        -0.17168f,
-        -0.06202f,
-        0.04764f,
-        0.13666f,
-        0.22331f,
-        0.25174f,
-        0.25756f,
-        0.23457f,
-        0.18736f,
-        0.14896f,
-        0.12577f,
-        0.10878f,
-        0.11829f,
-        0.12761f,
-        0.12272f,
-        0.11783f,
-        0.08909f,
-        0.05568f,
-        0.01304f,
-        -0.03437f,
-        -0.07885f,
-        -0.12018f,
-        -0.14795f,
-        -0.14488f,
-        -0.13443f,
-        -0.07384f,
-        -0.01325f,
-        0.04773f,
-        0.10873f,
-        0.12449f,
-        0.12708f,
-        0.10423f,
-        0.06426f,
-        0.02960f,
-        0.00222f,
-        -0.01508f,
-        -0.00116f,
-        0.01482f,
-        0.05956f,
-        0.10430f,
-        0.14391f,
-        0.18289f,
-        0.19326f,
-        0.19215f,
-        0.17468f,
-        0.14309f,
-        0.11609f,
-        0.09726f,
-        0.08373f,
-        0.09387f,
-        0.10406f,
-        0.12038f,
-        0.13670f,
-        0.13664f,
-        0.13321f,
-        0.10901f,
-        0.07374f,
-        0.03096f,
-        -0.02009f,
-        -0.06275f,
-        -0.08569f,
-        -0.10332f,
-        -0.08256f,
-        -0.06181f,
-        -0.03295f,
-        -0.00362f,
-        0.01073f,
-        0.02056f,
-        0.01863f,
-        0.00856f,
-        -0.00656f,
-        -0.02881f,
-        -0.04800f,
-        -0.05731f,
-        -0.06476f,
-        -0.04326f,
-        -0.02177f,
-        0.00082f,
-        0.02354f,
-        0.02708f,
-        0.02266f,
-        0.01111f,
-        -0.00676f,
-        -0.02525f,
-        -0.04487f,
-        -0.06462f,
-        -0.08500f,
-        -0.10538f,
-        -0.11138f,
-        -0.11737f,
-        -0.11038f,
-        -0.10059f,
-        -0.09401f,
-        -0.08920f,
-        -0.09031f,
-        -0.09816f,
-        -0.10849f,
-        -0.12488f,
-        -0.14148f,
-        -0.15981f,
-        -0.17813f,
-        -0.18350f,
-        -0.18800f,
-        -0.17833f,
-        -0.16420f,
-        -0.14694f,
-        -0.12745f,
-        -0.10914f,
-        -0.09254f,
-        -0.07724f,
-        -0.06632f,
-        -0.05540f,
-        -0.04451f,
-        -0.03363f,
-        -0.01106f,
-        0.01317f,
-        0.03497f,
-        0.05574f,
-        0.05848f,
-        0.04479f,
-        0.02599f,
-        -0.00246f,
-        -0.02784f,
-        -0.03815f,
-        -0.04845f,
-        -0.05679f,
-        -0.06512f,
-        -0.07863f,
-        -0.09331f,
-        -0.09273f,
-        -0.08351f,
-        -0.06389f,
-        -0.03215f,
-        -0.00359f,
-        0.01698f,
-        0.03614f,
-        0.04366f,
-        0.05118f,
-        0.05926f,
-        0.06737f,
-        0.06889f,
-        0.06825f,
-        0.05962f,
-        0.04515f,
-        0.03085f,
-        0.01680f,
-        0.00321f,
-        -0.00884f,
-        -0.02151f,
-        -0.04699f,
-        -0.07248f,
-        -0.10697f,
-        -0.14281f,
-        -0.16692f,
-        -0.18584f,
-        -0.18766f,
-        -0.17345f,
-        -0.15173f,
-        -0.11539f,
-        -0.07886f,
-        -0.04130f,
-        -0.00374f,
-        0.01742f,
-        0.03834f,
-        0.04443f,
-        0.04702f,
-        0.05337f,
-        0.06191f,
-        0.08086f,
-        0.11226f,
-        0.14392f,
-        0.17624f,
-        0.20598f,
-        0.21275f,
-        0.21953f,
-        0.20499f,
-        0.18870f,
-        0.16421f,
-        0.13696f,
-        0.10956f,
-        0.08207f,
-        0.06079f,
-        0.04908f,
-        0.04122f,
-        0.04725f,
-        0.05331f,
-        0.05990f,
-        0.06648f,
-        0.06711f,
-        0.06680f,
-        0.06618f,
-        0.06541f,
-        0.06420f,
-        0.06256f,
-        0.05847f,
-        0.04946f,
-        0.03922f,
-        0.02232f,
-        0.00543f,
-        -0.01271f,
-        -0.03088f,
-        -0.04066f,
-        -0.04836f,
-        -0.04490f,
-        -0.03474f,
-        -0.01992f,
-        0.00062f,
-        0.02042f,
-        0.03821f,
-        0.05524f,
-        0.06488f,
-        0.07452f,
-        0.07682f,
-        0.07846f,
-        0.07691f,
-        0.07424f,
-        0.07176f,
-        0.06943f,
-        0.06489f,
-        0.05685f,
-        0.04613f,
-        0.02533f,
-        0.00454f,
-        -0.01570f,
-        -0.03594f,
-        -0.04307f,
-        -0.04801f,
-        -0.05037f,
-        -0.05153f,
-        -0.05826f,
-        -0.07052f,
-        -0.08430f,
-        -0.10120f,
-        -0.11738f,
-        -0.12944f,
-        -0.14149f,
-        -0.14392f,
-        -0.14607f,
-        -0.13241f,
-        -0.11467f,
-        -0.08685f,
-        -0.05280f,
-        -0.02240f,
-        0.00338f,
-        0.02376f,
-        0.02911f,
-        0.03370f,
-        0.03056f,
-        0.02742f,
-        0.02812f,
-        0.02919f,
-        0.03436f,
-        0.04101f,
-        0.04658f,
-        0.05129f,
-        0.05149f,
-        0.04432f,
-        0.03528f,
-        0.01892f,
-        0.00277f,
-        -0.00551f,
-        -0.01379f,
-        -0.00568f,
-        0.00534f,
-        0.02449f,
-        0.04761f,
-        0.06685f,
-        0.08218f,
-        0.08942f,
-        0.07943f,
-        0.06665f,
-        0.03697f,
-        0.00729f,
-        -0.01511f,
-        -0.03726f,
-        -0.04098f,
-        -0.03975f,
-        -0.03062f,
-        -0.01647f,
-        -0.00382f,
-        0.00688f,
-        0.01432f,
-        0.01236f,
-        0.00921f,
-        -0.00745f,
-        -0.02412f,
-        -0.04365f,
-        -0.06350f,
-        -0.07252f,
-        -0.07748f,
-        -0.07295f,
-        -0.06067f,
-        -0.04710f,
-        -0.03136f,
-        -0.01722f,
-        -0.00957f,
-        -0.00209f,
-        -0.00296f,
-        -0.00384f,
-        -0.00391f,
-        -0.00384f,
-        0.00228f,
-        0.01143f,
-        0.02145f,
-        0.03238f,
-        0.03995f,
-        0.04010f,
-        0.03893f,
-        0.02933f,
-        0.01972f,
-        0.00933f,
-        -0.00110f,
-        -0.00486f,
-        -0.00676f,
-        0.00219f,
-        0.01825f,
-        0.03830f,
-        0.06371f,
-        0.08439f,
-        0.09090f,
-        0.09544f,
-        0.07517f,
-        0.05489f,
-        0.03232f,
-        0.00949f,
-        -0.00177f,
-        -0.00854f,
-        -0.00782f,
-        -0.00082f,
-        0.00699f,
-        0.01620f,
-        0.02280f,
-        0.01826f,
-        0.01346f,
-        -0.01062f,
-        -0.03470f,
-        -0.06160f,
-        -0.08906f,
-        -0.10667f,
-        -0.11919f,
-        -0.12306f,
-        -0.11763f,
-        -0.10892f,
-        -0.09275f,
-        -0.07676f,
-        -0.06199f,
-        -0.04723f,
-        -0.04116f,
-        -0.03554f,
-        -0.03289f,
-        -0.03111f,
-        -0.02938f,
-        -0.02768f,
-        -0.02871f,
-        -0.03349f,
-        -0.03992f,
-        -0.05142f,
-        -0.06284f,
-        -0.07316f,
-        -0.08347f,
-        -0.08734f,
-        -0.09043f,
-        -0.08375f,
-        -0.07314f,
-        -0.05538f,
-        -0.03142f,
-        -0.00846f,
-        0.01273f,
-        0.03163f,
-        0.04028f,
-        0.04891f,
-        0.05481f,
-        0.06071f,
-        0.06840f,
-        0.07647f,
-        0.08051f,
-        0.08241f,
-        0.08084f,
-        0.07544f,
-        0.06932f,
-        0.06149f,
-        0.05327f,
-        0.04220f,
-        0.03112f,
-        0.01934f,
-        0.00751f,
-        0.00130f,
-        -0.00323f,
-        -0.00419f,
-        -0.00268f,
-        -0.00199f,
-        -0.00248f,
-        -0.00365f,
-        -0.00702f,
-        -0.01034f,
-        -0.01275f,
-        -0.01517f,
-        -0.01446f,
-        -0.01335f,
-        -0.00857f,
-        -0.00226f,
-        0.00486f,
-        0.01272f,
-        0.01869f,
-        0.02120f,
-        0.02324f,
-        0.02312f,
-        0.02301f,
-        0.02669f,
-        0.03037f,
-        0.03471f,
-        0.03919f,
-        0.04182f,
-        0.04344f,
-        0.04507f,
-        0.04672f,
-        0.04818f,
-        0.04920f,
-        0.04977f,
-        0.04690f,
-        0.04404f,
-        0.04111f,
-        0.03817f,
-        0.03778f,
-        0.03820f,
-        0.03884f,
-        0.03964f,
-        0.03990f,
-        0.03935f,
-        0.03902f,
-        0.03943f,
-        0.03989f,
-        0.04112f,
-        0.04236f,
-        0.04013f,
-        0.03742f,
-        0.03049f,
-        0.02175f,
-        0.01313f,
-        0.00462f,
-        -0.00189f,
-        -0.00462f,
-        -0.00703f,
-        -0.00794f,
-        -0.00885f,
-        -0.01051f,
-        -0.01217f,
-        -0.01052f,
-        -0.00811f,
-        -0.00207f,
-        0.00602f,
-        0.01504f,
-        0.02514f,
-        0.03470f,
-        0.04289f,
-        0.05020f,
-        0.05022f,
-        0.05024f,
-        0.03943f,
-        0.02781f,
-        0.01278f,
-        -0.00337f,
-        -0.01711f,
-        -0.02908f,
-        -0.03894f,
-        -0.04563f,
-        -0.05179f,
-        -0.05615f,
-        -0.06056f,
-        -0.06599f,
-        -0.07142f,
-        -0.07839f,
-        -0.08558f,
-        -0.09063f,
-        -0.09472f,
-        -0.09483f,
-        -0.09120f,
-        -0.08566f,
-        -0.07639f,
-        -0.06745f,
-        -0.06026f,
-        -0.05306f,
-        -0.05392f,
-        -0.05488f,
-        -0.05875f,
-        -0.06330f,
-        -0.06427f,
-        -0.06316f,
-        -0.05980f,
-        -0.05374f,
-        -0.04786f,
-        -0.04241f,
-        -0.03702f,
-        -0.03203f,
-        -0.02705f,
-        -0.02298f,
-        -0.01899f,
-        -0.01750f,
-        -0.01686f,
-        -0.01674f,
-        -0.01699f,
-        -0.01701f,
-        -0.01664f,
-        -0.01662f,
-        -0.01780f,
-        -0.01897f,
-        -0.01983f,
-        -0.02069f,
-        -0.01922f,
-        -0.01739f,
-        -0.01492f,
-        -0.01216f,
-        -0.00890f,
-        -0.00516f,
-        -0.00076f,
-        0.00494f,
-        0.01046f,
-        0.01499f,
-        0.01951f,
-        0.01981f,
-        0.02001f,
-        0.01556f,
-        0.00997f,
-        0.00113f,
-        -0.00965f,
-        -0.01962f,
-        -0.02861f,
-        -0.03515f,
-        -0.03516f,
-        -0.03448f,
-        -0.02720f,
-        -0.01991f,
-        -0.01076f,
-        -0.00144f,
-        0.00795f,
-        0.01736f,
-        0.02619f,
-        0.03457f,
-        0.04165f,
-        0.04667f,
-        0.05059f,
-        0.05038f,
-        0.05003f,
-        0.04579f,
-        0.04156f,
-        0.03646f,
-        0.03121f,
-        0.02535f,
-        0.01919f,
-        0.01284f,
-        0.00629f,
-        0.00116f,
-        -0.00106f,
-        -0.00252f,
-        0.00034f,
-        0.00319f,
-        0.00610f,
-        0.00900f,
-        0.01096f,
-        0.01267f,
-        0.01435f,
-        0.01602f,
-        0.01701f,
-        0.01716f,
-        0.01711f,
-        0.01651f,
-        0.01601f,
-        0.01649f,
-        0.01698f,
-        0.01726f,
-        0.01753f,
-        0.01877f,
-        0.02036f,
-        0.02420f,
-        0.02981f,
-        0.03539f,
-        0.04091f,
-        0.04534f,
-        0.04547f,
-        0.04546f,
-        0.04027f,
-        0.03507f,
-        0.02762f,
-        0.01977f,
-        0.01352f,
-        0.00806f,
-        0.00608f,
-        0.00766f,
-        0.01064f,
-        0.01662f,
-        0.02229f,
-        0.02605f,
-        0.02982f,
-        0.02799f,
-        0.02595f,
-        0.01948f,
-        0.01182f,
-        0.00319f,
-        -0.00605f,
-        -0.01369f,
-        -0.01924f,
-        -0.02382f,
-        -0.02559f,
-        -0.02737f,
-        -0.02927f,
-        -0.03117f,
-        -0.03474f,
-        -0.03850f,
-        -0.04191f,
-        -0.04520f,
-        -0.04596f,
-        -0.04464f,
-        -0.04147f,
-        -0.03516f,
-        -0.02891f,
-        -0.02290f,
-        -0.01697f,
-        -0.01473f,
-        -0.01249f,
-        -0.01147f,
-        -0.01067f,
-        -0.00886f,
-        -0.00654f,
-        -0.00353f,
-        0.00020f,
-        0.00368f,
-        0.00662f,
-        0.00917f,
-        0.00917f,
-        0.00917f,
-        0.00679f,
-        0.00430f,
-        0.00202f,
-        -0.00021f,
-        -0.00082f,
-        -0.00037f,
-        0.00151f,
-        0.00529f,
-        0.00911f,
-        0.01303f,
-        0.01660f,
-        0.01558f,
-        0.01457f,
-        0.00939f,
-        0.00372f,
-        -0.00124f,
-        -0.00593f,
-        -0.00835f,
-        -0.00888f,
-        -0.00844f,
-        -0.00635f,
-        -0.00434f,
-        -0.00269f,
-        -0.00108f,
-        -0.00176f,
-        -0.00244f,
-        -0.00397f,
-        -0.00568f,
-        -0.00643f,
-        -0.00669f,
-        -0.00610f,
-        -0.00462f,
-        -0.00282f,
-        -0.00032f,
-        0.00222f,
-        0.00493f,
-        0.00765f,
-        0.00875f,
-        0.00977f,
-        0.00897f,
-        0.00764f,
-        0.00648f,
-        0.00544f,
-        0.00556f,
-        0.00728f,
-        0.00944f,
-        0.01294f,
-        0.01639f,
-        0.01909f,
-        0.02178f,
-        0.02238f,
-        0.02271f,
-        0.02123f,
-        0.01902f,
-        0.01582f,
-        0.01177f,
-        0.00780f,
-        0.00398f,
-        0.00061f,
-        -0.00067f,
-        -0.00194f,
-        0.00012f,
-        0.00218f,
-        0.00631f,
-        0.01087f,
-        0.01563f,
-        0.02050f,
-        0.02418f,
-        0.02655f,
-        0.02805f,
-        0.02751f,
-        0.02673f,
-        0.02415f,
-        0.02158f,
-        0.01575f,
-        0.00972f,
-        0.00075f,
-        -0.00910f,
-        -0.01921f,
-        -0.02950f,
-        -0.03903f,
-        -0.04748f,
-        -0.05526f,
-        -0.06091f,
-        -0.06624f,
-        -0.06662f,
-        -0.06700f,
-        -0.06315f,
-        -0.05874f,
-        -0.05348f,
-        -0.04787f,
-        -0.04189f,
-        -0.03560f,
-        -0.02922f,
-        -0.02270f,
-        -0.01667f,
-        -0.01297f,
-        -0.00927f,
-        -0.00694f,
-        -0.00461f,
-        -0.00043f,
-        0.00415f,
-        0.00842f,
-        0.01252f,
-        0.01500f,
-        0.01563f,
-        0.01591f,
-        0.01533f,
-        0.01471f,
-        0.01382f,
-        0.01294f,
-        0.01084f,
-        0.00866f,
-        0.00666f,
-        0.00473f,
-        0.00315f,
-        0.00184f,
-        -0.00010f,
-        -0.00296f,
-        -0.00598f,
-        -0.00955f,
-        -0.01299f,
-        -0.01416f,
-        -0.01533f,
-        -0.01398f,
-        -0.01227f,
-        -0.00969f,
-        -0.00672f,
-        -0.00415f,
-        -0.00194f,
-        -0.00092f,
-        -0.00213f,
-        -0.00398f,
-        -0.00902f,
-        -0.01405f,
-        -0.01891f,
-        -0.02377f,
-        -0.02543f,
-        -0.02635f,
-        -0.02531f,
-        -0.02316f,
-        -0.02075f,
-        -0.01804f,
-        -0.01533f,
-        -0.01261f,
-        -0.00991f,
-        -0.00744f,
-        -0.00497f,
-        -0.00338f,
-        -0.00186f,
-        -0.00082f,
-        0.00007f,
-        0.00120f,
-        0.00251f,
-        0.00443f,
-        0.00724f,
-        0.01042f,
-        0.01485f,
-        0.01930f,
-        0.02396f,
-        0.02861f,
-        0.03317f,
-        0.03772f,
-        0.04248f,
-        0.04733f,
-        0.05081f,
-        0.05300f,
-        0.05342f,
-        0.05039f,
-        0.04707f,
-        0.04229f,
-        0.03751f,
-        0.03438f,
-        0.03127f,
-        0.02933f,
-        0.02766f,
-        0.02751f,
-        0.02823f,
-        0.02944f,
-        0.03125f,
-        0.03180f,
-        0.02912f,
-        0.02608f,
-        0.01999f,
-        0.01389f,
-        0.01085f,
-        0.00806f,
-        0.00726f,
-        0.00712f,
-        0.00602f,
-        0.00420f,
-        0.00240f,
-        0.00063f,
-        -0.00073f,
-        -0.00058f,
-        -0.00047f,
-        -0.00144f,
-        -0.00241f,
-        -0.00545f,
-        -0.00883f,
-        -0.01159f,
-        -0.01407f,
-        -0.01470f,
-        -0.01354f,
-        -0.01144f,
-        -0.00744f,
-        -0.00342f,
-        0.00073f,
-        0.00487f,
-        0.00685f,
-        0.00878f,
-        0.00888f,
-        0.00853f,
-        0.00793f,
-        0.00717f,
-        0.00681f,
-        0.00694f,
-        0.00719f,
-        0.00780f,
-        0.00836f,
-        0.00861f,
-        0.00886f,
-        0.00880f,
-        0.00872f,
-        0.00851f,
-        0.00825f,
-        0.00755f,
-        0.00650f,
-        0.00503f,
-        0.00287f,
-        0.00083f,
-        -0.00078f,
-        -0.00229f,
-        -0.00072f,
-        0.00084f,
-        0.00433f,
-        0.00815f,
-        0.00982f,
-        0.01047f,
-        0.00854f,
-        0.00403f,
-        -0.00064f,
-        -0.00565f,
-        -0.01023f,
-        -0.01229f,
-        -0.01435f,
-        -0.01460f,
-        -0.01480f,
-        -0.01449f,
-        -0.01404f,
-        -0.01365f,
-        -0.01329f,
-        -0.01327f,
-        -0.01367f,
-        -0.01406f,
-        -0.01439f,
-        -0.01463f,
-        -0.01388f,
-        -0.01313f,
-        -0.01185f,
-        -0.01052f,
-        -0.00995f,
-        -0.00966f,
-        -0.01063f,
-        -0.01261f,
-        -0.01482f,
-        -0.01741f,
-        -0.01938f,
-        -0.01895f,
-        -0.01844f,
-        -0.01486f,
-        -0.01128f,
-        -0.00753f,
-        -0.00376f,
-        -0.00074f,
-        0.00191f,
-        0.00352f,
-        0.00407f,
-        0.00368f,
-        0.00130f,
-        -0.00109f,
-        -0.00349f,
-        -0.00589f,
-        -0.00502f,
-        -0.00404f,
-        -0.00156f,
-        0.00133f,
-        0.00324f,
-        0.00454f,
-        0.00478f,
-        0.00364f,
-        0.00253f,
-        0.00150f,
-        0.00070f,
-        0.00244f,
-        0.00417f,
-        0.00645f,
-        0.00879f,
-        0.00889f,
-        0.00814f,
-        0.00647f,
-        0.00405f,
-        0.00198f,
-        0.00050f,
-        -0.00103f,
-        -0.00275f,
-        -0.00449f,
-        -0.00716f,
-        -0.00983f,
-        -0.01228f,
-        -0.01469f,
-        -0.01690f,
-        -0.01903f,
-        -0.02089f,
-        -0.02250f,
-        -0.02354f,
-        -0.02334f,
-        -0.02289f,
-        -0.02080f,
-        -0.01872f,
-        -0.01567f,
-        -0.01258f,
-        -0.00976f,
-        -0.00702f,
-        -0.00532f,
-        -0.00432f,
-        -0.00381f,
-        -0.00393f,
-        -0.00395f,
-        -0.00362f,
-        -0.00321f,
-        -0.00168f,
-        -0.00015f,
-        0.00332f,
-        0.00702f,
-        0.01148f,
-        0.01625f,
-        0.01948f,
-        0.02141f,
-        0.02201f,
-        0.02028f,
-        0.01831f,
-        0.01532f,
-        0.01231f,
-        0.00872f,
-        0.00512f,
-        0.00181f,
-        -0.00144f,
-        -0.00316f,
-        -0.00407f,
-        -0.00431f,
-        -0.00381f,
-        -0.00341f,
-        -0.00322f,
-        -0.00300f,
-        -0.00262f,
-        -0.00224f,
-        -0.00176f,
-        -0.00127f,
-        -0.00115f,
-        -0.00114f,
-        -0.00118f,
-        -0.00126f,
-        -0.00169f,
-        -0.00261f,
-        -0.00391f,
-        -0.00639f,
-        -0.00883f,
-        -0.01058f,
-        -0.01233f,
-        -0.01189f,
-        -0.01119f,
-        -0.00977f,
-        -0.00807f,
-        -0.00648f,
-        -0.00500f,
-        -0.00363f,
-        -0.00244f,
-        -0.00131f,
-        -0.00041f,
-        0.00050f,
-        0.00205f,
-        0.00360f,
-        0.00630f,
-        0.00922f,
-        0.01208f,
-        0.01489f,
-        0.01681f,
-        0.01775f,
-        0.01841f,
-        0.01842f,
-        0.01855f,
-        0.01948f,
-        0.02040f,
-        0.02114f,
-        0.02187f,
-        0.02085f,
-        0.01930f,
-        0.01690f,
-        0.01390f,
-        0.01117f,
-        0.00880f,
-        0.00676f,
-        0.00581f,
-        0.00495f,
-        0.00549f,
-        0.00603f,
-        0.00704f,
-        0.00811f,
-        0.00816f,
-        0.00779f,
-        0.00619f,
-        0.00350f,
-        0.00019f,
-        -0.00426f,
-        -0.00865f,
-        -0.01273f,
-        -0.01681f,
-        -0.01717f,
-        -0.01753f,
-        -0.01511f,
-        -0.01210f,
-        -0.00970f,
-        -0.00763f,
-        -0.00663f,
-        -0.00684f,
-        -0.00710f,
-        -0.00749f,
-        -0.00781f,
-        -0.00764f,
-        -0.00747f,
-        -0.00633f,
-        -0.00512f,
-        -0.00298f,
-        -0.00055f,
-        0.00126f,
-        0.00262f,
-        0.00327f,
-        0.00286f,
-        0.00261f,
-        0.00287f,
-        0.00315f,
-        0.00398f,
-        0.00480f,
-        0.00464f,
-        0.00435f,
-        0.00406f,
-        0.00377f,
-        0.00393f,
-        0.00450f,
-        0.00492f,
-        0.00505f,
-        0.00506f,
-        0.00448f,
-        0.00389f,
-        0.00301f,
-        0.00212f,
-        0.00069f,
-        -0.00086f,
-        -0.00241f,
-        -0.00397f,
-        -0.00500f,
-        -0.00540f,
-        -0.00561f,
-        -0.00534f,
-        -0.00515f,
-        -0.00562f,
-        -0.00609f,
-        -0.00771f,
-        -0.00941f,
-        -0.01114f,
-        -0.01288f,
-        -0.01369f,
-        -0.01382f,
-        -0.01345f,
-        -0.01234f,
-        -0.01131f,
-        -0.01055f,
-        -0.00980f,
-        -0.00909f,
-        -0.00838f,
-        -0.00710f,
-        -0.00573f,
-        -0.00485f,
-        -0.00417f,
-        -0.00406f,
-        -0.00446f,
-        -0.00449f,
-        -0.00383f,
-        -0.00293f,
-        -0.00082f,
-        0.00128f,
-        0.00246f,
-        0.00364f,
-        0.00340f,
-        0.00283f,
-        0.00164f,
-        0.00009f,
-        -0.00195f,
-        -0.00459f,
-        -0.00732f,
-        -0.01031f,
-        -0.01311f,
-        -0.01424f,
-        -0.01536f,
-        -0.01433f,
-        -0.01312f,
-        -0.01105f,
-        -0.00868f,
-        -0.00606f,
-        -0.00323f,
-        -0.00061f,
-        0.00167f,
-        0.00362f,
-        0.00438f,
-        0.00512f,
-        0.00531f,
-        0.00549f,
-        0.00578f,
-        0.00608f,
-        0.00586f,
-        0.00540f,
-        0.00456f,
-        0.00337f,
-        0.00223f,
-        0.00121f,
-        0.00028f,
-        -0.00016f,
-        -0.00061f,
-        0.00002f,
-        0.00068f,
-        0.00217f,
-        0.00386f,
-        0.00510f,
-        0.00608f,
-        0.00625f,
-        0.00543f,
-        0.00434f,
-        0.00252f,
-        0.00073f,
-        -0.00073f,
-        -0.00219f,
-        -0.00213f,
-        -0.00193f,
-        -0.00097f,
-        0.00025f,
-        0.00059f,
-        0.00024f,
-        -0.00071f,
-        -0.00262f,
-        -0.00428f,
-        -0.00499f,
-        -0.00564f,
-        -0.00453f,
-        -0.00341f,
-        -0.00195f,
-        -0.00044f,
-        0.00085f,
-        0.00203f,
-        0.00300f,
-        0.00378f,
-        0.00455f,
-        0.00532f,
-        0.00614f,
-        0.00724f,
-        0.00833f,
-        0.00915f,
-        0.00996f,
-        0.01018f,
-        0.01025f,
-        0.00994f,
-        0.00941f,
-        0.00837f,
-        0.00668f,
-        0.00479f,
-        0.00231f,
-        -0.00008f,
-        -0.00156f,
-        -0.00305f,
-        -0.00362f,
-        -0.00409f,
-        -0.00468f,
-        -0.00530f,
-        -0.00562f,
-        -0.00571f,
-        -0.00535f,
-        -0.00429f,
-        -0.00321f,
-        -0.00207f,
-        -0.00095f,
-        -0.00014f,
-        0.00067f,
-        0.00164f,
-        0.00263f,
-        0.00365f,
-        0.00468f,
-        0.00566f,
-        0.00659f,
-        0.00745f,
-        0.00814f,
-        0.00868f,
-        0.00825f,
-        0.00782f,
-        0.00644f,
-        0.00503f,
-        0.00403f,
-        0.00314f,
-        0.00272f,
-        0.00259f,
-        0.00227f,
-        0.00173f,
-        0.00106f,
-        0.00003f,
-        -0.00098f,
-        -0.00190f,
-        -0.00282f,
-        -0.00382f,
-        -0.00482f,
-        -0.00597f,
-        -0.00718f,
-        -0.00810f,
-        -0.00878f,
-        -0.00915f,
-        -0.00900f,
-        -0.00875f,
-        -0.00816f,
-        -0.00756f,
-        -0.00670f,
-        -0.00585f,
-        -0.00458f,
-        -0.00324f,
-        -0.00140f,
-        0.00068f,
-        0.00293f,
-        0.00533f,
-        0.00743f,
-        0.00885f,
-        0.01007f,
-        0.01000f,
-        0.00993f,
-        0.00917f,
-        0.00838f,
-        0.00727f,
-        0.00607f,
-        0.00479f,
-        0.00347f,
-        0.00251f,
-        0.00201f,
-        0.00160f,
-        0.00142f,
-        0.00117f,
-        0.00002f,
-        -0.00113f,
-        -0.00235f,
-        -0.00359f,
-        -0.00409f,
-        -0.00431f,
-        -0.00455f,
-        -0.00481f,
-        -0.00517f,
-        -0.00572f,
-        -0.00609f,
-        -0.00571f,
-        -0.00532f,
-        -0.00412f,
-        -0.00291f,
-        -0.00181f,
-        -0.00074f,
-        -0.00002f,
-        0.00052f,
-        0.00068f,
-        0.00043f,
-        0.00009f,
-        -0.00048f,
-        -0.00094f,
-        -0.00074f,
-        -0.00054f,
-        0.00035f,
-        0.00127f,
-        0.00228f,
-        0.00331f,
-        0.00437f,
-        0.00544f,
-        0.00637f,
-        0.00711f,
-        0.00763f,
-        0.00746f,
-        0.00725f,
-        0.00653f,
-        0.00580f,
-        0.00496f,
-        0.00410f,
-        0.00323f,
-        0.00235f,
-        0.00168f,
-        0.00117f,
-        0.00073f,
-        0.00039f,
-        -0.00006f,
-        -0.00096f,
-        -0.00187f,
-        -0.00320f,
-        -0.00452f,
-        -0.00562f,
-        -0.00667f,
-        -0.00749f,
-        -0.00819f,
-        -0.00869f,
-        -0.00897f,
-        -0.00893f,
-        -0.00816f,
-        -0.00727f,
-        -0.00551f,
-        -0.00374f,
-        -0.00196f,
-        -0.00018f,
-        0.00098f,
-        0.00195f,
-        0.00237f,
-        0.00240f,
-        0.00216f,
-        0.00152f,
-        0.00091f,
-        0.00035f,
-        -0.00015f,
-        0.00019f,
-        0.00053f,
-        0.00134f,
-        0.00221f,
-        0.00276f,
-        0.00316f,
-        0.00330f,
-        0.00320f,
-        0.00303f,
-        0.00273f,
-        0.00239f,
-        0.00190f,
-        0.00140f,
-        0.00117f,
-        0.00093f,
-        0.00118f,
-        0.00153f,
-        0.00192f,
-        0.00233f,
-        0.00262f,
-        0.00278f,
-        0.00288f,
-        0.00286f,
-        0.00279f,
-        0.00234f,
-        0.00189f,
-        0.00117f,
-        0.00044f,
-        -0.00019f,
-        -0.00080f,
-        -0.00134f,
-        -0.00184f,
-        -0.00227f,
-        -0.00260f,
-        -0.00279f,
-        -0.00255f,
-        -0.00229f,
-        -0.00165f,
-        -0.00102f,
-        -0.00040f,
-        0.00022f,
-        0.00077f,
-        0.00129f,
-        0.00159f,
-        0.00168f,
-        0.00157f,
-        0.00108f,
-        0.00060f,
-        0.00012f,
-        -0.00036f,
-        -0.00039f,
-        -0.00041f,
-        -0.00015f,
-        0.00019f,
-        0.00058f,
-        0.00100f,
-        0.00136f,
-        0.00165f,
-        0.00195f,
-        0.00230f,
-        0.00269f,
-        0.00335f,
-        0.00401f,
-        0.00457f,
-        0.00512f,
-        0.00536f,
-        0.00550f,
-        0.00546f,
-        0.00529f,
-        0.00491f,
-        0.00420f,
-        0.00339f,
-        0.00223f,
-        0.00109f,
-        0.00045f,
-        -0.00019f,
-        -0.00013f,
-        0.00003f,
-        0.00012f,
-        0.00017f,
-        -0.00009f,
-        -0.00065f,
-        -0.00120f,
-        -0.00176f,
-        -0.00221f,
-        -0.00209f,
-        -0.00197f,
-        -0.00114f,
-        -0.00030f,
-        0.00061f,
-        0.00155f,
-        0.00220f,
-        0.00268f,
-        0.00294f,
-        0.00290f,
-        0.00272f,
-        0.00215f,
-        0.00155f,
-        0.00068f,
-        -0.00019f,
-        -0.00080f,
-        -0.00137f,
-        -0.00167f,
-        -0.00188f,
-        -0.00220f,
-        -0.00259f,
-        -0.00310f,
-        -0.00380f,
-        -0.00448f,
-        -0.00506f,
-        -0.00562f,
-        -0.00574f,
-        -0.00585f,
-        -0.00554f,
-        -0.00515f,
-        -0.00468f,
-        -0.00418f,
-        -0.00378f,
-        -0.00349f,
-        -0.00323f,
-        -0.00306f,
-        -0.00286f,
-        -0.00256f,
-        -0.00226f,
-        -0.00178f,
-        -0.00130f,
-        -0.00078f,
-        -0.00026f,
-        0.00005f,
-        0.00022f,
-        0.00011f,
-        -0.00033f,
-        -0.00081f,
-        -0.00142f,
-        -0.00198f,
-        -0.00215f,
-        -0.00233f,
-        -0.00212f,
-        -0.00187f,
-        -0.00151f,
-        -0.00110f,
-        -0.00065f,
-        -0.00018f,
-        0.00027f,
-        0.00070f,
-        0.00105f,
-        0.00115f,
-        0.00124f,
-        0.00086f,
-        0.00047f,
-        -0.00018f,
-        -0.00088f,
-        -0.00150f,
-        -0.00208f,
-        -0.00252f,
-        -0.00283f,
-        -0.00311f,
-        -0.00332f,
-        -0.00354f,
-        -0.00378f,
-        -0.00402f,
-        -0.00419f,
-        -0.00436f,
-        -0.00432f,
-        -0.00423f,
-        -0.00391f,
-        -0.00347f,
-        -0.00292f,
-        -0.00225f,
-        -0.00159f,
-        -0.00098f,
-        -0.00039f,
-        -0.00008f,
-        0.00023f,
-        0.00039f,
-        0.00053f,
-        0.00071f,
-        0.00090f,
-        0.00099f,
-        0.00100f,
-        0.00090f,
-        0.00063f,
-        0.00041f,
-        0.00040f,
-        0.00040f,
-        0.00086f,
-        0.00132f,
-        0.00085f,
-        0.00021f};
+std::span<const CSAMPLE> clickForSampleRate(mixxx::audio::SampleRate rate);
diff --git a/src/effects/backends/builtin/metronomeeffect.cpp b/src/effects/backends/builtin/metronomeeffect.cpp
index bd6f96956d3..a73c1b8d6cb 100644
--- a/src/effects/backends/builtin/metronomeeffect.cpp
+++ b/src/effects/backends/builtin/metronomeeffect.cpp
@@ -64,15 +64,9 @@ void MetronomeEffect::processChannel(
 
     MetronomeGroupState* gs = pGroupState;
 
-    SINT clickSize = kClickSize44100;
-    const CSAMPLE* click = kClick44100;
-    if (engineParameters.sampleRate() >= 96000) {
-        clickSize = kClickSize96000;
-        click = kClick96000;
-    } else if (engineParameters.sampleRate() >= 48000) {
-        clickSize = kClickSize48000;
-        click = kClick48000;
-    }
+    std::span<const CSAMPLE> clickSpan = clickForSampleRate(engineParameters.sampleRate());
+    SINT clickSize = clickSpan.size();
+    const CSAMPLE* click = clickSpan.data();
 
     if (pOutput != pInput) {
         SampleUtil::copy(pOutput, pInput, engineParameters.samplesPerBuffer());

From 5e74ec69b6cc82ab13daddec1e7bded637ed9c1d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= <daschuer@mixxx.org>
Date: Fri, 13 Sep 2024 00:01:49 +0200
Subject: [PATCH 32/36] Fix metronome without a sync enabled

---
 src/effects/backends/builtin/metronomeeffect.cpp | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/effects/backends/builtin/metronomeeffect.cpp b/src/effects/backends/builtin/metronomeeffect.cpp
index a73c1b8d6cb..e22dfc36913 100644
--- a/src/effects/backends/builtin/metronomeeffect.cpp
+++ b/src/effects/backends/builtin/metronomeeffect.cpp
@@ -100,7 +100,8 @@ void MetronomeEffect::processChannel(
                 if (*groupFeatures.scratch_rate != 0.0) {
                     beatLength /= *groupFeatures.scratch_rate;
                 } else {
-                    beatLength = 0;
+                    // no transport, nothing to do.
+                    return;
                 }
             }
 
@@ -133,10 +134,10 @@ void MetronomeEffect::processChannel(
             const SINT copyFrames =
                     math_min(engineParameters.framesPerBuffer() - outputOffset, clickSize);
             SampleUtil::addMonoToStereo(&pOutput[outputOffset * 2], &click[0], copyFrames);
-            gs->m_framesSinceClickStart = -outputOffset;
         }
+        // Due to seeking, we may have missed the start position of the click.
+        // We pretend that it has been played to stay in phase
+        gs->m_framesSinceClickStart = -outputOffset;
     }
-    if (gs->m_framesSinceClickStart < engineParameters.framesPerBuffer() + clickSize) {
-        gs->m_framesSinceClickStart += engineParameters.framesPerBuffer();
-    }
+    gs->m_framesSinceClickStart += engineParameters.framesPerBuffer();
 }

From 26d3029c5dd05db6f1792b00ab370796b4aeafc7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= <daschuer@mixxx.org>
Date: Fri, 13 Sep 2024 13:51:14 +0200
Subject: [PATCH 33/36] Avoid to fade in the metronome effect, because this
 would mangle the first click.

---
 src/effects/backends/builtin/metronomeeffect.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/effects/backends/builtin/metronomeeffect.cpp b/src/effects/backends/builtin/metronomeeffect.cpp
index e22dfc36913..80fdc84bf36 100644
--- a/src/effects/backends/builtin/metronomeeffect.cpp
+++ b/src/effects/backends/builtin/metronomeeffect.cpp
@@ -19,6 +19,7 @@ EffectManifestPointer MetronomeEffect::getManifest() {
     pManifest->setAuthor("The Mixxx Team");
     pManifest->setVersion("1.0");
     pManifest->setDescription(QObject::tr("Adds a metronome click sound to the stream"));
+    pManifest->setEffectRampsFromDry(true);
 
     // Period
     // The maximum is at 128 + 1 allowing 128 as max value and

From 2081952f57023cdef149334541db4f9810d521bd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= <daschuer@mixxx.org>
Date: Fri, 13 Sep 2024 20:37:30 +0200
Subject: [PATCH 34/36] Combine frames and scratch_rate into one optional
 because they are always valid.

---
 .../backends/builtin/autopaneffect.cpp        |  4 ++--
 src/effects/backends/builtin/echoeffect.cpp   |  4 ++--
 .../backends/builtin/flangereffect.cpp        |  4 ++--
 .../backends/builtin/metronomeeffect.cpp      | 21 +++++++------------
 src/effects/backends/builtin/phasereffect.cpp |  4 ++--
 .../backends/builtin/tremoloeffect.cpp        |  8 +++----
 src/engine/controls/bpmcontrol.cpp            |  3 +--
 src/engine/effects/groupfeaturestate.h        | 15 +++++++------
 8 files changed, 30 insertions(+), 33 deletions(-)

diff --git a/src/effects/backends/builtin/autopaneffect.cpp b/src/effects/backends/builtin/autopaneffect.cpp
index 0aab16ea246..4ad814feecf 100644
--- a/src/effects/backends/builtin/autopaneffect.cpp
+++ b/src/effects/backends/builtin/autopaneffect.cpp
@@ -88,10 +88,10 @@ void AutoPanEffect::processChannel(
     double period = m_pPeriodParameter->value();
     const auto smoothing = static_cast<float>(0.5 - m_pSmoothingParameter->value());
 
-    if (groupFeatures.beat_length_frames.has_value()) {
+    if (groupFeatures.beat_length.has_value()) {
         // period is a number of beats
         double beats = std::max(roundToFraction(period, 2), 0.25);
-        period = beats * *groupFeatures.beat_length_frames;
+        period = beats * groupFeatures.beat_length->frames;
 
         // TODO(xxx) sync phase
         //if (groupFeatures.has_beat_fraction) {
diff --git a/src/effects/backends/builtin/echoeffect.cpp b/src/effects/backends/builtin/echoeffect.cpp
index 1c01137d91b..97096919bf4 100644
--- a/src/effects/backends/builtin/echoeffect.cpp
+++ b/src/effects/backends/builtin/echoeffect.cpp
@@ -132,7 +132,7 @@ void EchoEffect::processChannel(
     const auto pingpong_frac = static_cast<CSAMPLE_GAIN>(m_pPingPongParameter->value());
 
     int delay_frames;
-    if (groupFeatures.beat_length_frames.has_value()) {
+    if (groupFeatures.beat_length.has_value()) {
         // period is a number of beats
         if (m_pQuantizeParameter->toBool()) {
             period = std::max(roundToFraction(period, 4), 1 / 8.0);
@@ -142,7 +142,7 @@ void EchoEffect::processChannel(
         } else if (period < 1 / 8.0) {
             period = 1 / 8.0;
         }
-        delay_frames = static_cast<int>(period * *groupFeatures.beat_length_frames);
+        delay_frames = static_cast<int>(period * groupFeatures.beat_length->frames);
     } else {
         // period is a number of seconds
         period = std::max(period, 1 / 8.0);
diff --git a/src/effects/backends/builtin/flangereffect.cpp b/src/effects/backends/builtin/flangereffect.cpp
index 426397ca4b3..c21e16d95cf 100644
--- a/src/effects/backends/builtin/flangereffect.cpp
+++ b/src/effects/backends/builtin/flangereffect.cpp
@@ -117,13 +117,13 @@ void FlangerEffect::processChannel(
         const GroupFeatureState& groupFeatures) {
     double lfoPeriodParameter = m_pSpeedParameter->value();
     double lfoPeriodFrames;
-    if (groupFeatures.beat_length_frames.has_value()) {
+    if (groupFeatures.beat_length.has_value()) {
         // lfoPeriodParameter is a number of beats
         lfoPeriodParameter = std::max(roundToFraction(lfoPeriodParameter, 2.0), kMinLfoBeats);
         if (m_pTripletParameter->toBool()) {
             lfoPeriodParameter /= 3.0;
         }
-        lfoPeriodFrames = lfoPeriodParameter * *groupFeatures.beat_length_frames;
+        lfoPeriodFrames = lfoPeriodParameter * groupFeatures.beat_length->frames;
     } else {
         // lfoPeriodParameter is a number of seconds
         lfoPeriodFrames = std::max(lfoPeriodParameter, kMinLfoBeats) *
diff --git a/src/effects/backends/builtin/metronomeeffect.cpp b/src/effects/backends/builtin/metronomeeffect.cpp
index 80fdc84bf36..2a50a3b1937 100644
--- a/src/effects/backends/builtin/metronomeeffect.cpp
+++ b/src/effects/backends/builtin/metronomeeffect.cpp
@@ -94,18 +94,12 @@ void MetronomeEffect::processChannel(
     double bufferEnd = gs->m_framesSinceClickStart + engineParameters.framesPerBuffer();
 
     double nextClickStart = bufferEnd; // default to "no new click";
-    if (m_pSyncParameter->toBool() && groupFeatures.beat_length_frames.has_value()) {
-        if (groupFeatures.beat_fraction_buffer_end.has_value()) {
-            double beatLength = *groupFeatures.beat_length_frames;
-            if (groupFeatures.scratch_rate.has_value()) {
-                if (*groupFeatures.scratch_rate != 0.0) {
-                    beatLength /= *groupFeatures.scratch_rate;
-                } else {
-                    // no transport, nothing to do.
-                    return;
-                }
-            }
-
+    if (m_pSyncParameter->toBool() && groupFeatures.beat_fraction_buffer_end.has_value()) {
+        // Sync enabled and have a track with beats
+        if (groupFeatures.beat_length.has_value() &&
+                groupFeatures.beat_length->scratch_rate != 0.0) {
+            double beatLength = groupFeatures.beat_length->frames /
+                    groupFeatures.beat_length->scratch_rate;
             double beatToBufferEnd;
             if (beatLength > 0) {
                 beatToBufferEnd =
@@ -122,7 +116,8 @@ void MetronomeEffect::processChannel(
                 nextClickStart = bufferEnd - beatToBufferEnd;
             }
         } else {
-            nextClickStart = *groupFeatures.beat_length_frames;
+            // no transport, nothing to do.
+            return;
         }
     } else {
         nextClickStart = engineParameters.sampleRate() * 60 / m_pBpmParameter->value();
diff --git a/src/effects/backends/builtin/phasereffect.cpp b/src/effects/backends/builtin/phasereffect.cpp
index cf1e7a89d4d..709d23d09a8 100644
--- a/src/effects/backends/builtin/phasereffect.cpp
+++ b/src/effects/backends/builtin/phasereffect.cpp
@@ -132,13 +132,13 @@ void PhaserEffect::processChannel(
 
     double periodParameter = m_pLFOPeriodParameter->value();
     double periodSamples;
-    if (groupFeatures.beat_length_frames.has_value()) {
+    if (groupFeatures.beat_length.has_value()) {
         // periodParameter is a number of beats
         periodParameter = std::max(roundToFraction(periodParameter, 2.0), 1 / 4.0);
         if (m_pTripletParameter->toBool()) {
             periodParameter /= 3.0;
         }
-        periodSamples = periodParameter * *groupFeatures.beat_length_frames;
+        periodSamples = periodParameter * groupFeatures.beat_length->frames;
     } else {
         // periodParameter is a number of seconds
         periodSamples = std::max(periodParameter, 1 / 4.0) * engineParameters.sampleRate();
diff --git a/src/effects/backends/builtin/tremoloeffect.cpp b/src/effects/backends/builtin/tremoloeffect.cpp
index 6b8924689fc..a1fe119de02 100644
--- a/src/effects/backends/builtin/tremoloeffect.cpp
+++ b/src/effects/backends/builtin/tremoloeffect.cpp
@@ -138,9 +138,9 @@ void TremoloEffect::processChannel(
     bool tripletDisabling = pState->tripletEnabled && !m_pTripletParameter->toBool();
 
     if (enableState == EffectEnableState::Enabling || quantizeEnabling || tripletDisabling) {
-        if (gf.beat_length_frames.has_value() && gf.beat_fraction_buffer_end.has_value()) {
+        if (gf.beat_length.has_value() && gf.beat_fraction_buffer_end.has_value()) {
             currentFrame = static_cast<unsigned int>(*gf.beat_fraction_buffer_end *
-                    *gf.beat_length_frames);
+                    gf.beat_length->frames);
         } else {
             currentFrame = 0;
         }
@@ -149,7 +149,7 @@ void TremoloEffect::processChannel(
 
     int framePerPeriod;
     double rate = m_pRateParameter->value();
-    if (gf.beat_length_frames.has_value() && gf.beat_fraction_buffer_end.has_value()) {
+    if (gf.beat_length.has_value() && gf.beat_fraction_buffer_end.has_value()) {
         if (m_pQuantizeParameter->toBool()) {
             const auto divider = static_cast<int>(log2(rate));
             rate = pow(2, divider);
@@ -158,7 +158,7 @@ void TremoloEffect::processChannel(
                 rate *= 3.0;
             }
         }
-        const auto framePerBeat = static_cast<int>(*gf.beat_length_frames);
+        const auto framePerBeat = static_cast<int>(gf.beat_length->frames);
         framePerPeriod = static_cast<int>(framePerBeat / rate);
     } else {
         framePerPeriod = static_cast<int>(engineParameters.sampleRate() / rate);
diff --git a/src/engine/controls/bpmcontrol.cpp b/src/engine/controls/bpmcontrol.cpp
index b5a73904b2f..2ca2dbff5be 100644
--- a/src/engine/controls/bpmcontrol.cpp
+++ b/src/engine/controls/bpmcontrol.cpp
@@ -1108,8 +1108,7 @@ void BpmControl::collectFeatures(GroupFeatureState* pGroupFeatures, double speed
                 &beatFraction)) {
         const double rateRatio = m_pRateRatio->get();
         if (rateRatio != 0.0) {
-            pGroupFeatures->beat_length_frames = beatLengthFrames / rateRatio;
-            pGroupFeatures->scratch_rate = speed / rateRatio;
+            pGroupFeatures->beat_length = {beatLengthFrames / rateRatio, speed / rateRatio};
         }
         pGroupFeatures->beat_fraction_buffer_end = beatFraction;
     }
diff --git a/src/engine/effects/groupfeaturestate.h b/src/engine/effects/groupfeaturestate.h
index 8abbd02c49d..2abc0310509 100644
--- a/src/engine/effects/groupfeaturestate.h
+++ b/src/engine/effects/groupfeaturestate.h
@@ -2,16 +2,19 @@
 
 #include <optional>
 
+struct GroupFeatureBeatLength {
+    // Beat length adjusted by the rate slider
+    double frames;
+    // Rate change by temporary actions like scratching
+    // and not the rate slider.
+    double scratch_rate;
+};
+
 /// GroupFeatureState communicates metadata about EngineChannels to EffectProcessors.
 struct GroupFeatureState {
     GroupFeatureState() = default;
 
-    // Adjusted by the rate slider
-    std::optional<double> beat_length_frames;
-
-    // Rate change by temporary actions like scratching
-    // and not the rate slider.
-    std::optional<double> scratch_rate;
+    std::optional<GroupFeatureBeatLength> beat_length;
 
     // Beat fraction (0.0 to 1.0) of the position at the buffer end.
     // Previous beat is in the current or earlier buffer. The next beat

From f01987449beb22fc89456c20d81369f8507b20de Mon Sep 17 00:00:00 2001
From: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com>
Date: Wed, 11 Sep 2024 22:54:30 +0200
Subject: [PATCH 35/36] refactor: use higher-level `std::span` based logic

---
 .../backends/builtin/metronomeeffect.cpp      | 39 ++++++++++++-------
 1 file changed, 26 insertions(+), 13 deletions(-)

diff --git a/src/effects/backends/builtin/metronomeeffect.cpp b/src/effects/backends/builtin/metronomeeffect.cpp
index 2a50a3b1937..118637e35e7 100644
--- a/src/effects/backends/builtin/metronomeeffect.cpp
+++ b/src/effects/backends/builtin/metronomeeffect.cpp
@@ -6,6 +6,21 @@
 #include "util/math.h"
 #include "util/sample.h"
 
+namespace {
+
+void playMonoSamples(std::span<const CSAMPLE> monoSource, std::span<CSAMPLE> output) {
+    const auto outputBufferFrames = output.size() / mixxx::kEngineChannelCount;
+    SINT framesPlayed = std::min(monoSource.size(), outputBufferFrames);
+    SampleUtil::addMonoToStereo(output.data(), monoSource.data(), framesPlayed);
+}
+
+double framesPerBeat(mixxx::audio::SampleRate sampleRate, double bpm) {
+    double framesPerMinute = sampleRate * 60;
+    return framesPerMinute / bpm;
+}
+
+} // namespace
+
 // static
 QString MetronomeEffect::getId() {
     return "org.mixxx.effects.metronome";
@@ -63,18 +78,21 @@ void MetronomeEffect::processChannel(
         return;
     }
 
+    auto output = std::span<CSAMPLE>(pOutput, engineParameters.samplesPerBuffer());
+
     MetronomeGroupState* gs = pGroupState;
 
-    std::span<const CSAMPLE> clickSpan = clickForSampleRate(engineParameters.sampleRate());
-    SINT clickSize = clickSpan.size();
-    const CSAMPLE* click = clickSpan.data();
+    const std::span<const CSAMPLE> click = clickForSampleRate(engineParameters.sampleRate());
+    SINT clickSize = click.size();
 
     if (pOutput != pInput) {
         SampleUtil::copy(pOutput, pInput, engineParameters.samplesPerBuffer());
     }
 
+    const bool shouldSync = m_pSyncParameter->toBool();
+
     if (enableState == EffectEnableState::Enabling) {
-        if (m_pSyncParameter->toBool() && groupFeatures.beat_fraction_buffer_end.has_value()) {
+        if (shouldSync && groupFeatures.beat_fraction_buffer_end.has_value()) {
             // Skip first click and sync phase
             gs->m_framesSinceClickStart = clickSize;
         } else {
@@ -85,16 +103,13 @@ void MetronomeEffect::processChannel(
 
     if (gs->m_framesSinceClickStart < clickSize) {
         // In click region, write remaining click frames.
-        const SINT copyFrames =
-                math_min(engineParameters.framesPerBuffer(),
-                        clickSize - gs->m_framesSinceClickStart);
-        SampleUtil::addMonoToStereo(pOutput, &click[gs->m_framesSinceClickStart], copyFrames);
+        playMonoSamples(click.subspan(gs->m_framesSinceClickStart), output);
     }
 
     double bufferEnd = gs->m_framesSinceClickStart + engineParameters.framesPerBuffer();
 
     double nextClickStart = bufferEnd; // default to "no new click";
-    if (m_pSyncParameter->toBool() && groupFeatures.beat_fraction_buffer_end.has_value()) {
+    if (shouldSync && groupFeatures.beat_fraction_buffer_end.has_value()) {
         // Sync enabled and have a track with beats
         if (groupFeatures.beat_length.has_value() &&
                 groupFeatures.beat_length->scratch_rate != 0.0) {
@@ -120,16 +135,14 @@ void MetronomeEffect::processChannel(
             return;
         }
     } else {
-        nextClickStart = engineParameters.sampleRate() * 60 / m_pBpmParameter->value();
+        nextClickStart = framesPerBeat(engineParameters.sampleRate(), m_pBpmParameter->value());
     }
 
     if (bufferEnd > nextClickStart) {
         // We need to start a new click
         SINT outputOffset = static_cast<SINT>(nextClickStart) - gs->m_framesSinceClickStart;
         if (outputOffset > 0 && outputOffset < engineParameters.framesPerBuffer()) {
-            const SINT copyFrames =
-                    math_min(engineParameters.framesPerBuffer() - outputOffset, clickSize);
-            SampleUtil::addMonoToStereo(&pOutput[outputOffset * 2], &click[0], copyFrames);
+            playMonoSamples(click, output.subspan(outputOffset * 2));
         }
         // Due to seeking, we may have missed the start position of the click.
         // We pretend that it has been played to stay in phase

From 694542df0fab7d2b75063b74e3e5f2ebe136c333 Mon Sep 17 00:00:00 2001
From: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com>
Date: Sun, 15 Sep 2024 15:00:46 +0200
Subject: [PATCH 36/36] fix: apply GroupFeatureState changes to glitcheffect to
 fix build

---
 src/effects/backends/builtin/glitcheffect.cpp | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/effects/backends/builtin/glitcheffect.cpp b/src/effects/backends/builtin/glitcheffect.cpp
index 90025793207..db0ae0c7639 100644
--- a/src/effects/backends/builtin/glitcheffect.cpp
+++ b/src/effects/backends/builtin/glitcheffect.cpp
@@ -81,7 +81,7 @@ void GlitchEffect::processChannel(
 
     int delay_frames;
     double min_delay;
-    if (groupFeatures.has_beat_length_sec) {
+    if (groupFeatures.beat_length.has_value()) {
         if (m_pQuantizeParameter->toBool()) {
             period = roundToFraction(period, 8);
             if (m_pTripletParameter->toBool()) {
@@ -89,9 +89,8 @@ void GlitchEffect::processChannel(
             }
         }
         period = std::max(period, 1 / 8.0);
-        delay_frames = static_cast<int>(period * groupFeatures.beat_length_sec *
-                engineParameters.sampleRate());
-        min_delay = 1 / 8.0 * groupFeatures.beat_length_sec * engineParameters.sampleRate();
+        delay_frames = static_cast<int>(period * groupFeatures.beat_length->frames);
+        min_delay = 1 / 8.0 * groupFeatures.beat_length->frames;
     } else {
         delay_frames = static_cast<int>(period * engineParameters.sampleRate());
         min_delay = 1 / 8.0 * engineParameters.sampleRate();