Browse Source

klangfalter: Add autogain on/off, hide autogain (level) from host

tags/2018-04-16
falkTX 6 years ago
parent
commit
b200e7409a
5 changed files with 39 additions and 22 deletions
  1. +7
    -1
      ports/klangfalter/source/Parameters.cpp
  2. +1
    -0
      ports/klangfalter/source/Parameters.h
  3. +4
    -1
      ports/klangfalter/source/Persistence.cpp
  4. +9
    -2
      ports/klangfalter/source/Processor.cpp
  5. +18
    -18
      ports/klangfalter/source/UI/KlangFalterEditor.cpp

+ 7
- 1
ports/klangfalter/source/Parameters.cpp View File

@@ -120,7 +120,13 @@ const FloatParameterDescriptor Parameters::StereoWidth(12,
0.0f,
10.0f);
const FloatParameterDescriptor Parameters::AutoGainDecibels(13,
const BoolParameterDescriptor Parameters::AutoGainOn(13,
"Autogain On",
"",
ParameterDescriptor::Automatable,
true);
const FloatParameterDescriptor Parameters::AutoGainDecibels(14,
"Autogain",
"dB",
ParameterDescriptor::NotAutomatable,


+ 1
- 0
ports/klangfalter/source/Parameters.h View File

@@ -37,6 +37,7 @@ struct Parameters
static const BoolParameterDescriptor DryOn;
static const FloatParameterDescriptor DryDecibels;
static const BoolParameterDescriptor AutoGainOn;
static const FloatParameterDescriptor AutoGainDecibels;
static const IntParameterDescriptor EqLowType;


+ 4
- 1
ports/klangfalter/source/Persistence.cpp View File

@@ -92,6 +92,7 @@ XmlElement* SaveState(const File& irDirectory, Processor& processor)
convolutionElement->setAttribute("decayShape", processor.getDecayShape());
convolutionElement->setAttribute("stereoWidth", processor.getParameter(Parameters::StereoWidth));
convolutionElement->setAttribute("reverse", processor.getReverse());
convolutionElement->setAttribute("autoGainOn", processor.getParameter(Parameters::AutoGainOn));
convolutionElement->setAttribute("autoGain", processor.getParameter(Parameters::AutoGainDecibels));
// IRs
@@ -144,6 +145,7 @@ bool LoadState(const File& irDirectory, XmlElement& element, Processor& processo
double attackShape = element.getDoubleAttribute("attackShape", 0.0);
double decayShape = element.getDoubleAttribute("decayShape", 0.0);
double stereoWidth = element.getDoubleAttribute("stereoWidth", Parameters::StereoWidth.getDefaultValue());
bool autoGainOn = element.getBoolAttribute("autoGainOn", Parameters::AutoGainOn.getDefaultValue());
double autoGain = element.getDoubleAttribute("autoGain", Parameters::AutoGainDecibels.getDefaultValue());
bool reverse = element.getBoolAttribute("reverse", false);
@@ -195,7 +197,8 @@ bool LoadState(const File& irDirectory, XmlElement& element, Processor& processo
processor.setParameterNotifyingHost(Parameters::EqHighShelfFreq, static_cast<float>(eqHiShelfFreq));
processor.setParameterNotifyingHost(Parameters::EqHighShelfDecibels, static_cast<float>(eqHiShelfDecibels));
processor.setParameterNotifyingHost(Parameters::StereoWidth, static_cast<float>(stereoWidth));
processor.setParameterNotifyingHost(Parameters::AutoGainDecibels, static_cast<float>(autoGain));
processor.setParameterNotifyingHost(Parameters::AutoGainOn, autoGainOn);
processor.setParameter(Parameters::AutoGainDecibels, static_cast<float>(autoGain));
processor.setIRBegin(irBegin);
processor.setIREnd(irEnd);
processor.setPredelayMs(predelayMs);


+ 9
- 2
ports/klangfalter/source/Processor.cpp View File

@@ -72,6 +72,7 @@ Processor::Processor() :
_parameterSet.registerParameter(Parameters::EqHighShelfFreq);
_parameterSet.registerParameter(Parameters::EqHighShelfDecibels);
_parameterSet.registerParameter(Parameters::StereoWidth);
_parameterSet.registerParameter(Parameters::AutoGainOn);
_parameterSet.registerParameter(Parameters::AutoGainDecibels);
_agents.push_back(new IRAgent(*this, 0, 0));
@@ -105,7 +106,8 @@ const String Processor::getName() const
int Processor::getNumParameters()
{
return _parameterSet.getParameterCount();
// ignore last parameter (autogain)
return _parameterSet.getParameterCount() -1;
}
float Processor::getParameter(int index)
@@ -279,7 +281,12 @@ void Processor::processBlock(AudioSampleBuffer& buffer, MidiBuffer& /*midiMessag
_wetBuffer.clear();
if (numInputChannels > 0 && numOutputChannels > 0)
{
float autoGain = DecibelScaling::Db2Gain(getParameter(Parameters::AutoGainDecibels));
float autoGain;
if (getParameter(Parameters::AutoGainOn))
autoGain = DecibelScaling::Db2Gain(getParameter(Parameters::AutoGainDecibels));
else
autoGain = 1.0f;
// Convolve
IRAgent* irAgent00 = getAgent(0, 0);


+ 18
- 18
ports/klangfalter/source/UI/KlangFalterEditor.cpp View File

@@ -1052,8 +1052,7 @@ void KlangFalterEditor::buttonClicked (Button* buttonThatWasClicked)
else if (buttonThatWasClicked == _autogainButton)
{
//[UserButtonCode__autogainButton] -- add your button handler code here..
if (_autogainButton->getToggleState())
_autogainButton->setToggleState(false, juce::dontSendNotification);
_processor.setParameterNotifyingHost(Parameters::AutoGainOn, _autogainButton->getToggleState());
//[/UserButtonCode__autogainButton]
}
else if (buttonThatWasClicked == _reverseButton)
@@ -1101,7 +1100,7 @@ void KlangFalterEditor::updateUI()
_stretchSlider->setEnabled(irAvailable);
_stretchSlider->setRange(0.5, 1.5);
_stretchSlider->setValue(stretch, juce::dontSendNotification);
_stretchLabel->setText(String(static_cast<int>(100.0*stretch)) + String("%"), juce::sendNotification);
_stretchLabel->setText(String(static_cast<int>(100.0*stretch)) + String("%"), juce::dontSendNotification);
}
{
const float db = _processor.getParameter(Parameters::DryDecibels);
@@ -1109,7 +1108,7 @@ void KlangFalterEditor::updateUI()
_drySlider->setEnabled(true);
_drySlider->setRange(0.0, 1.0);
_drySlider->setValue(scale, juce::dontSendNotification);
_dryLevelLabel->setText(DecibelScaling::DecibelString(db), juce::sendNotification);
_dryLevelLabel->setText(DecibelScaling::DecibelString(db), juce::dontSendNotification);
_dryButton->setToggleState(_processor.getParameter(Parameters::DryOn), juce::dontSendNotification);
}
{
@@ -1118,7 +1117,7 @@ void KlangFalterEditor::updateUI()
_wetSlider->setEnabled(true);
_wetSlider->setRange(0.0, 1.0);
_wetSlider->setValue(scale, juce::dontSendNotification);
_wetLevelLabel->setText(DecibelScaling::DecibelString(db), juce::sendNotification);
_wetLevelLabel->setText(DecibelScaling::DecibelString(db), juce::dontSendNotification);
_wetButton->setToggleState(_processor.getParameter(Parameters::WetOn), juce::dontSendNotification);
}
{
@@ -1129,42 +1128,43 @@ void KlangFalterEditor::updateUI()
const double irBegin = _processor.getIRBegin();
_beginSlider->setEnabled(irAvailable);
_beginSlider->setValue(irBegin, juce::dontSendNotification);
_beginLabel->setText(juce::String(static_cast<int>(100.0 * irBegin)) + juce::String("%"), juce::sendNotification);
_beginLabel->setText(juce::String(static_cast<int>(100.0 * irBegin)) + juce::String("%"), juce::dontSendNotification);
}
{
const double irEnd = _processor.getIREnd();
_endSlider->setEnabled(irAvailable);
_endSlider->setValue(irEnd, juce::dontSendNotification);
_endLabel->setText(juce::String(static_cast<int>(100.0 * irEnd)) + juce::String("%"), juce::sendNotification);
_endLabel->setText(juce::String(static_cast<int>(100.0 * irEnd)) + juce::String("%"), juce::dontSendNotification);
}
{
const double predelayMs = _processor.getPredelayMs();
_predelaySlider->setValue(predelayMs);
_predelaySlider->setEnabled(irAvailable);
_predelayLabel->setText(FormatSeconds(predelayMs / 1000.0), juce::sendNotification);
_predelayLabel->setText(FormatSeconds(predelayMs / 1000.0), juce::dontSendNotification);
}
{
const double attackLength = _processor.getAttackLength();
_attackLengthSlider->setValue(attackLength);
_attackLengthSlider->setEnabled(irAvailable);
_attackLengthLabel->setText(juce::String(100.0 * attackLength, 1)+juce::String("%"), juce::sendNotification);
_attackLengthLabel->setText(juce::String(100.0 * attackLength, 1)+juce::String("%"), juce::dontSendNotification);
}
{
const double attackShape = _processor.getAttackShape();
_attackShapeSlider->setValue(attackShape);
_attackShapeSlider->setEnabled(irAvailable);
_attackShapeLabel->setText((attackShape < 0.0001) ? juce::String("Neutral") : juce::String(attackShape, 2), juce::sendNotification);
_attackShapeLabel->setText((attackShape < 0.0001) ? juce::String("Neutral") : juce::String(attackShape, 2), juce::dontSendNotification);
}
{
const double decayShape = _processor.getDecayShape();
_decayShapeSlider->setValue(decayShape);
_decayShapeSlider->setEnabled(irAvailable);
_decayShapeLabel->setText((decayShape < 0.0001) ? juce::String("Neutral") : juce::String(decayShape, 2), juce::sendNotification);
_decayShapeLabel->setText((decayShape < 0.0001) ? juce::String("Neutral") : juce::String(decayShape, 2), juce::dontSendNotification);
}
{
const float autoGainDecibels = _processor.getParameter(Parameters::AutoGainDecibels);
const juce::String autoGainText = DecibelScaling::DecibelString(autoGainDecibels);
_autogainButton->setButtonText(juce::String("Autogain ") + autoGainText);
_autogainButton->setToggleState(_processor.getParameter(Parameters::AutoGainOn), juce::dontSendNotification);
}
{
Parameters::EqType lowEqType = static_cast<Parameters::EqType>(_processor.getParameter(Parameters::EqLowType));
@@ -1175,19 +1175,19 @@ void KlangFalterEditor::updateUI()
_lowEqButton->setButtonText(lowEqType == Parameters::Shelf ? juce::String("Low Shelf") : juce::String("Low Cut"));
_lowCutFreqHeaderLabel->setVisible(lowEqType == Parameters::Cut);
_lowCutFreqLabel->setVisible(lowEqType == Parameters::Cut);
_lowCutFreqLabel->setText((::fabs(cutFreq-Parameters::EqLowCutFreq.getMinValue()) > 0.0001f) ? FormatFrequency(cutFreq) : juce::String("Off"), juce::sendNotification);
_lowCutFreqLabel->setText((::fabs(cutFreq-Parameters::EqLowCutFreq.getMinValue()) > 0.0001f) ? FormatFrequency(cutFreq) : juce::String("Off"), juce::dontSendNotification);
_lowCutFreqSlider->setVisible(lowEqType == Parameters::Cut);
_lowCutFreqSlider->setEnabled(loEqEnabled);
_lowCutFreqSlider->setValue(cutFreq, juce::dontSendNotification);
_loFreqHeaderLabel->setVisible(lowEqType == Parameters::Shelf);
_loFreqLabel->setVisible(lowEqType == Parameters::Shelf);
_loFreqLabel->setText(FormatFrequency(shelfFreq), juce::sendNotification);
_loFreqLabel->setText(FormatFrequency(shelfFreq), juce::dontSendNotification);
_loFreqSlider->setVisible(lowEqType == Parameters::Shelf);
_loFreqSlider->setEnabled(loEqEnabled);
_loFreqSlider->setValue(shelfFreq, juce::dontSendNotification);
_loGainHeaderLabel->setVisible(lowEqType == Parameters::Shelf);
_loGainLabel->setVisible(lowEqType == Parameters::Shelf);
_loGainLabel->setText(DecibelScaling::DecibelString(shelfGainDb), juce::sendNotification);
_loGainLabel->setText(DecibelScaling::DecibelString(shelfGainDb), juce::dontSendNotification);
_loGainSlider->setVisible(lowEqType == Parameters::Shelf);
_loGainSlider->setEnabled(loEqEnabled);
_loGainSlider->setValue(shelfGainDb, juce::dontSendNotification);
@@ -1201,19 +1201,19 @@ void KlangFalterEditor::updateUI()
_highEqButton->setButtonText(highEqType == Parameters::Shelf ? juce::String("High Shelf") : juce::String("High Cut"));
_highCutFreqHeaderLabel->setVisible(highEqType == Parameters::Cut);
_highCutFreqLabel->setVisible(highEqType == Parameters::Cut);
_highCutFreqLabel->setText((::fabs(cutFreq-Parameters::EqHighCutFreq.getMaxValue()) > 0.0001f) ? FormatFrequency(cutFreq) : juce::String("Off"), juce::sendNotification);
_highCutFreqLabel->setText((::fabs(cutFreq-Parameters::EqHighCutFreq.getMaxValue()) > 0.0001f) ? FormatFrequency(cutFreq) : juce::String("Off"), juce::dontSendNotification);
_highCutFreqSlider->setVisible(highEqType == Parameters::Cut);
_highCutFreqSlider->setEnabled(hiEqEnabled);
_highCutFreqSlider->setValue(cutFreq, juce::dontSendNotification);
_hiFreqHeaderLabel->setVisible(highEqType == Parameters::Shelf);
_hiFreqLabel->setVisible(highEqType == Parameters::Shelf);
_hiFreqLabel->setText(FormatFrequency(shelfFreq), juce::sendNotification);
_hiFreqLabel->setText(FormatFrequency(shelfFreq), juce::dontSendNotification);
_hiFreqSlider->setVisible(highEqType == Parameters::Shelf);
_hiFreqSlider->setEnabled(hiEqEnabled);
_hiFreqSlider->setValue(shelfFreq, juce::dontSendNotification);
_hiGainHeaderLabel->setVisible(highEqType == Parameters::Shelf);
_hiGainLabel->setVisible(highEqType == Parameters::Shelf);
_hiGainLabel->setText(DecibelScaling::DecibelString(shelfGainDb), juce::sendNotification);
_hiGainLabel->setText(DecibelScaling::DecibelString(shelfGainDb), juce::dontSendNotification);
_hiGainSlider->setVisible(highEqType == Parameters::Shelf);
_hiGainSlider->setEnabled(hiEqEnabled);
_hiGainSlider->setValue(shelfGainDb, juce::dontSendNotification);
@@ -1225,7 +1225,7 @@ void KlangFalterEditor::updateUI()
_widthLabel->setVisible(numOutputChannels >= 2);
const float stereoWidth = _processor.getParameter(Parameters::StereoWidth);
_widthSlider->setValue(stereoWidth, juce::dontSendNotification);
_widthLabel->setText((::fabs(1.0f-stereoWidth) < 0.001) ? juce::String("Neutral") : juce::String(stereoWidth, 2), juce::sendNotification);
_widthLabel->setText((::fabs(1.0f-stereoWidth) < 0.001) ? juce::String("Neutral") : juce::String(stereoWidth, 2), juce::dontSendNotification);
}
{
_levelMeterDry->setChannelCount(numInputChannels);


Loading…
Cancel
Save