mirror of
https://codeberg.org/armin/justasample.git
synced 2026-09-01 12:20:48 +02:00
init
This commit is contained in:
commit
d21bc831e1
178 changed files with 24136 additions and 0 deletions
62
Source/Components/Displays/ChorusVisualizer.cpp
Normal file
62
Source/Components/Displays/ChorusVisualizer.cpp
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
ChorusVisualizer.cpp
|
||||
Created: 30 Jan 2024 6:12:49pm
|
||||
Author: binya
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#include <JuceHeader.h>
|
||||
#include "ChorusVisualizer.h"
|
||||
|
||||
ChorusVisualizer::ChorusVisualizer(APVTS& apvts, int sampleRate) :
|
||||
apvts(apvts), sampleRate(sampleRate),
|
||||
rateAttachment(*apvts.getParameter(PluginParameters::CHORUS_RATE), [this](float newValue) { rate = newValue; repaint(); }, apvts.undoManager),
|
||||
depthAttachment(*apvts.getParameter(PluginParameters::CHORUS_DEPTH), [this](float newValue) { depth = newValue; repaint(); }, apvts.undoManager),
|
||||
centerDelayAttachment(*apvts.getParameter(PluginParameters::CHORUS_CENTER_DELAY), [this](float newValue) { centerDelay = newValue; repaint(); }, apvts.undoManager)
|
||||
{
|
||||
rateAttachment.sendInitialUpdate();
|
||||
depthAttachment.sendInitialUpdate();
|
||||
centerDelayAttachment.sendInitialUpdate();
|
||||
}
|
||||
|
||||
void ChorusVisualizer::paint(juce::Graphics& g)
|
||||
{
|
||||
auto theme = getTheme();
|
||||
|
||||
juce::Path path;
|
||||
|
||||
constexpr int pointsPerPixel = 10;
|
||||
|
||||
for (int i = 0; i < getWidth() * pointsPerPixel; i++)
|
||||
{
|
||||
float pos = float(i) / pointsPerPixel;
|
||||
|
||||
float lfo = std::sin(WINDOW_LENGTH * rate * pos / getWidth() * 2 * juce::MathConstants<float>::pi);
|
||||
float skewedDepth = logf(depth) + b;
|
||||
float delay = centerDelay * 0.98f + skewedDepth * lfo * multiplier;
|
||||
float loc = juce::jmap<float>(delay, -oscRange, oscRange, float(getHeight()), 0.f);
|
||||
|
||||
if (i == 0)
|
||||
path.startNewSubPath(pos, loc);
|
||||
else
|
||||
path.lineTo(pos, loc);
|
||||
}
|
||||
|
||||
auto strokeWidth = getWidth() * Layout::fxDisplayStrokeWidth;
|
||||
|
||||
g.setColour(theme.dark.withAlpha(0.2f));
|
||||
g.drawRect(0.f, (getHeight() - strokeWidth) / 2.f, float(getWidth()), strokeWidth);
|
||||
g.setColour(theme.dark);
|
||||
g.strokePath(path, juce::PathStrokeType(strokeWidth));
|
||||
|
||||
if (!isEnabled())
|
||||
g.fillAll(theme.background.withAlpha(0.5f));
|
||||
}
|
||||
|
||||
void ChorusVisualizer::enablementChanged()
|
||||
{
|
||||
repaint();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue