Slider change doesn't affect the volume of an AudioProcessor

Hello there.
I wrote a program that creates an AudioProcessorGraph, permitting to the user to add several audio tracks and to manage them through an UI.

Each time that a node is added to my AudioProcessorGraph, my program store the Node::Ptr of that specific node, in order to access it later for changing volume and other parameters stored inside that node.

I’m trying to manage the volume of the nodes: first, a node is instantiated and then the UI is set subsequently, by creating a lambda function which calls an onValueChange on the relative slider:

void MixerPluginProjectEditor::settingTheUI(juce::String itemText, int indexToAdd,
    juce::AudioProcessorGraph::Node::Ptr newNode)
    // ... ... ///
    auto nodeId = newNode->nodeID;

    sliders[indexToAdd]->setRange(-50.0, 0.0);
    sliders[indexToAdd]->onValueChange = [this, newNode, indexToAdd] {volumeChange(newNode, sliders[indexToAdd]); };

// ... ... //

The function volumeChange:

void MixerPluginProjectFinaleAudioProcessorEditor::volumeChange(juce::AudioProcessorGraph::Node::Ptr node, juce::Slider* slider)
    auto params = node->getProcessor()->getParameters();
    auto currentValue = slider->getValue();

The parameter params[0] represent the Volume argument contained in each node of my “mixer”:

class AudioChannel : public ProcessorBase
    AudioChannel(juce::File audioPath)
        addParameter(volume = new juce::AudioParameterFloat("volume", "Volume", juce::NormalisableRange<float> (-50.0f, 0.0f), -10.0f));
    //  ... ...  //
    void processBlock(juce::AudioSampleBuffer& buffer, juce::MidiBuffer&) override
        auto totalNumInputChannels = getTotalNumInputChannels();
        auto totalNumOutputChannels = getTotalNumOutputChannels();

        for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
            buffer.clear(i, 0, buffer.getNumSamples());

        juce::AudioSourceChannelInfo bufferToFill(buffer);

        float gain = juce::Decibels::decibelsToGain(volume->get());


    juce::AudioParameterFloat* volume;

However, when I set the volume through the onValueChange function, the Volume number changes from 0.0 to -50.0, and it remains stuck on -50, making the audio of the node completely silent!

I don’t understand where I’m wrong. Any suggestions? Thank you in advance

The function setValueNotifyingHost() takes a “normalized” value, from 0.0 to 1.0 (inclusive). You can use the range you just set to normalize it.

1 Like

Ouch, how foolish of me not to have known! After the setting the range between 0.0 and 1.0, everything works fine :slightly_smiling_face:

1 Like