StreamingKit
StreamingKit copied to clipboard
Subtle "pop" in audio when using setGain
Thanks for this amazing library @tumtumtum! :smile: We are using a number of equalizer bands (10 at the moment) being changed using a NSTimer at 0.1 seconds to create a cross-fade between two players. This means during a 5-second crossfade quite a few setGain adjustments are made.
In the Xcode simulator I can hear a very faint but still audible "pop" occurring on each and every setGain call. Is this something you have experienced and do you have a suggestion for getting around the issue?
Thanks ☺️
That's odd. Are you getting this on devices? Could you try decreasing the NSTimer interval so that you're reducing the gain by a smaller amount each time?
Cheers!
Hey @tumtumtum! I've been meaning to come back to you on this. Yes, this is happening on every device. I tried reducing the NSTimer and the sound was even more pronounced as it was happening more often. See my edit below for a recording. We were able to solve the problem though I can't explain why... We changed kAudioUnitScope_Global on line 2194 of STKAudioPlayer.m from:
CHECK_STATUS_AND_RETURN(AudioUnitSetParameter(eqUnit, kAUNBandEQParam_Gain + bandIndex, kAudioUnitScope_Global, 0, gain, 0));
To:
CHECK_STATUS_AND_RETURN(AudioUnitSetParameter(eqUnit, kAUNBandEQParam_Gain + bandIndex, kAudioUnitScope_GlobalGlobal, 0, gain, 0));
As I said, I don't yet know why this worked. Our app is however working beautifully now. ;)
EDIT: Here's a recording. If you listen closely to the fade out and in you'll hear the repeating click every 0.1 second.
Hey @tumtumtum! i'm getting similar issue in my app, however changing "kAUNBandEQParam_Gain" to "kAUNBandEQParam_GlobalGain" is not giving any pop sound , but that doesn't apply different gain values for different bands.
@richardthornton could you provide me your code example where I can do that ? thanks