Noob here, need help setting AudioParameterInt value with ParameterSlider


#1

I have a Slider::IncDecButtons slider which is supposed to hold values from -12 to 12 with step amount 1. I define it like this (this is to change the pitch of an oscillator by semitones):

addAndMakeVisible(OSC1_pitchSlider = new ParameterSlider(*owner.OSC1_pitchParam));
OSC1_pitchSlider->setSliderStyle(Slider::IncDecButtons);
OSC1_pitchSlider->setRange(-12.0, 12.0, 1.0);

The associated AudioParameterInt is defined like this:

addParameter(OSC1_pitchParam = new AudioParameterInt(“OSC1 Pitch”, “pitch”, -12, 12, 0));

But for some reason the GUI value doesn’t correctly map to the parameter value, e.g. if the GUI value is incremented from 0 to 1 in the GUI, then the parameter is set to 12.

How to fix this? The only (nasty) workaround I’ve found is to give the GUI element a smaller step value, eg 0.25 or something. Then at least the pitch changes by a semitone, sometimes (other times it changes by two semitones).