Handling sliders using the sliderValueChanged() method!


In an earlier project of mine I had some sliders in my GUI addressing a parameter from some other class of mine (Actually Jules OpenGlDemo class from the JuceDemo) which I invoked using the changeListenerCallback method - this worked fine using the following code:

void DemoEditorComponent::changeListenerCallback (void* source) { if (source == getFilter()) { updateParametersFromFilter(); } else if (source == gainSlider) { getFilter()->setParameterNotifyingHost (0, (float) gainSlider->getValue()); } else if (source == zoomSlider) { gl->canvas->zoomFactor = (float) zoomSlider->getValue(); <-my class }

Now I’m working on another project using the JuceAudioPlugin v1.13 which seems to use the sliderValueChanged(Slider*) method. My problem is that I can’t seem to change a parameter living in my own class (the project compiles but changing the slider doesn’t change the zoomFactor parameter) . I use the following code:

[code]void DemoEditorComponent::changeListenerCallback (void* source)
// this is the filter telling us that it’s changed, so we’ll update our
// display of the time, midi message, etc.
if (source == getFilter())
elseif (source == zoomSlider)
gl->canvas->zoomFactor = (float)zoomSlider->getValue();

void DemoEditorComponent::sliderValueChanged(Slider*)
getFilter()->setParameterNotifyingHost (0, (float) gainSlider->getValue());
getFilter()->setParameterNotifyingHost (1, (float) zoomSlider->getValue());

Does that mean that I cannot address parameters living in other classes than the getFilter() or is my code wrong?

Sorry if the question is trivial!

Your code just looks a bit muddled to me… The change listener callback is no longer ever called by sliders, so why the code in there that checks whether the source is the slider?

I think you want to do something like this:

void DemoEditorComponent::sliderValueChanged(Slider* caller)
if(caller == zoomSlider){
gl->canvas->zoomFactor = (float)zoomSlider->getValue();
getFilter()->setParameterNotifyingHost (1, (float)zoomSlider->getValue());


Yahoooooo thanks - that helped :slight_smile: :slight_smile: :slight_smile: :slight_smile: