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"
|
PRODUCT_NAME "Crille Bass Strip"
|
||||||
COMPANY_NAME "Crille Audio"
|
COMPANY_NAME "Crille Audio"
|
||||||
BUNDLE_ID "org.crilleaudio.crillebassstrip"
|
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)
|
juce_generate_juce_header(CrilleBassStripApp)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<key>CFBundleExecutable</key>
|
<key>CFBundleExecutable</key>
|
||||||
<string>Crille Bass Strip</string>
|
<string>Crille Bass Strip</string>
|
||||||
<key>CFBundleIconFile</key>
|
<key>CFBundleIconFile</key>
|
||||||
<string></string>
|
<string>Icon.icns</string>
|
||||||
<key>CFBundleIdentifier</key>
|
<key>CFBundleIdentifier</key>
|
||||||
<string>org.crilleaudio.crillebassstrip</string>
|
<string>org.crilleaudio.crillebassstrip</string>
|
||||||
<key>CFBundleName</key>
|
<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::
|
||||||
CrilleBassStripAudioProcessorEditor(
|
CrilleBassStripAudioProcessorEditor(
|
||||||
CrilleBassStripAudioProcessor& p)
|
CrilleBassStripAudioProcessor& p)
|
||||||
@@ -251,6 +306,43 @@ CrilleBassStripAudioProcessorEditor(
|
|||||||
downTuneButton
|
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(
|
addKnob(
|
||||||
"gateThreshold",
|
"gateThreshold",
|
||||||
"THRESHOLD"
|
"THRESHOLD"
|
||||||
@@ -325,6 +417,8 @@ CrilleBassStripAudioProcessorEditor(
|
|||||||
addAndMakeVisible(compressorInputMeter);
|
addAndMakeVisible(compressorInputMeter);
|
||||||
addAndMakeVisible(compressorReductionMeter);
|
addAndMakeVisible(compressorReductionMeter);
|
||||||
|
|
||||||
|
updateSectionStates();
|
||||||
|
|
||||||
setSize(760, 720);
|
setSize(760, 720);
|
||||||
startTimerHz(30);
|
startTimerHz(30);
|
||||||
}
|
}
|
||||||
@@ -399,6 +493,40 @@ void CrilleBassStripAudioProcessorEditor::addKnob(
|
|||||||
knobs.push_back(std::move(k));
|
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 CrilleBassStripAudioProcessorEditor::smoothMeter(
|
||||||
float current,
|
float current,
|
||||||
float target,
|
float target,
|
||||||
@@ -414,6 +542,8 @@ float CrilleBassStripAudioProcessorEditor::smoothMeter(
|
|||||||
|
|
||||||
void CrilleBassStripAudioProcessorEditor::timerCallback()
|
void CrilleBassStripAudioProcessorEditor::timerCallback()
|
||||||
{
|
{
|
||||||
|
updateSectionStates();
|
||||||
|
|
||||||
smoothedGateDb =
|
smoothedGateDb =
|
||||||
smoothMeter(
|
smoothMeter(
|
||||||
smoothedGateDb,
|
smoothedGateDb,
|
||||||
@@ -499,70 +629,55 @@ void CrilleBassStripAudioProcessorEditor::paint(
|
|||||||
juce::Justification::centredLeft
|
juce::Justification::centredLeft
|
||||||
);
|
);
|
||||||
|
|
||||||
const struct
|
const bool panelStates[]
|
||||||
{
|
{
|
||||||
juce::Rectangle<int> bounds;
|
downTuneButton.getToggleState(),
|
||||||
juce::String title;
|
gateToggleButton.getToggleState(),
|
||||||
juce::Colour border;
|
compressorToggleButton.getToggleState(),
|
||||||
}
|
distortionToggleButton.getToggleState(),
|
||||||
panels[]
|
eqToggleButton.getToggleState()
|
||||||
{
|
|
||||||
{
|
|
||||||
{ 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)
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
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(
|
g.setColour(active
|
||||||
bounds.toFloat(),
|
? juce::Colour(0xff1b1f24)
|
||||||
10.0f
|
: juce::Colour(0xff171a1e));
|
||||||
);
|
|
||||||
|
|
||||||
g.setColour(panel.border);
|
g.fillRoundedRectangle(bounds, 10.0f);
|
||||||
|
|
||||||
g.drawRoundedRectangle(
|
g.setColour(active
|
||||||
bounds.toFloat(),
|
? juce::Colour(0xff4a5058)
|
||||||
10.0f,
|
: juce::Colour(0xff2a2e34));
|
||||||
2.0f
|
|
||||||
);
|
|
||||||
|
|
||||||
g.setColour(juce::Colour(0xfff0f1f2));
|
g.drawRoundedRectangle(bounds, 10.0f, 2.0f);
|
||||||
g.setFont(15.0f);
|
|
||||||
|
|
||||||
g.drawText(
|
|
||||||
panel.title,
|
|
||||||
bounds.removeFromTop(38),
|
|
||||||
juce::Justification::centred
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 =
|
const float inputFrequency =
|
||||||
processor.getDetectedFrequencyHz();
|
processor.getDetectedFrequencyHz();
|
||||||
|
|
||||||
@@ -722,6 +837,30 @@ void CrilleBassStripAudioProcessorEditor::paint(
|
|||||||
|
|
||||||
void CrilleBassStripAudioProcessorEditor::resized()
|
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(
|
downTuneButton.setBounds(
|
||||||
35,
|
35,
|
||||||
135,
|
135,
|
||||||
|
|||||||
+107
-17
@@ -1,12 +1,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <JuceHeader.h>
|
#include <JuceHeader.h>
|
||||||
#include "PluginProcessor.h"
|
#include "PluginProcessor.h"
|
||||||
|
|
||||||
class CrilleBassStripAudioProcessorEditor final : public juce::AudioProcessorEditor,
|
class CrilleBassStripAudioProcessorEditor final
|
||||||
private juce::Timer
|
: public juce::AudioProcessorEditor,
|
||||||
|
private juce::Timer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit CrilleBassStripAudioProcessorEditor(CrilleBassStripAudioProcessor&);
|
explicit CrilleBassStripAudioProcessorEditor(
|
||||||
|
CrilleBassStripAudioProcessor&);
|
||||||
|
|
||||||
~CrilleBassStripAudioProcessorEditor() override = default;
|
~CrilleBassStripAudioProcessorEditor() override = default;
|
||||||
|
|
||||||
void paint(juce::Graphics&) override;
|
void paint(juce::Graphics&) override;
|
||||||
@@ -16,9 +20,14 @@ private:
|
|||||||
class LevelMeter final : public juce::Component
|
class LevelMeter final : public juce::Component
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum class Mode { inputLevel, gainReduction };
|
enum class Mode
|
||||||
|
{
|
||||||
|
inputLevel,
|
||||||
|
gainReduction
|
||||||
|
};
|
||||||
|
|
||||||
explicit LevelMeter(Mode meterMode);
|
explicit LevelMeter(Mode meterMode);
|
||||||
|
|
||||||
void setLevel(float newLevelDb);
|
void setLevel(float newLevelDb);
|
||||||
void setThreshold(float newThresholdDb);
|
void setThreshold(float newThresholdDb);
|
||||||
void paint(juce::Graphics&) override;
|
void paint(juce::Graphics&) override;
|
||||||
@@ -29,6 +38,22 @@ private:
|
|||||||
float thresholdDb = -80.0f;
|
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
|
struct Knob
|
||||||
{
|
{
|
||||||
juce::Slider slider;
|
juce::Slider slider;
|
||||||
@@ -36,25 +61,90 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
CrilleBassStripAudioProcessor& processor;
|
CrilleBassStripAudioProcessor& processor;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<Knob>> knobs;
|
std::vector<std::unique_ptr<Knob>> knobs;
|
||||||
std::vector<std::unique_ptr<juce::AudioProcessorValueTreeState::SliderAttachment>> attachments;
|
|
||||||
juce::ToggleButton downTuneButton;
|
|
||||||
|
|
||||||
std::unique_ptr<
|
std::vector<std::unique_ptr<
|
||||||
juce::AudioProcessorValueTreeState::ButtonAttachment
|
juce::AudioProcessorValueTreeState::SliderAttachment>>
|
||||||
> downTuneAttachment;
|
attachments;
|
||||||
|
|
||||||
LevelMeter gateInputMeter { LevelMeter::Mode::inputLevel };
|
juce::ToggleButton downTuneButton;
|
||||||
LevelMeter compressorInputMeter { LevelMeter::Mode::inputLevel };
|
|
||||||
LevelMeter compressorReductionMeter { LevelMeter::Mode::gainReduction };
|
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 smoothedGateDb = -80.0f;
|
||||||
float smoothedCompressorDb = -80.0f;
|
float smoothedCompressorDb = -80.0f;
|
||||||
float smoothedReductionDb = 0.0f;
|
float smoothedReductionDb = 0.0f;
|
||||||
|
|
||||||
void addKnob(const juce::String& parameter, const juce::String& caption);
|
void addKnob(
|
||||||
void timerCallback() override;
|
const juce::String& parameter,
|
||||||
static float smoothMeter(float current, float target, float attack, float release);
|
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;
|
using P = juce::AudioParameterFloat;
|
||||||
juce::AudioProcessorValueTreeState::ParameterLayout p;
|
juce::AudioProcessorValueTreeState::ParameterLayout p;
|
||||||
|
|
||||||
p.add(std::make_unique<juce::AudioParameterBool>(
|
p.add(std::make_unique<juce::AudioParameterBool>(
|
||||||
pid("downTuneOn"),
|
pid("downTuneOn"),
|
||||||
"DownTune",
|
"DownTune",
|
||||||
false));
|
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<juce::AudioParameterBool>(
|
||||||
p.add(std::make_unique<P>(pid("gateGain"), "Gate Gain", juce::NormalisableRange<float>(-24.f, 12.f, 0.1f), 0.f, "dB"));
|
pid("gateOn"),
|
||||||
p.add(std::make_unique<P>(pid("compThreshold"), "Comp Threshold", juce::NormalisableRange<float>(-60.f, 0.f, 0.1f), -18.f, "dB"));
|
"Gate On",
|
||||||
p.add(std::make_unique<P>(pid("compRatio"), "Comp Ratio", juce::NormalisableRange<float>(1.f, 20.f, 0.1f, 0.5f), 4.f, ":1"));
|
true));
|
||||||
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<juce::AudioParameterBool>(
|
||||||
p.add(std::make_unique<P>(pid("mix"), "Distortion Mix", juce::NormalisableRange<float>(0.f, 100.f, 1.f), 25.f, "%"));
|
pid("compressorOn"),
|
||||||
p.add(std::make_unique<P>(pid("distGain"), "Distortion Gain", juce::NormalisableRange<float>(-18.f, 12.f, 0.1f), 0.f, "dB"));
|
"Compressor On",
|
||||||
p.add(std::make_unique<P>(pid("bass"), "Bass", juce::NormalisableRange<float>(-12.f, 12.f, 0.1f), 2.f, "dB"));
|
true));
|
||||||
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<juce::AudioParameterBool>(
|
||||||
p.add(std::make_unique<P>(pid("treble"), "Treble", juce::NormalisableRange<float>(-12.f, 12.f, 0.1f), 1.f, "dB"));
|
pid("distortionOn"),
|
||||||
p.add(std::make_unique<P>(pid("output"), "Output", juce::NormalisableRange<float>(-24.f, 12.f, 0.1f), -1.f, "dB"));
|
"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;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,14 +166,16 @@ void CrilleBassStripAudioProcessor::prepareToPlay(double sr, int block)
|
|||||||
setLatencySamples(
|
setLatencySamples(
|
||||||
downTune.inputLatency() +
|
downTune.inputLatency() +
|
||||||
downTune.outputLatency());
|
downTune.outputLatency());
|
||||||
|
|
||||||
downTuneLatencyMs =
|
downTuneLatencyMs =
|
||||||
1000.0 *
|
1000.0 *
|
||||||
(downTune.inputLatency() + downTune.outputLatency()) /
|
(downTune.inputLatency() + downTune.outputLatency()) /
|
||||||
sr;
|
sr;
|
||||||
|
|
||||||
//debug börjar
|
//debug börjar
|
||||||
DBG("DownTune input latency: "
|
DBG("DownTune input latency: "
|
||||||
<< downTune.inputLatency()
|
<< downTune.inputLatency()
|
||||||
<< " samples");
|
<< " samples");
|
||||||
|
|
||||||
DBG("DownTune output latency: "
|
DBG("DownTune output latency: "
|
||||||
<< downTune.outputLatency()
|
<< downTune.outputLatency()
|
||||||
@@ -80,40 +188,61 @@ void CrilleBassStripAudioProcessor::prepareToPlay(double sr, int block)
|
|||||||
DBG("DownTune latency ms: "
|
DBG("DownTune latency ms: "
|
||||||
<< 1000.0 * (downTune.inputLatency() + downTune.outputLatency()) / sr);
|
<< 1000.0 * (downTune.inputLatency() + downTune.outputLatency()) / sr);
|
||||||
// debug slutar
|
// 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);
|
compressor.prepare(spec);
|
||||||
lowShelf.prepare(spec);
|
lowShelf.prepare(spec);
|
||||||
lowMid.prepare(spec);
|
lowMid.prepare(spec);
|
||||||
mid.prepare(spec);
|
mid.prepare(spec);
|
||||||
highShelf.prepare(spec);
|
highShelf.prepare(spec);
|
||||||
|
|
||||||
compressor.reset();
|
compressor.reset();
|
||||||
lowShelf.reset();
|
lowShelf.reset();
|
||||||
lowMid.reset();
|
lowMid.reset();
|
||||||
mid.reset();
|
mid.reset();
|
||||||
highShelf.reset();
|
highShelf.reset();
|
||||||
gateEnvelope.assign(static_cast<size_t>(getTotalNumOutputChannels()), 0.f);
|
|
||||||
|
gateEnvelope.assign(
|
||||||
|
static_cast<size_t>(getTotalNumOutputChannels()),
|
||||||
|
0.f);
|
||||||
|
|
||||||
gateInputLevelDb.store(meterFloorDb);
|
gateInputLevelDb.store(meterFloorDb);
|
||||||
compressorInputLevelDb.store(meterFloorDb);
|
compressorInputLevelDb.store(meterFloorDb);
|
||||||
compressorGainReductionDb.store(0.0f);
|
compressorGainReductionDb.store(0.0f);
|
||||||
|
|
||||||
updateFilters();
|
updateFilters();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CrilleBassStripAudioProcessor::isBusesLayoutSupported(const BusesLayout& layouts) const
|
bool CrilleBassStripAudioProcessor::isBusesLayoutSupported(const BusesLayout& layouts) const
|
||||||
{
|
{
|
||||||
const auto input = layouts.getMainInputChannelSet();
|
const auto input = layouts.getMainInputChannelSet();
|
||||||
const auto output = layouts.getMainOutputChannelSet();
|
const auto output = layouts.getMainOutputChannelSet();
|
||||||
|
|
||||||
return input == juce::AudioChannelSet::mono()
|
return input == juce::AudioChannelSet::mono()
|
||||||
&& output == juce::AudioChannelSet::stereo();
|
&& 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;
|
float peak = 0.0f;
|
||||||
|
|
||||||
for (int channel = 0; channel < buffer.getNumChannels(); ++channel)
|
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;
|
return peak;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrilleBassStripAudioProcessor::updatePitchDetector(
|
void CrilleBassStripAudioProcessor::updatePitchDetector(
|
||||||
const float* input,
|
const float* input,
|
||||||
int numSamples)
|
int numSamples)
|
||||||
@@ -302,21 +431,67 @@ void CrilleBassStripAudioProcessor::analysePitch()
|
|||||||
|
|
||||||
void CrilleBassStripAudioProcessor::updateFilters()
|
void CrilleBassStripAudioProcessor::updateFilters()
|
||||||
{
|
{
|
||||||
const auto bass = apvts.getRawParameterValue("bass")->load();
|
const auto bass =
|
||||||
const auto lm = apvts.getRawParameterValue("lowMid")->load();
|
apvts.getRawParameterValue("bass")->load();
|
||||||
const auto m = apvts.getRawParameterValue("middle")->load();
|
|
||||||
const auto tr = apvts.getRawParameterValue("treble")->load();
|
const auto lm =
|
||||||
*lowShelf.state = *juce::dsp::IIR::Coefficients<float>::makeLowShelf(currentSampleRate, 80.0, 0.707, dbToGain(bass));
|
apvts.getRawParameterValue("lowMid")->load();
|
||||||
*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));
|
const auto m =
|
||||||
*highShelf.state = *juce::dsp::IIR::Coefficients<float>::makeHighShelf(currentSampleRate, 3500.0, 0.707, dbToGain(tr));
|
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;
|
juce::ScopedNoDenormals noDenormals;
|
||||||
|
|
||||||
const int numSamples = buffer.getNumSamples();
|
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)
|
if (buffer.getNumChannels() > 0)
|
||||||
{
|
{
|
||||||
updatePitchDetector(
|
updatePitchDetector(
|
||||||
@@ -370,47 +545,65 @@ void CrilleBassStripAudioProcessor::processBlock(juce::AudioBuffer<float>& buffe
|
|||||||
// Copy the processed mono bass signal to both stereo output channels.
|
// Copy the processed mono bass signal to both stereo output channels.
|
||||||
if (buffer.getNumChannels() >= 2)
|
if (buffer.getNumChannels() >= 2)
|
||||||
buffer.copyFrom(1, 0, buffer, 0, 0, numSamples);
|
buffer.copyFrom(1, 0, buffer, 0, 0, numSamples);
|
||||||
|
|
||||||
// Measure input level before the noise gate.
|
// Measure input level before the noise gate.
|
||||||
const float gateInputPeak = getBufferPeak(buffer);
|
const float gateInputPeak = getBufferPeak(buffer);
|
||||||
|
|
||||||
gateInputLevelDb.store(
|
gateInputLevelDb.store(
|
||||||
juce::Decibels::gainToDecibels(gateInputPeak, meterFloorDb),
|
juce::Decibels::gainToDecibels(
|
||||||
|
gateInputPeak,
|
||||||
|
meterFloorDb),
|
||||||
std::memory_order_relaxed);
|
std::memory_order_relaxed);
|
||||||
|
|
||||||
// Noise gate
|
// Noise gate
|
||||||
const float threshold =
|
if (gateEnabled)
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
auto* x = buffer.getWritePointer(c);
|
const float threshold =
|
||||||
auto& env = gateEnvelope[static_cast<size_t>(c)];
|
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 =
|
auto* x = buffer.getWritePointer(c);
|
||||||
std::abs(x[i]) >= threshold ? 1.f : 0.f;
|
auto& env = gateEnvelope[static_cast<size_t>(c)];
|
||||||
|
|
||||||
env = target > env
|
for (int i = 0; i < buffer.getNumSamples(); ++i)
|
||||||
? target
|
{
|
||||||
: releaseCoeff * env;
|
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.
|
// Measure compressor input level.
|
||||||
const float compressorInputPeak = getBufferPeak(buffer);
|
const float compressorInputPeak =
|
||||||
|
getBufferPeak(buffer);
|
||||||
|
|
||||||
compressorInputLevelDb.store(
|
compressorInputLevelDb.store(
|
||||||
juce::Decibels::gainToDecibels(
|
juce::Decibels::gainToDecibels(
|
||||||
@@ -418,73 +611,95 @@ void CrilleBassStripAudioProcessor::processBlock(juce::AudioBuffer<float>& buffe
|
|||||||
meterFloorDb),
|
meterFloorDb),
|
||||||
std::memory_order_relaxed);
|
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::AudioBlock<float> block(buffer);
|
||||||
juce::dsp::ProcessContextReplacing<float> context(block);
|
juce::dsp::ProcessContextReplacing<float> context(block);
|
||||||
|
|
||||||
compressor.process(context);
|
// Compressor
|
||||||
|
if (compressorEnabled)
|
||||||
|
{
|
||||||
|
compressor.setThreshold(
|
||||||
|
apvts.getRawParameterValue("compThreshold")->load());
|
||||||
|
|
||||||
// Calculate compressor gain reduction.
|
compressor.setRatio(
|
||||||
const float compressorOutputPeak = getBufferPeak(buffer);
|
apvts.getRawParameterValue("compRatio")->load());
|
||||||
|
|
||||||
const float gainReduction =
|
compressor.setAttack(15.f);
|
||||||
compressorInputPeak > 0.0f
|
compressor.setRelease(100.f);
|
||||||
? juce::jmax(
|
compressor.process(context);
|
||||||
0.0f,
|
|
||||||
juce::Decibels::gainToDecibels(
|
|
||||||
compressorInputPeak /
|
|
||||||
juce::jmax(compressorOutputPeak, 1.0e-9f)))
|
|
||||||
: 0.0f;
|
|
||||||
|
|
||||||
compressorGainReductionDb.store(
|
// Calculate compressor gain reduction.
|
||||||
juce::jlimit(0.0f, 24.0f, gainReduction),
|
const float compressorOutputPeak =
|
||||||
std::memory_order_relaxed);
|
getBufferPeak(buffer);
|
||||||
|
|
||||||
// Compressor makeup gain.
|
const float gainReduction =
|
||||||
buffer.applyGain(
|
compressorInputPeak > 0.0f
|
||||||
dbToGain(
|
? juce::jmax(
|
||||||
apvts.getRawParameterValue("compGain")->load()));
|
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
|
// Distortion
|
||||||
const float drive =
|
if (distortionEnabled)
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
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];
|
auto* x = buffer.getWritePointer(c);
|
||||||
const float wet = std::tanh(dry * drive);
|
|
||||||
|
|
||||||
x[i] =
|
for (int i = 0; i < buffer.getNumSamples(); ++i)
|
||||||
((1.f - mix) * dry + mix * wet) * dg;
|
{
|
||||||
|
const float dry = x[i];
|
||||||
|
const float wet = std::tanh(dry * drive);
|
||||||
|
|
||||||
|
x[i] =
|
||||||
|
((1.f - mix) * dry + mix * wet) * dg;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// EQ
|
// EQ
|
||||||
updateFilters();
|
if (eqEnabled)
|
||||||
|
{
|
||||||
|
updateFilters();
|
||||||
|
|
||||||
lowShelf.process(context);
|
lowShelf.process(context);
|
||||||
lowMid.process(context);
|
lowMid.process(context);
|
||||||
mid.process(context);
|
mid.process(context);
|
||||||
highShelf.process(context);
|
highShelf.process(context);
|
||||||
|
}
|
||||||
|
|
||||||
// Final output gain.
|
// Final output gain.
|
||||||
buffer.applyGain(
|
buffer.applyGain(
|
||||||
@@ -492,20 +707,28 @@ void CrilleBassStripAudioProcessor::processBlock(juce::AudioBuffer<float>& buffe
|
|||||||
apvts.getRawParameterValue("output")->load()));
|
apvts.getRawParameterValue("output")->load()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrilleBassStripAudioProcessor::getStateInformation(juce::MemoryBlock& dest)
|
void CrilleBassStripAudioProcessor::getStateInformation(
|
||||||
|
juce::MemoryBlock& dest)
|
||||||
{
|
{
|
||||||
if (auto xml = apvts.copyState().createXml())
|
if (auto xml = apvts.copyState().createXml())
|
||||||
copyXmlToBinary(*xml, dest);
|
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);
|
if (auto xml = getXmlFromBinary(data, size);
|
||||||
xml != nullptr && xml->hasTagName(apvts.state.getType()))
|
xml != nullptr
|
||||||
apvts.replaceState(juce::ValueTree::fromXml(*xml));
|
&& xml->hasTagName(apvts.state.getType()))
|
||||||
|
{
|
||||||
|
apvts.replaceState(
|
||||||
|
juce::ValueTree::fromXml(*xml));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
juce::AudioProcessorEditor* CrilleBassStripAudioProcessor::createEditor()
|
juce::AudioProcessorEditor*
|
||||||
|
CrilleBassStripAudioProcessor::createEditor()
|
||||||
{
|
{
|
||||||
return new CrilleBassStripAudioProcessorEditor(*this);
|
return new CrilleBassStripAudioProcessorEditor(*this);
|
||||||
}
|
}
|
||||||
@@ -513,4 +736,4 @@ juce::AudioProcessorEditor* CrilleBassStripAudioProcessor::createEditor()
|
|||||||
juce::AudioProcessor* JUCE_CALLTYPE createPluginFilter()
|
juce::AudioProcessor* JUCE_CALLTYPE createPluginFilter()
|
||||||
{
|
{
|
||||||
return new CrilleBassStripAudioProcessor();
|
return new CrilleBassStripAudioProcessor();
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user