Gjorde det möjligt att slå på/stänga av alla olika effekter samt fixade ikon för MacOS
This commit is contained in:
1 parent
f5e6eadcd4
commit
ba29890105
10 files changed
+643
-188
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 83 KiB |
@@ -139,6 +139,9 @@ juce_add_gui_app(CrilleBassStripApp
|
||||
PRODUCT_NAME "Crille Bass Strip"
|
||||
COMPANY_NAME "Crille Audio"
|
||||
BUNDLE_ID "org.crilleaudio.crillebassstrip"
|
||||
|
||||
ICON_BIG "${CMAKE_CURRENT_SOURCE_DIR}/Assets/CrilleBassStrip.png"
|
||||
ICON_SMALL "${CMAKE_CURRENT_SOURCE_DIR}/Assets/CrilleBassStrip.png"
|
||||
)
|
||||
|
||||
juce_generate_juce_header(CrilleBassStripApp)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>Crille Bass Strip</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string></string>
|
||||
<string>Icon.icns</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.crilleaudio.crillebassstrip</string>
|
||||
<key>CFBundleName</key>
|
||||
|
||||
Binary file not shown.
BIN
Binary file not shown.
Generated
BIN
Binary file not shown.
Binary file not shown.
+192
-53
@@ -212,6 +212,61 @@ void CrilleBassStripAudioProcessorEditor::LevelMeter::paint(
|
||||
);
|
||||
}
|
||||
|
||||
CrilleBassStripAudioProcessorEditor::SectionToggleButton::
|
||||
SectionToggleButton(
|
||||
const juce::String& sectionName,
|
||||
juce::Colour activeColour)
|
||||
: juce::ToggleButton(sectionName),
|
||||
sectionColour(activeColour)
|
||||
{
|
||||
setClickingTogglesState(true);
|
||||
setMouseCursor(juce::MouseCursor::PointingHandCursor);
|
||||
}
|
||||
|
||||
void CrilleBassStripAudioProcessorEditor::SectionToggleButton::paintButton(
|
||||
juce::Graphics& g,
|
||||
bool shouldDrawButtonAsHighlighted,
|
||||
bool shouldDrawButtonAsDown)
|
||||
{
|
||||
const bool active = getToggleState();
|
||||
const auto bounds = getLocalBounds().toFloat();
|
||||
|
||||
const float ledSize = 9.0f;
|
||||
auto ledBounds = juce::Rectangle<float>(
|
||||
5.0f,
|
||||
(bounds.getHeight() - ledSize) * 0.5f,
|
||||
ledSize,
|
||||
ledSize);
|
||||
|
||||
auto ledColour = active
|
||||
? sectionColour
|
||||
: juce::Colour(0xff454a51);
|
||||
|
||||
if (shouldDrawButtonAsDown)
|
||||
ledColour = ledColour.brighter(0.25f);
|
||||
else if (shouldDrawButtonAsHighlighted)
|
||||
ledColour = ledColour.brighter(0.12f);
|
||||
|
||||
g.setColour(ledColour.withAlpha(active ? 0.25f : 0.12f));
|
||||
g.fillEllipse(ledBounds.expanded(3.0f));
|
||||
|
||||
g.setColour(ledColour);
|
||||
g.fillEllipse(ledBounds);
|
||||
|
||||
g.setColour(active
|
||||
? juce::Colour(0xfff0f1f2)
|
||||
: juce::Colour(0xff686e76));
|
||||
|
||||
g.setFont(juce::Font(15.0f, juce::Font::bold));
|
||||
g.drawText(
|
||||
getButtonText(),
|
||||
20,
|
||||
0,
|
||||
getWidth() - 25,
|
||||
getHeight(),
|
||||
juce::Justification::centred);
|
||||
}
|
||||
|
||||
CrilleBassStripAudioProcessorEditor::
|
||||
CrilleBassStripAudioProcessorEditor(
|
||||
CrilleBassStripAudioProcessor& p)
|
||||
@@ -251,6 +306,43 @@ CrilleBassStripAudioProcessorEditor(
|
||||
downTuneButton
|
||||
);
|
||||
|
||||
addAndMakeVisible(gateToggleButton);
|
||||
addAndMakeVisible(compressorToggleButton);
|
||||
addAndMakeVisible(distortionToggleButton);
|
||||
addAndMakeVisible(eqToggleButton);
|
||||
|
||||
gateToggleAttachment =
|
||||
std::make_unique<
|
||||
juce::AudioProcessorValueTreeState::ButtonAttachment
|
||||
>(
|
||||
processor.apvts,
|
||||
"gateOn",
|
||||
gateToggleButton);
|
||||
|
||||
compressorToggleAttachment =
|
||||
std::make_unique<
|
||||
juce::AudioProcessorValueTreeState::ButtonAttachment
|
||||
>(
|
||||
processor.apvts,
|
||||
"compressorOn",
|
||||
compressorToggleButton);
|
||||
|
||||
distortionToggleAttachment =
|
||||
std::make_unique<
|
||||
juce::AudioProcessorValueTreeState::ButtonAttachment
|
||||
>(
|
||||
processor.apvts,
|
||||
"distortionOn",
|
||||
distortionToggleButton);
|
||||
|
||||
eqToggleAttachment =
|
||||
std::make_unique<
|
||||
juce::AudioProcessorValueTreeState::ButtonAttachment
|
||||
>(
|
||||
processor.apvts,
|
||||
"eqOn",
|
||||
eqToggleButton);
|
||||
|
||||
addKnob(
|
||||
"gateThreshold",
|
||||
"THRESHOLD"
|
||||
@@ -325,6 +417,8 @@ CrilleBassStripAudioProcessorEditor(
|
||||
addAndMakeVisible(compressorInputMeter);
|
||||
addAndMakeVisible(compressorReductionMeter);
|
||||
|
||||
updateSectionStates();
|
||||
|
||||
setSize(760, 720);
|
||||
startTimerHz(30);
|
||||
}
|
||||
@@ -399,6 +493,40 @@ void CrilleBassStripAudioProcessorEditor::addKnob(
|
||||
knobs.push_back(std::move(k));
|
||||
}
|
||||
|
||||
void CrilleBassStripAudioProcessorEditor::setKnobSectionEnabled(
|
||||
int firstKnob,
|
||||
int numberOfKnobs,
|
||||
bool enabled)
|
||||
{
|
||||
const float alpha = enabled ? 1.0f : 0.35f;
|
||||
|
||||
for (int i = firstKnob;
|
||||
i < firstKnob + numberOfKnobs;
|
||||
++i)
|
||||
{
|
||||
knobs[static_cast<std::size_t>(i)]->slider.setEnabled(enabled);
|
||||
knobs[static_cast<std::size_t>(i)]->slider.setAlpha(alpha);
|
||||
knobs[static_cast<std::size_t>(i)]->label.setAlpha(alpha);
|
||||
}
|
||||
}
|
||||
|
||||
void CrilleBassStripAudioProcessorEditor::updateSectionStates()
|
||||
{
|
||||
const bool gateEnabled = gateToggleButton.getToggleState();
|
||||
const bool compressorEnabled = compressorToggleButton.getToggleState();
|
||||
const bool distortionEnabled = distortionToggleButton.getToggleState();
|
||||
const bool eqEnabled = eqToggleButton.getToggleState();
|
||||
|
||||
setKnobSectionEnabled(0, 3, gateEnabled);
|
||||
setKnobSectionEnabled(3, 3, compressorEnabled);
|
||||
setKnobSectionEnabled(6, 3, distortionEnabled);
|
||||
setKnobSectionEnabled(9, 5, eqEnabled);
|
||||
|
||||
gateInputMeter.setAlpha(gateEnabled ? 1.0f : 0.25f);
|
||||
compressorInputMeter.setAlpha(compressorEnabled ? 1.0f : 0.25f);
|
||||
compressorReductionMeter.setAlpha(compressorEnabled ? 1.0f : 0.25f);
|
||||
}
|
||||
|
||||
float CrilleBassStripAudioProcessorEditor::smoothMeter(
|
||||
float current,
|
||||
float target,
|
||||
@@ -414,6 +542,8 @@ float CrilleBassStripAudioProcessorEditor::smoothMeter(
|
||||
|
||||
void CrilleBassStripAudioProcessorEditor::timerCallback()
|
||||
{
|
||||
updateSectionStates();
|
||||
|
||||
smoothedGateDb =
|
||||
smoothMeter(
|
||||
smoothedGateDb,
|
||||
@@ -499,70 +629,55 @@ void CrilleBassStripAudioProcessorEditor::paint(
|
||||
juce::Justification::centredLeft
|
||||
);
|
||||
|
||||
const struct
|
||||
const bool panelStates[]
|
||||
{
|
||||
juce::Rectangle<int> bounds;
|
||||
juce::String title;
|
||||
juce::Colour border;
|
||||
}
|
||||
panels[]
|
||||
{
|
||||
{
|
||||
{ 15, 85, 180, 300 },
|
||||
"DOWNTUNE",
|
||||
juce::Colour(0xff4b79a8)
|
||||
},
|
||||
{
|
||||
{ 205, 85, 265, 300 },
|
||||
"NOISE GATE",
|
||||
juce::Colour(0xff3c424a)
|
||||
},
|
||||
{
|
||||
{ 480, 85, 265, 300 },
|
||||
"COMPRESSOR",
|
||||
juce::Colour(0xff3c424a)
|
||||
},
|
||||
{
|
||||
{ 15, 395, 300, 310 },
|
||||
"DISTORTION",
|
||||
juce::Colour(0xffb85c45)
|
||||
},
|
||||
{
|
||||
{ 325, 395, 420, 310 },
|
||||
"EQUALIZER",
|
||||
juce::Colour(0xff3c424a)
|
||||
}
|
||||
downTuneButton.getToggleState(),
|
||||
gateToggleButton.getToggleState(),
|
||||
compressorToggleButton.getToggleState(),
|
||||
distortionToggleButton.getToggleState(),
|
||||
eqToggleButton.getToggleState()
|
||||
};
|
||||
|
||||
for (const auto& panel : panels)
|
||||
const juce::Rectangle<int> panelBounds[]
|
||||
{
|
||||
auto bounds = panel.bounds;
|
||||
{ 15, 85, 180, 300 },
|
||||
{ 205, 85, 265, 300 },
|
||||
{ 480, 85, 265, 300 },
|
||||
{ 15, 395, 300, 310 },
|
||||
{ 325, 395, 420, 310 }
|
||||
};
|
||||
|
||||
g.setColour(juce::Colour(0xff1b1f24));
|
||||
for (int i = 0; i < 5; ++i)
|
||||
{
|
||||
const auto bounds = panelBounds[i].toFloat();
|
||||
const bool active = panelStates[i];
|
||||
|
||||
g.fillRoundedRectangle(
|
||||
bounds.toFloat(),
|
||||
10.0f
|
||||
);
|
||||
g.setColour(active
|
||||
? juce::Colour(0xff1b1f24)
|
||||
: juce::Colour(0xff171a1e));
|
||||
|
||||
g.setColour(panel.border);
|
||||
g.fillRoundedRectangle(bounds, 10.0f);
|
||||
|
||||
g.drawRoundedRectangle(
|
||||
bounds.toFloat(),
|
||||
10.0f,
|
||||
2.0f
|
||||
);
|
||||
g.setColour(active
|
||||
? juce::Colour(0xff4a5058)
|
||||
: juce::Colour(0xff2a2e34));
|
||||
|
||||
g.setColour(juce::Colour(0xfff0f1f2));
|
||||
g.setFont(15.0f);
|
||||
|
||||
g.drawText(
|
||||
panel.title,
|
||||
bounds.removeFromTop(38),
|
||||
juce::Justification::centred
|
||||
);
|
||||
g.drawRoundedRectangle(bounds, 10.0f, 2.0f);
|
||||
}
|
||||
|
||||
g.setColour(downTuneButton.getToggleState()
|
||||
? juce::Colour(0xfff0f1f2)
|
||||
: juce::Colour(0xff686e76));
|
||||
|
||||
g.setFont(juce::Font(15.0f, juce::Font::bold));
|
||||
g.drawText(
|
||||
"DOWNTUNE",
|
||||
15,
|
||||
85,
|
||||
180,
|
||||
38,
|
||||
juce::Justification::centred);
|
||||
|
||||
const float inputFrequency =
|
||||
processor.getDetectedFrequencyHz();
|
||||
|
||||
@@ -722,6 +837,30 @@ void CrilleBassStripAudioProcessorEditor::paint(
|
||||
|
||||
void CrilleBassStripAudioProcessorEditor::resized()
|
||||
{
|
||||
gateToggleButton.setBounds(
|
||||
245,
|
||||
91,
|
||||
185,
|
||||
28);
|
||||
|
||||
compressorToggleButton.setBounds(
|
||||
520,
|
||||
91,
|
||||
185,
|
||||
28);
|
||||
|
||||
distortionToggleButton.setBounds(
|
||||
70,
|
||||
401,
|
||||
190,
|
||||
28);
|
||||
|
||||
eqToggleButton.setBounds(
|
||||
435,
|
||||
401,
|
||||
200,
|
||||
28);
|
||||
|
||||
downTuneButton.setBounds(
|
||||
35,
|
||||
135,
|
||||
|
||||
+107
-17
@@ -1,12 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <JuceHeader.h>
|
||||
#include "PluginProcessor.h"
|
||||
|
||||
class CrilleBassStripAudioProcessorEditor final : public juce::AudioProcessorEditor,
|
||||
private juce::Timer
|
||||
class CrilleBassStripAudioProcessorEditor final
|
||||
: public juce::AudioProcessorEditor,
|
||||
private juce::Timer
|
||||
{
|
||||
public:
|
||||
explicit CrilleBassStripAudioProcessorEditor(CrilleBassStripAudioProcessor&);
|
||||
explicit CrilleBassStripAudioProcessorEditor(
|
||||
CrilleBassStripAudioProcessor&);
|
||||
|
||||
~CrilleBassStripAudioProcessorEditor() override = default;
|
||||
|
||||
void paint(juce::Graphics&) override;
|
||||
@@ -16,9 +20,14 @@ private:
|
||||
class LevelMeter final : public juce::Component
|
||||
{
|
||||
public:
|
||||
enum class Mode { inputLevel, gainReduction };
|
||||
enum class Mode
|
||||
{
|
||||
inputLevel,
|
||||
gainReduction
|
||||
};
|
||||
|
||||
explicit LevelMeter(Mode meterMode);
|
||||
|
||||
void setLevel(float newLevelDb);
|
||||
void setThreshold(float newThresholdDb);
|
||||
void paint(juce::Graphics&) override;
|
||||
@@ -29,6 +38,22 @@ private:
|
||||
float thresholdDb = -80.0f;
|
||||
};
|
||||
|
||||
class SectionToggleButton final : public juce::ToggleButton
|
||||
{
|
||||
public:
|
||||
SectionToggleButton(
|
||||
const juce::String& sectionName,
|
||||
juce::Colour activeColour);
|
||||
|
||||
void paintButton(
|
||||
juce::Graphics& g,
|
||||
bool shouldDrawButtonAsHighlighted,
|
||||
bool shouldDrawButtonAsDown) override;
|
||||
|
||||
private:
|
||||
juce::Colour sectionColour;
|
||||
};
|
||||
|
||||
struct Knob
|
||||
{
|
||||
juce::Slider slider;
|
||||
@@ -36,25 +61,90 @@ private:
|
||||
};
|
||||
|
||||
CrilleBassStripAudioProcessor& processor;
|
||||
|
||||
std::vector<std::unique_ptr<Knob>> knobs;
|
||||
std::vector<std::unique_ptr<juce::AudioProcessorValueTreeState::SliderAttachment>> attachments;
|
||||
juce::ToggleButton downTuneButton;
|
||||
|
||||
std::unique_ptr<
|
||||
juce::AudioProcessorValueTreeState::ButtonAttachment
|
||||
> downTuneAttachment;
|
||||
std::vector<std::unique_ptr<
|
||||
juce::AudioProcessorValueTreeState::SliderAttachment>>
|
||||
attachments;
|
||||
|
||||
LevelMeter gateInputMeter { LevelMeter::Mode::inputLevel };
|
||||
LevelMeter compressorInputMeter { LevelMeter::Mode::inputLevel };
|
||||
LevelMeter compressorReductionMeter { LevelMeter::Mode::gainReduction };
|
||||
juce::ToggleButton downTuneButton;
|
||||
|
||||
std::unique_ptr<
|
||||
juce::AudioProcessorValueTreeState::ButtonAttachment>
|
||||
downTuneAttachment;
|
||||
|
||||
SectionToggleButton gateToggleButton {
|
||||
"NOISE GATE",
|
||||
juce::Colour(0xffe5a536)
|
||||
};
|
||||
|
||||
SectionToggleButton compressorToggleButton {
|
||||
"COMPRESSOR",
|
||||
juce::Colour(0xffe5a536)
|
||||
};
|
||||
|
||||
SectionToggleButton distortionToggleButton {
|
||||
"DISTORTION",
|
||||
juce::Colour(0xffd26b4f)
|
||||
};
|
||||
|
||||
SectionToggleButton eqToggleButton {
|
||||
"EQUALIZER",
|
||||
juce::Colour(0xffe5a536)
|
||||
};
|
||||
|
||||
std::unique_ptr<
|
||||
juce::AudioProcessorValueTreeState::ButtonAttachment>
|
||||
gateToggleAttachment;
|
||||
|
||||
std::unique_ptr<
|
||||
juce::AudioProcessorValueTreeState::ButtonAttachment>
|
||||
compressorToggleAttachment;
|
||||
|
||||
std::unique_ptr<
|
||||
juce::AudioProcessorValueTreeState::ButtonAttachment>
|
||||
distortionToggleAttachment;
|
||||
|
||||
std::unique_ptr<
|
||||
juce::AudioProcessorValueTreeState::ButtonAttachment>
|
||||
eqToggleAttachment;
|
||||
|
||||
LevelMeter gateInputMeter {
|
||||
LevelMeter::Mode::inputLevel
|
||||
};
|
||||
|
||||
LevelMeter compressorInputMeter {
|
||||
LevelMeter::Mode::inputLevel
|
||||
};
|
||||
|
||||
LevelMeter compressorReductionMeter {
|
||||
LevelMeter::Mode::gainReduction
|
||||
};
|
||||
|
||||
float smoothedGateDb = -80.0f;
|
||||
float smoothedCompressorDb = -80.0f;
|
||||
float smoothedReductionDb = 0.0f;
|
||||
|
||||
void addKnob(const juce::String& parameter, const juce::String& caption);
|
||||
void timerCallback() override;
|
||||
static float smoothMeter(float current, float target, float attack, float release);
|
||||
void addKnob(
|
||||
const juce::String& parameter,
|
||||
const juce::String& caption);
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CrilleBassStripAudioProcessorEditor)
|
||||
};
|
||||
void timerCallback() override;
|
||||
|
||||
void updateSectionStates();
|
||||
|
||||
void setKnobSectionEnabled(
|
||||
int firstKnob,
|
||||
int numberOfKnobs,
|
||||
bool enabled);
|
||||
|
||||
static float smoothMeter(
|
||||
float current,
|
||||
float target,
|
||||
float attack,
|
||||
float release);
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(
|
||||
CrilleBassStripAudioProcessorEditor)
|
||||
};
|
||||
+340
-117
@@ -21,24 +21,130 @@ juce::AudioProcessorValueTreeState::ParameterLayout CrilleBassStripAudioProcesso
|
||||
{
|
||||
using P = juce::AudioParameterFloat;
|
||||
juce::AudioProcessorValueTreeState::ParameterLayout p;
|
||||
|
||||
p.add(std::make_unique<juce::AudioParameterBool>(
|
||||
pid("downTuneOn"),
|
||||
"DownTune",
|
||||
false));
|
||||
p.add(std::make_unique<P>(pid("gateThreshold"), "Gate Threshold", juce::NormalisableRange<float>(-80.f, -10.f, 0.1f), -45.f, "dB"));
|
||||
p.add(std::make_unique<P>(pid("gateRelease"), "Gate Release", juce::NormalisableRange<float>(20.f, 500.f, 1.f, 0.5f), 150.f, "ms"));
|
||||
p.add(std::make_unique<P>(pid("gateGain"), "Gate Gain", juce::NormalisableRange<float>(-24.f, 12.f, 0.1f), 0.f, "dB"));
|
||||
p.add(std::make_unique<P>(pid("compThreshold"), "Comp Threshold", juce::NormalisableRange<float>(-60.f, 0.f, 0.1f), -18.f, "dB"));
|
||||
p.add(std::make_unique<P>(pid("compRatio"), "Comp Ratio", juce::NormalisableRange<float>(1.f, 20.f, 0.1f, 0.5f), 4.f, ":1"));
|
||||
p.add(std::make_unique<P>(pid("compGain"), "Comp Gain", juce::NormalisableRange<float>(-12.f, 18.f, 0.1f), 3.f, "dB"));
|
||||
p.add(std::make_unique<P>(pid("drive"), "Drive", juce::NormalisableRange<float>(0.f, 24.f, 0.1f), 5.f, "dB"));
|
||||
p.add(std::make_unique<P>(pid("mix"), "Distortion Mix", juce::NormalisableRange<float>(0.f, 100.f, 1.f), 25.f, "%"));
|
||||
p.add(std::make_unique<P>(pid("distGain"), "Distortion Gain", juce::NormalisableRange<float>(-18.f, 12.f, 0.1f), 0.f, "dB"));
|
||||
p.add(std::make_unique<P>(pid("bass"), "Bass", juce::NormalisableRange<float>(-12.f, 12.f, 0.1f), 2.f, "dB"));
|
||||
p.add(std::make_unique<P>(pid("lowMid"), "Low Mid", juce::NormalisableRange<float>(-12.f, 12.f, 0.1f), -2.f, "dB"));
|
||||
p.add(std::make_unique<P>(pid("middle"), "Middle", juce::NormalisableRange<float>(-12.f, 12.f, 0.1f), 0.f, "dB"));
|
||||
p.add(std::make_unique<P>(pid("treble"), "Treble", juce::NormalisableRange<float>(-12.f, 12.f, 0.1f), 1.f, "dB"));
|
||||
p.add(std::make_unique<P>(pid("output"), "Output", juce::NormalisableRange<float>(-24.f, 12.f, 0.1f), -1.f, "dB"));
|
||||
pid("downTuneOn"),
|
||||
"DownTune",
|
||||
false));
|
||||
|
||||
p.add(std::make_unique<juce::AudioParameterBool>(
|
||||
pid("gateOn"),
|
||||
"Gate On",
|
||||
true));
|
||||
|
||||
p.add(std::make_unique<juce::AudioParameterBool>(
|
||||
pid("compressorOn"),
|
||||
"Compressor On",
|
||||
true));
|
||||
|
||||
p.add(std::make_unique<juce::AudioParameterBool>(
|
||||
pid("distortionOn"),
|
||||
"Distortion On",
|
||||
true));
|
||||
|
||||
p.add(std::make_unique<juce::AudioParameterBool>(
|
||||
pid("eqOn"),
|
||||
"EQ On",
|
||||
true));
|
||||
|
||||
p.add(std::make_unique<P>(
|
||||
pid("gateThreshold"),
|
||||
"Gate Threshold",
|
||||
juce::NormalisableRange<float>(-80.f, -10.f, 0.1f),
|
||||
-55.f,
|
||||
"dB"));
|
||||
|
||||
p.add(std::make_unique<P>(
|
||||
pid("gateRelease"),
|
||||
"Gate Release",
|
||||
juce::NormalisableRange<float>(20.f, 500.f, 1.f, 0.5f),
|
||||
150.f,
|
||||
"ms"));
|
||||
|
||||
p.add(std::make_unique<P>(
|
||||
pid("gateGain"),
|
||||
"Gate Gain",
|
||||
juce::NormalisableRange<float>(-24.f, 12.f, 0.1f),
|
||||
0.f,
|
||||
"dB"));
|
||||
|
||||
p.add(std::make_unique<P>(
|
||||
pid("compThreshold"),
|
||||
"Comp Threshold",
|
||||
juce::NormalisableRange<float>(-60.f, 0.f, 0.1f),
|
||||
-30.f,
|
||||
"dB"));
|
||||
|
||||
p.add(std::make_unique<P>(
|
||||
pid("compRatio"),
|
||||
"Comp Ratio",
|
||||
juce::NormalisableRange<float>(1.f, 20.f, 0.1f, 0.5f),
|
||||
3.f,
|
||||
":1"));
|
||||
|
||||
p.add(std::make_unique<P>(
|
||||
pid("compGain"),
|
||||
"Comp Gain",
|
||||
juce::NormalisableRange<float>(-12.f, 18.f, 0.1f),
|
||||
2.f,
|
||||
"dB"));
|
||||
|
||||
p.add(std::make_unique<P>(
|
||||
pid("drive"),
|
||||
"Drive",
|
||||
juce::NormalisableRange<float>(0.f, 24.f, 0.1f),
|
||||
5.f,
|
||||
"dB"));
|
||||
|
||||
p.add(std::make_unique<P>(
|
||||
pid("mix"),
|
||||
"Distortion Mix",
|
||||
juce::NormalisableRange<float>(0.f, 100.f, 1.f),
|
||||
25.f,
|
||||
"%"));
|
||||
|
||||
p.add(std::make_unique<P>(
|
||||
pid("distGain"),
|
||||
"Distortion Gain",
|
||||
juce::NormalisableRange<float>(-18.f, 12.f, 0.1f),
|
||||
0.f,
|
||||
"dB"));
|
||||
|
||||
p.add(std::make_unique<P>(
|
||||
pid("bass"),
|
||||
"Bass",
|
||||
juce::NormalisableRange<float>(-12.f, 12.f, 0.1f),
|
||||
0.f,
|
||||
"dB"));
|
||||
|
||||
p.add(std::make_unique<P>(
|
||||
pid("lowMid"),
|
||||
"Low Mid",
|
||||
juce::NormalisableRange<float>(-12.f, 12.f, 0.1f),
|
||||
0.f,
|
||||
"dB"));
|
||||
|
||||
p.add(std::make_unique<P>(
|
||||
pid("middle"),
|
||||
"Middle",
|
||||
juce::NormalisableRange<float>(-12.f, 12.f, 0.1f),
|
||||
0.f,
|
||||
"dB"));
|
||||
|
||||
p.add(std::make_unique<P>(
|
||||
pid("treble"),
|
||||
"Treble",
|
||||
juce::NormalisableRange<float>(-12.f, 12.f, 0.1f),
|
||||
0.f,
|
||||
"dB"));
|
||||
|
||||
p.add(std::make_unique<P>(
|
||||
pid("output"),
|
||||
"Output",
|
||||
juce::NormalisableRange<float>(-24.f, 12.f, 0.1f),
|
||||
0.f,
|
||||
"dB"));
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -60,14 +166,16 @@ void CrilleBassStripAudioProcessor::prepareToPlay(double sr, int block)
|
||||
setLatencySamples(
|
||||
downTune.inputLatency() +
|
||||
downTune.outputLatency());
|
||||
|
||||
downTuneLatencyMs =
|
||||
1000.0 *
|
||||
(downTune.inputLatency() + downTune.outputLatency()) /
|
||||
sr;
|
||||
1000.0 *
|
||||
(downTune.inputLatency() + downTune.outputLatency()) /
|
||||
sr;
|
||||
|
||||
//debug börjar
|
||||
DBG("DownTune input latency: "
|
||||
<< downTune.inputLatency()
|
||||
<< " samples");
|
||||
<< downTune.inputLatency()
|
||||
<< " samples");
|
||||
|
||||
DBG("DownTune output latency: "
|
||||
<< downTune.outputLatency()
|
||||
@@ -80,40 +188,61 @@ void CrilleBassStripAudioProcessor::prepareToPlay(double sr, int block)
|
||||
DBG("DownTune latency ms: "
|
||||
<< 1000.0 * (downTune.inputLatency() + downTune.outputLatency()) / sr);
|
||||
// debug slutar
|
||||
juce::dsp::ProcessSpec spec { sr, static_cast<juce::uint32>(block), static_cast<juce::uint32>(getTotalNumOutputChannels()) };
|
||||
|
||||
juce::dsp::ProcessSpec spec {
|
||||
sr,
|
||||
static_cast<juce::uint32>(block),
|
||||
static_cast<juce::uint32>(getTotalNumOutputChannels())
|
||||
};
|
||||
|
||||
compressor.prepare(spec);
|
||||
lowShelf.prepare(spec);
|
||||
lowMid.prepare(spec);
|
||||
mid.prepare(spec);
|
||||
highShelf.prepare(spec);
|
||||
|
||||
compressor.reset();
|
||||
lowShelf.reset();
|
||||
lowMid.reset();
|
||||
mid.reset();
|
||||
highShelf.reset();
|
||||
gateEnvelope.assign(static_cast<size_t>(getTotalNumOutputChannels()), 0.f);
|
||||
|
||||
gateEnvelope.assign(
|
||||
static_cast<size_t>(getTotalNumOutputChannels()),
|
||||
0.f);
|
||||
|
||||
gateInputLevelDb.store(meterFloorDb);
|
||||
compressorInputLevelDb.store(meterFloorDb);
|
||||
compressorGainReductionDb.store(0.0f);
|
||||
|
||||
updateFilters();
|
||||
}
|
||||
|
||||
bool CrilleBassStripAudioProcessor::isBusesLayoutSupported(const BusesLayout& layouts) const
|
||||
{
|
||||
const auto input = layouts.getMainInputChannelSet();
|
||||
const auto input = layouts.getMainInputChannelSet();
|
||||
const auto output = layouts.getMainOutputChannelSet();
|
||||
|
||||
return input == juce::AudioChannelSet::mono()
|
||||
&& output == juce::AudioChannelSet::stereo();
|
||||
}
|
||||
|
||||
float CrilleBassStripAudioProcessor::getBufferPeak(const juce::AudioBuffer<float>& buffer) noexcept
|
||||
float CrilleBassStripAudioProcessor::getBufferPeak(
|
||||
const juce::AudioBuffer<float>& buffer) noexcept
|
||||
{
|
||||
float peak = 0.0f;
|
||||
|
||||
for (int channel = 0; channel < buffer.getNumChannels(); ++channel)
|
||||
peak = juce::jmax(peak, buffer.getMagnitude(channel, 0, buffer.getNumSamples()));
|
||||
peak = juce::jmax(
|
||||
peak,
|
||||
buffer.getMagnitude(
|
||||
channel,
|
||||
0,
|
||||
buffer.getNumSamples()));
|
||||
|
||||
return peak;
|
||||
}
|
||||
|
||||
void CrilleBassStripAudioProcessor::updatePitchDetector(
|
||||
const float* input,
|
||||
int numSamples)
|
||||
@@ -302,21 +431,67 @@ void CrilleBassStripAudioProcessor::analysePitch()
|
||||
|
||||
void CrilleBassStripAudioProcessor::updateFilters()
|
||||
{
|
||||
const auto bass = apvts.getRawParameterValue("bass")->load();
|
||||
const auto lm = apvts.getRawParameterValue("lowMid")->load();
|
||||
const auto m = apvts.getRawParameterValue("middle")->load();
|
||||
const auto tr = apvts.getRawParameterValue("treble")->load();
|
||||
*lowShelf.state = *juce::dsp::IIR::Coefficients<float>::makeLowShelf(currentSampleRate, 80.0, 0.707, dbToGain(bass));
|
||||
*lowMid.state = *juce::dsp::IIR::Coefficients<float>::makePeakFilter(currentSampleRate, 300.0, 0.8, dbToGain(lm));
|
||||
*mid.state = *juce::dsp::IIR::Coefficients<float>::makePeakFilter(currentSampleRate, 900.0, 0.8, dbToGain(m));
|
||||
*highShelf.state = *juce::dsp::IIR::Coefficients<float>::makeHighShelf(currentSampleRate, 3500.0, 0.707, dbToGain(tr));
|
||||
const auto bass =
|
||||
apvts.getRawParameterValue("bass")->load();
|
||||
|
||||
const auto lm =
|
||||
apvts.getRawParameterValue("lowMid")->load();
|
||||
|
||||
const auto m =
|
||||
apvts.getRawParameterValue("middle")->load();
|
||||
|
||||
const auto tr =
|
||||
apvts.getRawParameterValue("treble")->load();
|
||||
|
||||
*lowShelf.state =
|
||||
*juce::dsp::IIR::Coefficients<float>::makeLowShelf(
|
||||
currentSampleRate,
|
||||
80.0,
|
||||
0.707,
|
||||
dbToGain(bass));
|
||||
|
||||
*lowMid.state =
|
||||
*juce::dsp::IIR::Coefficients<float>::makePeakFilter(
|
||||
currentSampleRate,
|
||||
300.0,
|
||||
0.8,
|
||||
dbToGain(lm));
|
||||
|
||||
*mid.state =
|
||||
*juce::dsp::IIR::Coefficients<float>::makePeakFilter(
|
||||
currentSampleRate,
|
||||
900.0,
|
||||
0.8,
|
||||
dbToGain(m));
|
||||
|
||||
*highShelf.state =
|
||||
*juce::dsp::IIR::Coefficients<float>::makeHighShelf(
|
||||
currentSampleRate,
|
||||
3500.0,
|
||||
0.707,
|
||||
dbToGain(tr));
|
||||
}
|
||||
|
||||
void CrilleBassStripAudioProcessor::processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBuffer&)
|
||||
void CrilleBassStripAudioProcessor::processBlock(
|
||||
juce::AudioBuffer<float>& buffer,
|
||||
juce::MidiBuffer&)
|
||||
{
|
||||
juce::ScopedNoDenormals noDenormals;
|
||||
|
||||
const int numSamples = buffer.getNumSamples();
|
||||
|
||||
const bool gateEnabled =
|
||||
apvts.getRawParameterValue("gateOn")->load() > 0.5f;
|
||||
|
||||
const bool compressorEnabled =
|
||||
apvts.getRawParameterValue("compressorOn")->load() > 0.5f;
|
||||
|
||||
const bool distortionEnabled =
|
||||
apvts.getRawParameterValue("distortionOn")->load() > 0.5f;
|
||||
|
||||
const bool eqEnabled =
|
||||
apvts.getRawParameterValue("eqOn")->load() > 0.5f;
|
||||
|
||||
if (buffer.getNumChannels() > 0)
|
||||
{
|
||||
updatePitchDetector(
|
||||
@@ -370,47 +545,65 @@ void CrilleBassStripAudioProcessor::processBlock(juce::AudioBuffer<float>& buffe
|
||||
// Copy the processed mono bass signal to both stereo output channels.
|
||||
if (buffer.getNumChannels() >= 2)
|
||||
buffer.copyFrom(1, 0, buffer, 0, 0, numSamples);
|
||||
|
||||
|
||||
// Measure input level before the noise gate.
|
||||
const float gateInputPeak = getBufferPeak(buffer);
|
||||
|
||||
gateInputLevelDb.store(
|
||||
juce::Decibels::gainToDecibels(gateInputPeak, meterFloorDb),
|
||||
juce::Decibels::gainToDecibels(
|
||||
gateInputPeak,
|
||||
meterFloorDb),
|
||||
std::memory_order_relaxed);
|
||||
|
||||
// Noise gate
|
||||
const float threshold =
|
||||
dbToGain(apvts.getRawParameterValue("gateThreshold")->load());
|
||||
|
||||
const float releaseMs =
|
||||
apvts.getRawParameterValue("gateRelease")->load();
|
||||
|
||||
const float releaseCoeff =
|
||||
std::exp(-1.f / (0.001f * releaseMs *
|
||||
static_cast<float>(currentSampleRate)));
|
||||
|
||||
const float gateGain =
|
||||
dbToGain(apvts.getRawParameterValue("gateGain")->load());
|
||||
|
||||
for (int c = 0; c < buffer.getNumChannels(); ++c)
|
||||
if (gateEnabled)
|
||||
{
|
||||
auto* x = buffer.getWritePointer(c);
|
||||
auto& env = gateEnvelope[static_cast<size_t>(c)];
|
||||
const float threshold =
|
||||
dbToGain(
|
||||
apvts.getRawParameterValue("gateThreshold")->load());
|
||||
|
||||
for (int i = 0; i < buffer.getNumSamples(); ++i)
|
||||
const float releaseMs =
|
||||
apvts.getRawParameterValue("gateRelease")->load();
|
||||
|
||||
const float releaseCoeff =
|
||||
std::exp(
|
||||
-1.f /
|
||||
(0.001f * releaseMs *
|
||||
static_cast<float>(currentSampleRate)));
|
||||
|
||||
const float gateGain =
|
||||
dbToGain(
|
||||
apvts.getRawParameterValue("gateGain")->load());
|
||||
|
||||
for (int c = 0; c < buffer.getNumChannels(); ++c)
|
||||
{
|
||||
const float target =
|
||||
std::abs(x[i]) >= threshold ? 1.f : 0.f;
|
||||
auto* x = buffer.getWritePointer(c);
|
||||
auto& env = gateEnvelope[static_cast<size_t>(c)];
|
||||
|
||||
env = target > env
|
||||
? target
|
||||
: releaseCoeff * env;
|
||||
for (int i = 0; i < buffer.getNumSamples(); ++i)
|
||||
{
|
||||
const float target =
|
||||
std::abs(x[i]) >= threshold ? 1.f : 0.f;
|
||||
|
||||
x[i] *= env * gateGain;
|
||||
env = target > env
|
||||
? target
|
||||
: releaseCoeff * env;
|
||||
|
||||
x[i] *= env * gateGain;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::fill(
|
||||
gateEnvelope.begin(),
|
||||
gateEnvelope.end(),
|
||||
1.0f);
|
||||
}
|
||||
|
||||
// Measure compressor input level.
|
||||
const float compressorInputPeak = getBufferPeak(buffer);
|
||||
const float compressorInputPeak =
|
||||
getBufferPeak(buffer);
|
||||
|
||||
compressorInputLevelDb.store(
|
||||
juce::Decibels::gainToDecibels(
|
||||
@@ -418,73 +611,95 @@ void CrilleBassStripAudioProcessor::processBlock(juce::AudioBuffer<float>& buffe
|
||||
meterFloorDb),
|
||||
std::memory_order_relaxed);
|
||||
|
||||
// Compressor
|
||||
compressor.setThreshold(
|
||||
apvts.getRawParameterValue("compThreshold")->load());
|
||||
|
||||
compressor.setRatio(
|
||||
apvts.getRawParameterValue("compRatio")->load());
|
||||
|
||||
compressor.setAttack(15.f);
|
||||
compressor.setRelease(100.f);
|
||||
|
||||
juce::dsp::AudioBlock<float> block(buffer);
|
||||
juce::dsp::ProcessContextReplacing<float> context(block);
|
||||
|
||||
compressor.process(context);
|
||||
// Compressor
|
||||
if (compressorEnabled)
|
||||
{
|
||||
compressor.setThreshold(
|
||||
apvts.getRawParameterValue("compThreshold")->load());
|
||||
|
||||
// Calculate compressor gain reduction.
|
||||
const float compressorOutputPeak = getBufferPeak(buffer);
|
||||
compressor.setRatio(
|
||||
apvts.getRawParameterValue("compRatio")->load());
|
||||
|
||||
const float gainReduction =
|
||||
compressorInputPeak > 0.0f
|
||||
? juce::jmax(
|
||||
0.0f,
|
||||
juce::Decibels::gainToDecibels(
|
||||
compressorInputPeak /
|
||||
juce::jmax(compressorOutputPeak, 1.0e-9f)))
|
||||
: 0.0f;
|
||||
compressor.setAttack(15.f);
|
||||
compressor.setRelease(100.f);
|
||||
compressor.process(context);
|
||||
|
||||
compressorGainReductionDb.store(
|
||||
juce::jlimit(0.0f, 24.0f, gainReduction),
|
||||
std::memory_order_relaxed);
|
||||
// Calculate compressor gain reduction.
|
||||
const float compressorOutputPeak =
|
||||
getBufferPeak(buffer);
|
||||
|
||||
// Compressor makeup gain.
|
||||
buffer.applyGain(
|
||||
dbToGain(
|
||||
apvts.getRawParameterValue("compGain")->load()));
|
||||
const float gainReduction =
|
||||
compressorInputPeak > 0.0f
|
||||
? juce::jmax(
|
||||
0.0f,
|
||||
juce::Decibels::gainToDecibels(
|
||||
compressorInputPeak /
|
||||
juce::jmax(
|
||||
compressorOutputPeak,
|
||||
1.0e-9f)))
|
||||
: 0.0f;
|
||||
|
||||
compressorGainReductionDb.store(
|
||||
juce::jlimit(
|
||||
0.0f,
|
||||
24.0f,
|
||||
gainReduction),
|
||||
std::memory_order_relaxed);
|
||||
|
||||
// Compressor makeup gain.
|
||||
buffer.applyGain(
|
||||
dbToGain(
|
||||
apvts.getRawParameterValue("compGain")->load()));
|
||||
}
|
||||
else
|
||||
{
|
||||
compressorGainReductionDb.store(
|
||||
0.0f,
|
||||
std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
// Distortion
|
||||
const float drive =
|
||||
dbToGain(apvts.getRawParameterValue("drive")->load());
|
||||
|
||||
const float mix =
|
||||
apvts.getRawParameterValue("mix")->load() * 0.01f;
|
||||
|
||||
const float dg =
|
||||
dbToGain(apvts.getRawParameterValue("distGain")->load());
|
||||
|
||||
for (int c = 0; c < buffer.getNumChannels(); ++c)
|
||||
if (distortionEnabled)
|
||||
{
|
||||
auto* x = buffer.getWritePointer(c);
|
||||
const float drive =
|
||||
dbToGain(
|
||||
apvts.getRawParameterValue("drive")->load());
|
||||
|
||||
for (int i = 0; i < buffer.getNumSamples(); ++i)
|
||||
const float mix =
|
||||
apvts.getRawParameterValue("mix")->load() * 0.01f;
|
||||
|
||||
const float dg =
|
||||
dbToGain(
|
||||
apvts.getRawParameterValue("distGain")->load());
|
||||
|
||||
for (int c = 0; c < buffer.getNumChannels(); ++c)
|
||||
{
|
||||
const float dry = x[i];
|
||||
const float wet = std::tanh(dry * drive);
|
||||
auto* x = buffer.getWritePointer(c);
|
||||
|
||||
x[i] =
|
||||
((1.f - mix) * dry + mix * wet) * dg;
|
||||
for (int i = 0; i < buffer.getNumSamples(); ++i)
|
||||
{
|
||||
const float dry = x[i];
|
||||
const float wet = std::tanh(dry * drive);
|
||||
|
||||
x[i] =
|
||||
((1.f - mix) * dry + mix * wet) * dg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// EQ
|
||||
updateFilters();
|
||||
if (eqEnabled)
|
||||
{
|
||||
updateFilters();
|
||||
|
||||
lowShelf.process(context);
|
||||
lowMid.process(context);
|
||||
mid.process(context);
|
||||
highShelf.process(context);
|
||||
lowShelf.process(context);
|
||||
lowMid.process(context);
|
||||
mid.process(context);
|
||||
highShelf.process(context);
|
||||
}
|
||||
|
||||
// Final output gain.
|
||||
buffer.applyGain(
|
||||
@@ -492,20 +707,28 @@ void CrilleBassStripAudioProcessor::processBlock(juce::AudioBuffer<float>& buffe
|
||||
apvts.getRawParameterValue("output")->load()));
|
||||
}
|
||||
|
||||
void CrilleBassStripAudioProcessor::getStateInformation(juce::MemoryBlock& dest)
|
||||
void CrilleBassStripAudioProcessor::getStateInformation(
|
||||
juce::MemoryBlock& dest)
|
||||
{
|
||||
if (auto xml = apvts.copyState().createXml())
|
||||
copyXmlToBinary(*xml, dest);
|
||||
}
|
||||
|
||||
void CrilleBassStripAudioProcessor::setStateInformation(const void* data, int size)
|
||||
void CrilleBassStripAudioProcessor::setStateInformation(
|
||||
const void* data,
|
||||
int size)
|
||||
{
|
||||
if (auto xml = getXmlFromBinary(data, size);
|
||||
xml != nullptr && xml->hasTagName(apvts.state.getType()))
|
||||
apvts.replaceState(juce::ValueTree::fromXml(*xml));
|
||||
xml != nullptr
|
||||
&& xml->hasTagName(apvts.state.getType()))
|
||||
{
|
||||
apvts.replaceState(
|
||||
juce::ValueTree::fromXml(*xml));
|
||||
}
|
||||
}
|
||||
|
||||
juce::AudioProcessorEditor* CrilleBassStripAudioProcessor::createEditor()
|
||||
juce::AudioProcessorEditor*
|
||||
CrilleBassStripAudioProcessor::createEditor()
|
||||
{
|
||||
return new CrilleBassStripAudioProcessorEditor(*this);
|
||||
}
|
||||
@@ -513,4 +736,4 @@ juce::AudioProcessorEditor* CrilleBassStripAudioProcessor::createEditor()
|
||||
juce::AudioProcessor* JUCE_CALLTYPE createPluginFilter()
|
||||
{
|
||||
return new CrilleBassStripAudioProcessor();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user