Trying to control the gain/volume of audio being played in my audio app using a slider
Using
AudioTransportSource transport;
transport.setGain(gainSlider.getValue)
but struggling with the exact syntax?
Ideas welcome
Trying to control the gain/volume of audio being played in my audio app using a slider
Using
AudioTransportSource transport;
transport.setGain(gainSlider.getValue)
but struggling with the exact syntax?
Ideas welcome
No offense but: Search a non-JUCE related C++ tutorial to learn the most basic C++ language syntax would be my first idea – otherwise you won’t get much further than just copy & pasting code. In January 2020 you asked what to learn in order to really understand JUCE – and I’d still give you the same reply as I did back then.
But regarding your specific question: transport.setGain(gainSlider.getValue)
won’t work since getValue
is a function – and to call a function with no arguments you need to add a pair of empty parentheses, so that it reads transport.setGain(gainSlider.getValue())
.
Besides the syntax issues you should also make sure where the setGain
call is placed. It needs to be called again on each slider value change. So a good place would be to put it into the onValueChanged
callback of your slider, e.g. somewhere where you create the slider instance put this line:
gainSlider.onValueChanged = [this] () { transport.setGain (gainSlider.getValue()); };