I’ve got my IIR high pass filter working on my PluginProcessor side, but on the GUI / PluginEdtior side, the frequency knob shows 20.0 Hz to 20480.0 Hz on a linear scale, even though I am using “hpfHzSlider.setSkewFactorFromMidPoint(1024.0)” to try to make the scale logarithmic. I don’t understand why this wouldn’t work.
Here is my code, from my PluginEditor.cpp :
"
hpfHzSlider.setSliderStyle(Slider::SliderStyle::RotaryHorizontalVerticalDrag);
hpfHzSlider.setTextBoxStyle(Slider::NoTextBox, false, 62, 38);
hpfHzSlider.hideTextBox(true);
hpfHzSlider.setValue(20.0);
hpfHzSlider.setSkewFactorFromMidPoint(1024.0);
hpfHzSlider.setRange(20.0, 20480.0);
hpfHzSlider.setPopupDisplayEnabled(true, true, this);
hpfHzSlider.setTextValueSuffix(" Hz");
hpfHzSlider.addListener(this);
addAndMakeVisible(hpfHzSlider);
hpfHzSlideAttch = std::make_uniqueAudioProcessorValueTreeState::SliderAttachment(processor.apvts,“hpfHz”, hpfHzSlider);
i can’t answer your question due to my low juce skill level, but i’d like to point out that a skew factor is not a logarithmic curve, but just a linear curve split into 2 linear curves that meet at some value. it can give the impression of unlinear curves but maybe for a parameter that goes through such a huge range of values it might be better to make it truly log
Hi @baintonaj, to make your code more readable, please indent every line with 4 spaces, or surround the whole code with three backticks before and after, like this:
```
void your_code_here ()
{
}
```
The same is obtained by selecting the code in your post while editing, then pressing the button that has this symbol on it: </>
I am not entirely sure why your code above is not working. However I want to propose another solution to you, as I see you tapping into the same trap I was in half a year ago:
When you attach your Slider to the AudioParameter, it will automatically use the range, skew, and initial value from it. Furthermore, they can start conflicting when your GUI control uses skew, but your AudioParam doesn’t. So in your AudioProcessorValueTreeState initializer list you have to use
hpfHzSlideAttch.reset(new SliderAttachment(processor.apvts, "hpfHz", hpfHzSlider));
//don't need these anymore:
//hpfHzSlider.setValue(HPF_INITIAL_VALUE);
//hpfHzSlider.setSkewFactorFromMidPoint(HPF_MID);
//hpfHzSlider.setRange(HPF_MIN, HPF_MAX);
Now one problem here is that you cannot set the skew from a midpoint anymore, which is convenient. To get the skewvalues, I used the same method as you do now (although working), and the immediately called getSkewFactor() to write out the value.
Anyway I’m using similar ranges for my filters as you (80-18kHz) and a skew factor of
I might be mistaken, but I think this is not true (in JUCE at least). The documentation of setSkewFactor() states that it “…will logarithmically spread the values across the length of the slider” and in juce_NormalisableRange.h line 139 the calculation Slider → [0,1] goes
oh nice. didn’t expect that. still op’s question, why it doesn’t work in their code remains unanswered… i wish i could help but i didn’t experiment with unlinear sliders in juce a lot yet.
For frequency controls, where the pitch midpoint is sqrt(min * max), the corresponding skew factor is 1 / log2(1 + sqrt(max / min)), so I get the normalisable range with
1 kHz will be 1 kHz everywhere. What the skew changes is the relation with the internal 0…1 value stored by AudioParameterFloat. The usual (most “automatic”) arrangement is to have an AudioProcessorValueTreeState as a member of your AudioProcessor holding all your automatable parameters, then a Slider/Button/ComboBoxAttachment for each UI element that controls one of them, usually as members of your AudioProcessorEditor. See this tutorial. You create your parameters in your AudioProcessor constructor -that’s where you set a skew for any parameter that needs one. I place that helper function in the cpp of my AudioProcessor, as it’s the only place where I use it. For example: