perf(gui): skip unchanged repaints and gate updates by tab
Add change detection to Display, WaveformDisplay, FilterDisplay, EnvelopeDisplay, and LFODisplay so repaint() is only called when values actually change. Gate updateVisuals() by currentTab so only the visible tab's displays are updated each timer tick. Similarly gate updateModList/updateMacroList to their respective tabs. Manage dynamically created controls via ownedControls unique_ptr vector instead of raw new leaks. Null-check parameter lookups before creating attachments. Hold engine control lock when reading matrix/macros/LFO shape data. Fix envelope display curve directions (attack rising from bottom, decay falling toward sustain, release falling toward bottom). Add tooltip to FilterDisplay noting the approximation. Replace ToggleButton raw param pointer with ParameterAttachment for proper gesture handling. Sync preset and scale combos to processor state.
This commit is contained in:
@@ -5,7 +5,10 @@ namespace serum
|
||||
|
||||
void EnvelopeDisplay::setParams (float a, float d, float s, float r, float c)
|
||||
{
|
||||
if (attack == a && decay == d && sustain == s && release == r && curve == c)
|
||||
return;
|
||||
attack = a; decay = d; sustain = s; release = r; curve = c;
|
||||
repaint();
|
||||
}
|
||||
|
||||
void EnvelopeDisplay::paint (juce::Graphics& g)
|
||||
@@ -19,7 +22,7 @@ void EnvelopeDisplay::paint (juce::Graphics& g)
|
||||
const float atkShape = 0.3f + curve * 2.7f;
|
||||
const float decShape = 3.0f - curve * 2.7f;
|
||||
|
||||
// Normalise durations for display (attack 0..1, decay 0..0.6, release 0..0.6).
|
||||
// Normalise durations for display, allowing a short sustain plateau.
|
||||
const float aSec = maps::toSeconds (attack);
|
||||
const float dSec = maps::toSeconds (decay);
|
||||
const float rSec = maps::toSeconds (release);
|
||||
@@ -36,7 +39,6 @@ void EnvelopeDisplay::paint (juce::Graphics& g)
|
||||
|
||||
juce::Path path;
|
||||
path.startNewSubPath (left, bottom);
|
||||
path.lineTo (left, top);
|
||||
|
||||
// Attack (curve-shaped).
|
||||
const int steps = 48;
|
||||
@@ -44,7 +46,7 @@ void EnvelopeDisplay::paint (juce::Graphics& g)
|
||||
for (int i = 0; i <= steps; ++i)
|
||||
{
|
||||
const float p = (float) i / steps;
|
||||
const float y = top + (bottom - top) * std::pow (p, atkShape);
|
||||
const float y = bottom - (bottom - top) * std::pow (p, atkShape);
|
||||
path.lineTo (left + p * (peakX - left), y);
|
||||
}
|
||||
|
||||
@@ -53,7 +55,7 @@ void EnvelopeDisplay::paint (juce::Graphics& g)
|
||||
for (int i = 0; i <= steps; ++i)
|
||||
{
|
||||
const float p = (float) i / steps;
|
||||
const float y = sustainY + (bottom - sustainY) * std::pow (1.0f - p, decShape);
|
||||
const float y = sustainY + (top - sustainY) * std::pow (1.0f - p, decShape);
|
||||
path.lineTo (peakX + p * (decX - peakX), y);
|
||||
}
|
||||
path.lineTo (decX, sustainY);
|
||||
@@ -64,7 +66,7 @@ void EnvelopeDisplay::paint (juce::Graphics& g)
|
||||
for (int i = 0; i <= steps; ++i)
|
||||
{
|
||||
const float p = (float) i / steps;
|
||||
const float y = sustainY + (bottom - sustainY) * std::pow (1.0f - p, decShape);
|
||||
const float y = bottom - (bottom - sustainY) * std::pow (1.0f - p, decShape);
|
||||
path.lineTo (relStartX + p * (right - relStartX), y);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user