Hi,
I have written a small plugin that includes mute buttons for the left and right channels. You can mute the left channel or the right channel, but not both at the same time.
I use AudioBuffer’s clear method to mute the audio.
//works, but sometimes generates tiny pops
if (leftChannel) {
buffer.clear (1, 0, buffer.getNumSamples());
} else if (rightChannel) {
buffer.clear (0, 0, buffer.getNumSamples());
}
When I mute a channel, sometimes there is a tiny pop in the audio. It is not big and I could live with it, but I want the muting to happen smoothly so that there is no pop, ever.
I have been looking at applyGainRamp, but I cannot make it work, and I don’t know if it is even the right move.
//fail, makes digital noise
if (leftChannel) {
buffer.applyGainRamp (1, 0, buffer.getNumSamples(), buffer.getMagnitude (1, 0, buffer.getNumSamples()), 0.0);
} else if (rightChannel) {
buffer.applyGainRamp (0, 0, buffer.getNumSamples(), buffer.getMagnitude (0, 0, buffer.getNumSamples()), 0.0);
}
Can you please put me on the right track?
Best regards,
Fred