mirror of
https://codeberg.org/armin/beamgrid.git
synced 2026-09-01 04:10:47 +02:00
Add GRID visibility knob and fix spectrum/grid rendering
- Add GRID rotary knob (0-1) controlling grid + axis-label brightness/visibility - Raise analyser ceiling to 0 dBFS; remove overlapping 0/-6 dB lines - Set plugin minimum width to 800px (and clamp restored width) - Extend spectrum signal/peak waves to full plot width - Render signal wave as quadratic spline to match peak smoothness - Restore 1px gaps in LED mode
This commit is contained in:
parent
e0177ed26f
commit
b6bdc73488
6 changed files with 52 additions and 14 deletions
|
|
@ -34,6 +34,7 @@ public:
|
|||
const int mode = juce::roundToInt (params.getRawParameterValue ("mode")->load());
|
||||
const int leds = juce::roundToInt (params.getRawParameterValue ("leds")->load());
|
||||
const double smooth = *params.getRawParameterValue ("smooth");
|
||||
const double gridVis = *params.getRawParameterValue ("grid");
|
||||
|
||||
analyser.setGraceSeconds (graceMs / 1000.0);
|
||||
analyser.setFalloffRate (0.1 + falloff * 5.0);
|
||||
|
|
@ -47,6 +48,7 @@ public:
|
|||
displayMode = mode;
|
||||
ledCount = leds;
|
||||
smoothAmount = static_cast<float> (smooth);
|
||||
gridAmount = static_cast<float> (gridVis);
|
||||
|
||||
analyser.update (1.0 / 60.0);
|
||||
repaint();
|
||||
|
|
@ -66,8 +68,8 @@ public:
|
|||
const float bandWidth = (plot.getWidth() - gap * (n + 1)) / static_cast<float> (n);
|
||||
const float baseY = plot.getBottom();
|
||||
|
||||
const juce::Colour gridColour = lf.transform (juce::Colours::grey.brighter (0.2f)).withAlpha (0.32f);
|
||||
const juce::Colour labelColour = lf.transform (juce::Colours::grey);
|
||||
const juce::Colour gridColour = lf.transform (juce::Colours::grey.brighter (0.2f)).withAlpha (gridAmount);
|
||||
const juce::Colour labelColour = gridColour;
|
||||
|
||||
// --- Gridlines (drawn first; labels drawn last so they stay readable) ---
|
||||
const double freqTicks[] = { 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000 };
|
||||
|
|
@ -179,18 +181,33 @@ private:
|
|||
}
|
||||
|
||||
// Trace the curve. `smooth` controls how much the band levels are
|
||||
// averaged (above); the path itself is straight segments between band
|
||||
// centres, so at smooth = 0 it stays raw/edgy and at 1 it is rounded
|
||||
// by the heavy level smoothing.
|
||||
juce::Path wave;
|
||||
wave.startNewSubPath (plot.getX() + gap, baseY);
|
||||
// averaged (above); the path itself is a quadratic spline through the
|
||||
// band centres (same technique as the peak wave), so at smooth = 0 it
|
||||
// stays raw/edgy and at 1 it is rounded by the heavy level smoothing.
|
||||
// The curve is anchored to the first/last band value right at the plot
|
||||
// edges so it reaches the full width instead of ramping down to the
|
||||
// baseline at the sides.
|
||||
juce::HeapBlock<juce::Point<float>> wpts (static_cast<size_t> (n));
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
const float x = plot.getX() + gap + i * (bandWidth + gap) + bandWidth * 0.5f;
|
||||
const float y = baseY - levels[i] * plot.getHeight();
|
||||
wave.lineTo (x, y);
|
||||
wpts[i] = { x, y };
|
||||
}
|
||||
wave.lineTo (plot.getRight() - gap, baseY);
|
||||
|
||||
juce::Path wave;
|
||||
wave.startNewSubPath (plot.getX(), wpts[0].y);
|
||||
wave.lineTo (wpts[0]);
|
||||
for (int i = 0; i < n - 1; ++i)
|
||||
{
|
||||
const juce::Point<float> mid = { (wpts[i].x + wpts[i + 1].x) * 0.5f,
|
||||
(wpts[i].y + wpts[i + 1].y) * 0.5f };
|
||||
wave.quadraticTo (wpts[i], mid);
|
||||
}
|
||||
wave.quadraticTo (wpts[n - 1], wpts[n - 1]);
|
||||
wave.lineTo (plot.getRight(), wpts[n - 1].y);
|
||||
wave.lineTo (plot.getRight(), baseY);
|
||||
wave.lineTo (plot.getX(), baseY);
|
||||
wave.closeSubPath();
|
||||
|
||||
// Brighter at the top, darker toward the bottom.
|
||||
|
|
@ -233,7 +250,8 @@ private:
|
|||
}
|
||||
|
||||
juce::Path peakWave;
|
||||
peakWave.startNewSubPath (ppts[0]);
|
||||
peakWave.startNewSubPath (plot.getX(), baseY - peaks[0] * plot.getHeight());
|
||||
peakWave.lineTo (ppts[0]);
|
||||
for (int i = 0; i < n - 1; ++i)
|
||||
{
|
||||
const juce::Point<float> mid = { (ppts[i].x + ppts[i + 1].x) * 0.5f,
|
||||
|
|
@ -241,6 +259,7 @@ private:
|
|||
peakWave.quadraticTo (ppts[i], mid);
|
||||
}
|
||||
peakWave.quadraticTo (ppts[n - 1], ppts[n - 1]);
|
||||
peakWave.lineTo (plot.getRight(), baseY - peaks[n - 1] * plot.getHeight());
|
||||
g.setColour (lf.getPeak());
|
||||
g.strokePath (peakWave, juce::PathStrokeType (2.0f));
|
||||
}
|
||||
|
|
@ -292,6 +311,7 @@ private:
|
|||
int displayMode = ModeBars;
|
||||
int ledCount = 16;
|
||||
float smoothAmount = 0.35f;
|
||||
float gridAmount = 0.32f;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AnalyserComponent)
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue