StreamingKit icon indicating copy to clipboard operation
StreamingKit copied to clipboard

Subtle "pop" in audio when using setGain

Open richardthornton opened this issue 9 years ago • 4 comments

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?

richardthornton avatar May 12 '15 11:05 richardthornton

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!

tumtumtum avatar May 20 '15 16:05 tumtumtum

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.

richardthornton avatar May 21 '15 00:05 richardthornton

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.

pavan6181 avatar Aug 05 '15 13:08 pavan6181

@richardthornton could you provide me your code example where I can do that ? thanks

kristoff2016 avatar Feb 13 '19 06:02 kristoff2016