Skip to content

Commit

Permalink
bug fix to the reverb
Browse files Browse the repository at this point in the history
  • Loading branch information
seanlikeskites committed Jul 4, 2014
1 parent 876fa65 commit c95e275
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 18 deletions.
10 changes: 5 additions & 5 deletions JuceModules/SAFE_juce_module/PluginUtils/SAFEAudioProcessor.cpp
Expand Up @@ -137,7 +137,7 @@ const String SAFEAudioProcessor::getParameterName (int index)
const String SAFEAudioProcessor::getParameterText (int index)
{
SAFEParameter* info = parameters [index];
return String (info->getScaledValue(), 2) + info->getUnits();
return String (info->getUIScaledValue(), 2) + info->getUnits();
}

const OwnedArray <SAFEParameter>& SAFEAudioProcessor::getParameterArray()
Expand Down Expand Up @@ -803,16 +803,16 @@ bool SAFEAudioProcessor::isReadyToSave()
//==========================================================================
// Methods to Create New Parameters
//==========================================================================
void SAFEAudioProcessor::addParameter (String name, float& valueRef, float initialValue, float minValue, float maxValue, String units, float skewFactor, bool convertDBToGainValue, double interpolationTime)
void SAFEAudioProcessor::addParameter (String name, float& valueRef, float initialValue, float minValue, float maxValue, String units, float skewFactor, bool convertDBToGainValue, double interpolationTime, float UIScaleFactor)
{
parameters.add (new SAFEParameter (name, valueRef, initialValue, minValue, maxValue, units, skewFactor, convertDBToGainValue, interpolationTime));
parameters.add (new SAFEParameter (name, valueRef, initialValue, minValue, maxValue, units, skewFactor, convertDBToGainValue, interpolationTime, UIScaleFactor));

parametersToSave.add (0);
}

void SAFEAudioProcessor::addDBParameter (String name, float& valueRef, float initialValue, float minValue, float maxValue, String units, float skewFactor, double interpolationTime)
void SAFEAudioProcessor::addDBParameter (String name, float& valueRef, float initialValue, float minValue, float maxValue, String units, float skewFactor, double interpolationTime, float UIScaleFactor)
{
parameters.add (new SAFEParameter (name, valueRef, initialValue, minValue, maxValue, units, skewFactor, true, interpolationTime));
parameters.add (new SAFEParameter (name, valueRef, initialValue, minValue, maxValue, units, skewFactor, true, interpolationTime, UIScaleFactor));

parametersToSave.add (0);
}
Expand Down
4 changes: 2 additions & 2 deletions JuceModules/SAFE_juce_module/PluginUtils/SAFEAudioProcessor.h
Expand Up @@ -132,9 +132,9 @@ class SAFEAudioProcessor : public AudioProcessor,
//==========================================================================
// Methods to Create New Parameters
//==========================================================================
void addParameter (String name, float& valueRef, float initialValue = 1, float minValue = 0, float maxValue = 1, String units = String::empty, float skewFactor = 1, bool convertDBToGainValue = false, double interpolationTime = 100);
void addParameter (String name, float& valueRef, float initialValue = 1, float minValue = 0, float maxValue = 1, String units = String::empty, float skewFactor = 1, bool convertDBToGainValue = false, double interpolationTime = 100, float UIScaleFactor = 1);

void addDBParameter (String name, float& valueRef, float initialValue = 1, float minValue = 0, float maxValue = 1, String units = String::empty, float skewFactor = 1, double interpolationTimeInit = 100);
void addDBParameter (String name, float& valueRef, float initialValue = 1, float minValue = 0, float maxValue = 1, String units = String::empty, float skewFactor = 1, double interpolationTimeInit = 100, float UIScaleFactor = 1);

