Hi,
I’m in the process of trying to figure out the implementation for converting gain values from the AudioParameterFloat definition in the constructor into db and % for the UI in the editor.
addParameter(mDelayTimeParameter = new AudioParameterFloat("delatime",
"Delay Time",
0.0f,
0.15f,
0.02f));
addParameter(mFeedbackParameter = new AudioParameterFloat("feedback",
"Feedback",
0.0f,
0.98f,
0.1));
addParameter(mDryWetParameter = new AudioParameterFloat("drywet",
"Dry / Wet",
0.0f,
1.0f,
0.5f));
addParameter(mSaturationlevelParameter = new AudioParameterFloat("saturation",
"Saturation",
1.0f,
6.0f,
1.5));
addParameter(mDelayOutputLevelParameter = new AudioParameterFloat("output",
"Output Level",
0.0f,
1.0f,
0.5f));
// static float Decibels::gainToDecibels (float gain,
// float minusInfinityDb = float (defaultMinusInfinitydB)
// );
I understand the conversion between gain values:
0-1 to db 20*log(x) = db
0-1 gain * 100 = %
However, I’m not sure where to implement this to allow the process block to deal with gain values and the UI to show db values
I attempted to alter the slider.Setvalue method in the editor but these just defaulted back to the values set in the constructor
///////////////////////////////////////////////////////
//////////// SATURATION LEVEL SLIDER /////////////////
AudioParameterFloat* mSaturationlevelParameter = (AudioParameterFloat*)params.getUnchecked(3);
SaturationlevelSlider.setSliderStyle(Slider::SliderStyle::RotaryHorizontalVerticalDrag);
SaturationlevelSlider.setBounds(400,100,200,80);
SaturationlevelSlider.setRange(mSaturationlevelParameter->range.start, mSaturationlevelParameter->range.end);
SaturationlevelSlider.setValue(20*log(*mSaturationlevelParameter)); <--- if only it were that simple
// mDelayTimeSlider.addListener(this);
SaturationlevelSlider.setTextValueSuffix("db");
addAndMakeVisible(SaturationlevelSlider);
SaturationlevelSlider.onValueChange = [this, mSaturationlevelParameter]
{ *mSaturationlevelParameter = SaturationlevelSlider.getValue(); };
SaturationlevelSlider.onDragStart = [mSaturationlevelParameter]
{ mSaturationlevelParameter->beginChangeGesture(); };
SaturationlevelSlider.onDragEnd = [mSaturationlevelParameter]
{ mSaturationlevelParameter->endChangeGesture(); };
addAndMakeVisible(SaturationlevelSlider);
SaturationlevelLabel.setText("Saturation", dontSendNotification);
SaturationlevelLabel.attachToComponent(&SaturationlevelSlider, true);
I have read through the forum posts on the topic, but my understanding is not yet such that I can make sense of them.
I have read these sources:
https://docs.juce.com/master/classDecibels.html#aa8114cb97adb33d7723e8a5bc6f67c18
but I need a noob run through if anyone would care to enlighten me!
Thanks,
Alex