The Red Penguin

Add stop, start and volume functionality


Thursday 30 July 2020

We've already created these buttons and sliders but here we're going to make them a bit more useful.

1. Go to MainComponent::buttonClicked in MainComponent.cpp - this is the button event listener.

We're going to take transportSource.start(); out of the loadURL function and paste it in here.

2. In the if statement for the stopButton we can add transportSource.stop();

If we now build and compile we can load up an audio file and use PLAY and STOP to start and stop the audio.

3. We can now go into the slider listener. We had previously turned this into a frequency control! So we can remove the comment and the dphase = volSlider.getValue() * 0.001; in there and add this instead:

transportSource.setGain(slider->getValue());

The slider was previously set between 0 and 10 but we want this volume to be between 0 and 1.

We configure the GUI in the constructor so we need to go back to MainComponent::MainComponent() and underneath volSlider.addListener(this); we can add

volSlider.setRange(0.0, 1.0);

And that's how you activate these buttons!