//==========================================================================
// Buffer Playing Audio For Analysis
Expand Down
Expand Up @@ -47,11 +47,13 @@ SAFEAudioProcessorEditor::SAFEAudioProcessorEditor (SAFEAudioProcessor* ownerFil
float currentDefaultValue = currentParameter->getDefaultValue();
float currentSkewFactor = currentParameter->getSkewFactor();
String currentUnits = currentParameter->getUnits();
float currentUIScaleFactor = currentParameter->getUIScaleFactor();

currentSlider->setRange (currentMinValue, currentMaxValue, 0.01);
currentSlider->setDefaultValue (currentDefaultValue);
currentSlider->setSkewFactor (currentSkewFactor);
currentSlider->setTextValueSuffix (currentUnits);
currentSlider->setTextBoxScaleFactor (currentUIScaleFactor);
currentSlider->addListener (this);
}

Expand Down
14 changes: 13 additions & 1 deletion JuceModules/SAFE_juce_module/PluginUtils/SAFEParameter.cpp
@@ -1,7 +1,7 @@
//==========================================================================
// Constructor and Destructor
//==========================================================================
SAFEParameter::SAFEParameter (String nameInit, float& valueRef, float initialValue, float minValueInit, float maxValueInit, String unitsInit, float skewFactorInit, bool convertDBToGainValue, double interpolationTimeInit)
SAFEParameter::SAFEParameter (String nameInit, float& valueRef, float initialValue, float minValueInit, float maxValueInit, String unitsInit, float skewFactorInit, bool convertDBToGainValue, double interpolationTimeInit, float UIScaleFactorInit)
: outputValue (valueRef),
convertToGain (convertDBToGainValue)
{
Expand All @@ -19,6 +19,8 @@ SAFEParameter::SAFEParameter (String nameInit, float& valueRef, float initialVal
interpolationTime = interpolationTimeInit;
updateBlockSizes();

UIScaleFactor = UIScaleFactorInit;

setScaledValue (defaultValue);
}

Expand Down Expand Up @@ -64,6 +66,11 @@ float SAFEParameter::getScaledValue() const
return scaledValue;
}

float SAFEParameter::getUIScaledValue() const
{
return scaledValue * UIScaleFactor;
}

float SAFEParameter::getGainValue() const
{
if (convertToGain)
Expand Down Expand Up @@ -102,6 +109,11 @@ const String SAFEParameter::getUnits() const
return units;
}

float SAFEParameter::getUIScaleFactor() const
{
return UIScaleFactor;
}

//==========================================================================
// Smoothing Bits
//==========================================================================
Expand Down
7 changes: 6 additions & 1 deletion JuceModules/SAFE_juce_module/PluginUtils/SAFEParameter.h
Expand Up @@ -7,7 +7,7 @@ class SAFEParameter
//==========================================================================
// Constructor and Destructor
//==========================================================================
SAFEParameter (String nameInit, float& valueRef, float initialValue = 1, float minValueInit = 0, float maxValueInit = 1, String unitsInit = String::empty, float skewFactorInit = 1, bool convertDBToGainValue = false, double interpolationTimeInit = 100);
SAFEParameter (String nameInit, float& valueRef, float initialValue = 1, float minValueInit = 0, float maxValueInit = 1, String unitsInit = String::empty, float skewFactorInit = 1, bool convertDBToGainValue = false, double interpolationTimeInit = 100, float UIScaleFactorInit = 1);
~SAFEParameter();

//==========================================================================
Expand All @@ -18,6 +18,7 @@ class SAFEParameter

float getBaseValue() const;
float getScaledValue() const;
float getUIScaledValue() const;
float getGainValue() const;
float getDefaultValue() const;

Expand All @@ -28,6 +29,8 @@ class SAFEParameter
const String getName() const;
const String getUnits() const;

float getUIScaleFactor() const;

//==========================================================================
// Smoothing Bits
//==========================================================================
Expand Down Expand Up @@ -56,6 +59,8 @@ class SAFEParameter

bool convertToGain;

double UIScaleFactor;

void updateBlockSizes();

