My app plays a short beep whenever the user touches a tile. Sounds perfect. However, if the user drags their finger it will play the beep multiple times in quick succession, which works but also makes a crackling, static kind of noise. I'm trying to get rid of the crackle.
I've tried many things that have not worked:
Code:
public void setup() {
sp = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
sndBeep = sp.load(panel.act.getApplicationContext(), R.raw.beep, 1);
}
public void play() {
// sp.stop(sndPlaying); -- this actually makes the crackling noise worse
// sndPriority++; -- this had no effect
sndPlaying = sp.play(sndBeep, 1.0f, 1.0f, sndPriority, 0, sndFreq);
}
The noise happens because of the little pause between the last and the next beep. So, in fact you should decrement the priority on each call.
This should finish the last beep and start the new one only after that.
There's still a chance to get some noise. Simply if the sound contains - even a tiny - noise at beginning or end.