Audio drops while updating parameters binaural audio player


#1

I’m trying to build a binaural audio player but I’m having problems with the GUI, when I start move parameters I start hearing ‘clicks’ in the audio. I’m not sure why. I have a component and inside it I have an object that is derived from an AudioIODeviceCallback. I’m changing the parameters from the component with setters, and when I do that I start to hear clicks. All is built as a stand alone app. Please help. Here are parts of the code and here is the github repo if you are interested:

class MainContentComponent : public Component,
public ButtonListener,
public SliderListener
{
BinauralAudioPlayer audioPlayer;
};

void MainContentComponent::sliderValueChanged (Slider* sliderThatWasMoved)
{
if (sliderThatWasMoved == azimuthSlider)
audioPlayer.setAzimuth(azimuthSlider->getValue());
else if (sliderThatWasMoved == elevationSlider)
audioPlayer.setElevation(elevationSlider->getValue());

}

class BinauralAudioPlayer : public AudioIODeviceCallback
{

private:
int azimuth;
int elevation;

};

void BinauralAudioPlayer::audioDeviceIOCallback()
{
AudioSampleBuffer outputBuffer (outputChannelData, totalNumOutputChannels, numSamples);

AudioSourceChannelInfo info;
info.buffer = &outputBuffer;
info.startSample = 0;
info.numSamples = numSamples;
transportSource.getNextAudioBlock (info);

if (transportSource.isPlaying())
{
    hrir.update(azimuth, elevation);
    convolverLeft.setIR(hrir.leftEar.getWritePointer(0));
    convolverRight.setIR(hrir.rightEar.getWritePointer(0));
    
    convolverLeft.process(outputChannelData[0], convolutionResult, numSamples);
    
    for (int i = 0; i < numSamples; i++)
        outputChannelData[0][i] = convolutionResult[i];
    
    convolverRight.process(outputChannelData[1], convolutionResult, numSamples);
    
    for (int i = 0; i < numSamples; i++) {
        outputChannelData[1][i] = convolutionResult[i];           
    }
}

}


#2

Are the parameter values being smoothed? Clicks are a very common symptom of parameter values changing to quickly. Try the LinearSmoothedValue class in JUCE.


#3

Thanks a lot Fabian!!! I’m going to try this