void startInterpolating();
Expand Down
14 changes: 10 additions & 4 deletions JuceModules/SAFE_juce_module/UIComponents/SAFESlider.cpp
Expand Up @@ -63,6 +63,7 @@ SAFESlider::SAFESlider()
textBoxWidth (50),
textBoxHeight (15),
numDecimalPlaces (1),
textBoxScaleFactor (1),
useSIPrefixes (true)
{
setSize (80, 80);
Expand Down Expand Up @@ -126,11 +127,11 @@ void SAFESlider::setValue (double newValue, NotificationType notification)

if (units != String::empty && useSIPrefixes)
{
valueString = makeSIValueString (newValue) + units;
valueString = makeSIValueString (newValue * textBoxScaleFactor) + units;
}
else
{
valueString = String (newValue, numDecimalPlaces);
valueString = String (newValue * textBoxScaleFactor, numDecimalPlaces);
}

textBox.setText (valueString);
Expand Down Expand Up @@ -192,7 +193,7 @@ void SAFESlider::setText (String newText)
//==========================================================================
void SAFESlider::sliderValueChanged (Slider* /*movedSlider*/)
{
double sliderValue = slider.getValue();
double sliderValue = slider.getValue() * textBoxScaleFactor;

String valueString;

Expand Down Expand Up @@ -236,13 +237,18 @@ void SAFESlider::resized()
}

//==========================================================================
// Number of Decimal Places for Text Box Value
// Text Box Settings
//==========================================================================
void SAFESlider::setNumDecimalPlaces (int newNumDecimalPlaces)
{
numDecimalPlaces = newNumDecimalPlaces;
}

void SAFESlider::setTextBoxScaleFactor (double newScaleFactor)
{
textBoxScaleFactor = newScaleFactor;
}

//==========================================================================
// Make the Value String Look Pretty
//==========================================================================
Expand Down
5 changes: 4 additions & 1 deletion JuceModules/SAFE_juce_module/UIComponents/SAFESlider.h
Expand Up @@ -57,10 +57,11 @@ class SAFESlider : public Component,
void resized();

//==========================================================================
// Number of Decimal Places for Text Box Value
// Text Box Settings
//==========================================================================
void setUseSIPrefixes (bool newValue);
void setNumDecimalPlaces (int newNumDecimalPlaces);
void setTextBoxScaleFactor (double newScaleFactor);

private:
Label label;
Expand Down Expand Up @@ -104,6 +105,8 @@ class SAFESlider : public Component,
String units;
int numDecimalPlaces;

double textBoxScaleFactor;

bool useSIPrefixes;

//==========================================================================
Expand Down
8 changes: 4 additions & 4 deletions SAFEReverb/Source/PluginProcessor.cpp
Expand Up @@ -27,8 +27,8 @@ SafereverbAudioProcessor::SafereverbAudioProcessor()
addParameter ("PreDelay", predelay, 0);
addParameter ("Size", size, 0.5);
addParameter ("Gain", gain, 1.0);
addParameter ("Mix", mix, 15.0, 0.0, 100.0, "%");
addParameter ("Early Mix", earlyMix, 75.0, 0.0, 100.0, "%");
addParameter ("Mix", mix, 0.15, 0.0, 1.0, "%", 1.0, false, 100.0, 100.0);
addParameter ("Early Mix", earlyMix, 0.75, 0.0, 1.0, "%", 1.0, false, 100.0, 100.0);

for (int i = 0; i < 9; ++i)
{
Expand Down Expand Up @@ -73,11 +73,11 @@ void SafereverbAudioProcessor::parameterUpdateCalculations (int index)
break;

case MVerb<float>::MIX:
reverb.setParameter (index, mix / 100.0);
reverb.setParameter (index, mix);
break;

case MVerb<float>::EARLYMIX:
reverb.setParameter (index, earlyMix / 100.0);
reverb.setParameter (index, earlyMix);
break;
}
}
Expand Down

0 comments on commit c95e275

Please sign in to comment.