So, for the final project in a coding class I made a synth using the Maximilian add-on. It works great but half the time I launch it there’s an awful pop. I don’t no how to get rid of it and always just mute my computer when it’s launching. any ideas?
yes that’s pretty much it but with j starting at 0, doing it in the audio callback and declaring j in the .h so you can keep increasing it until it reaches 1. also don’t forget to clamp j between 0 and 1
depending on the increment of j the ramp up will be slower or faster usually 100ms is more than enough
then in the audio callback function, which probably is void ofApp::audioOut(ofSoundBuffer & buffer)
put the following at the end of the function, after you’ve done any processing of the audio signal
size_t nChans =buffer.getNumChannels();
if(bNeedsVolumeRamp){
for (size_t i = 0; i < buffer.getNumFrames(); i++){
for(size_t j = 0; j < nChans; j++){
buffer[i*nChans + j] *= volumeRamp;
}
volumeRamp += 0.01; // adjust this value to change how much time it takes to make the ramp.
if(volumeRamp > 1.0f){
volumeRamp = 1.0f;
}
}
if(ofIsFloatEqual(volumeRamp,1.0f)){
bNeedsVolumeRamp = false;
}
}
I’ve had a lot of success and fixing audio popping issues by using a ofScopedLock() in the whole ofApp::AudioOut when dealing with dynamic variables that drive audio parameters, specially using Maximillian. You might want to implement that as well!
well that’s something you need to do if you are going to use dynamic variables that are being modified elsewhere as the audio callbacks are running in a different thread. It is also relevant to the popping audio the way in which the dynamic variables change; if these have abrupt changes it might become into a kind of pop, but that depends on what you are doing with these. In order to avoid such abrupt changes you can use some kind of smoothing.