I have a stereo sound for Inter aural time difference consisting of sine wave(16 samples as 16 bit PCM Data) for left and right audio. From time to time I would like to advance either the left or right audio so that sound in one ear comes earlier than the other. If I just put another sine wave of different frequency in between my normal sine samples to give an illusion of changing sound in one ear, I hear a click. I am playing a buffer of 1024 samples at a time containing looped sine wave samples. If I drop one sample it generates a click as well. Can someone suggest a way of speeding up the Sine wave without generating a click. e.g loop the sine wave separately for both ears. Now advance the sine wave in one ear so that it feels like a frequency change and then play the normal sound again in both ears. I have fixed sine samples with me. (I work in java so can't do any heavy computations). I have tried to clarify but the question could still be confusing. Ask for specific details.



1 Answer 1


I understand the point.
If you are outputting signal[i] you cant jump to signal[i+n] instantaneously. You should just fade it to the new point with some window function. Allow some period of fading time.

For example: If I currently output signal[i] and I want to shift it to signal[i+n] in 1 second. I will use half of Hann window to fade it in and out. So I time scaling Hann from pi to 1 second. and output $signal[i+n]*Hann[i]+signal[i]*(1-Hann[i])$ for 1 second before I switch to signal[i+n] at full scale. This should not generate a click.

You may want to try other window function or different fading period.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.