« Return to Thread: Need help with clicking sound.

Re: Need help with clicking sound.

by Jason Daly :: Rate this Message:

Reply to Author | View in Thread

Some parts of this message have been removed. Learn more about Nabble's security policy.
Alfred Hawk wrote:
Dear All,
 
I have just started to use openal for sound synthesis and I guess that is what it is made for.

Actually, OpenAL is not intended for sound synthesis applications.  It's primarily intended to create 3D audio soundscapes for games and simulations.  You can probably do rudimentary sound synthesis with it, but it won't make it easy for you.


I have made a simple program using two buffers, in which a sine wave is generated, in other words a single frequency sound. Now if I change the frequency I hear a clicking sound that is due to the fact when the second buffer is played, it starts playing the waveform from the beginning. I have tried using a single buffer and AL_LOOP function but of no vain. Please see the code below. Is there any way or function in openal that can remove this clicking sound. I have tried changing Sampling frequency but of no vain.
I am not sure whether it makes any sense or I am going in right direction but I need to remove this clicking sound in order to proceed with sound synthesis.

The click is probably coming from the fact that your sine wave is not coming back to zero (or 128, in this case) at the end of your buffer.  In this case, when you switch buffers (or loop the single buffer), you start the sine wave back at zero.  This jump in amplitude produces the click you're hearing.

To fix this, you have to ensure the buffer length is proportional to the frequency of the sine wave, so the amplitude goes back to zero at the end of each buffer.


By the way, instead of hand-coding the sine wave yourself, you can make use of ALUT, which has a method to create waveforms (sine, square, sawtooth, white noise, and impulse).

The call looks something like this:

buffer = alutCreateBufferWaveform(ALUT_WAVEFORM_SINE, frequency, phase, duration);

Best of all, the duration will be automatically rounded up to avoid clicks.  See the ALUT spec at http://tinyurl.com/azzl69 for more details.

--"J"


_______________________________________________
Openal-devel mailing list
Openal-devel@...
http://opensource.creative.com/mailman/listinfo/openal-devel

 « Return to Thread: Need help with clicking sound.