|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
Need help with clicking sound.I have just started to use openal for sound synthesis and I guess that is what it is made for. 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. Cheers, Alfred ==Code== // Buffers hold sound data. ALuint Buffers[2]; // Sources are points of emitting sound. ALuint Sources; ALuint Buffersize=50000; ALint iState; char data[Buffersize]; char data2[Buffersize]; // Initialize OpenAL and clear the error bit. alutInit(NULL, 0); alGetError(); //Generating buffers. alGenBuffers(2, Buffers); //'NUM_BUFFERS' is number of buffers that will be generated. //'Buffers' is pointer to an array of ALuint values that will store the names of new buufers. double pi = 3.141592654; double freq=1800; // frequency double sfreq=2000; // sampling frequency int z; for (z=0;z<Buffersize;z++) data[z]=50*sin(2*pi*z*freq/sfreq); for (z=0;z<Buffersize;z++) data2[z]=50*sin(2*pi*freq*(Buffersize+z))/sfreq; if (alGetError() != AL_NO_ERROR) return AL_FALSE; // Load wav data into buffers. alBufferData(Buffers[0],AL_FORMAT_MONO8,data,sizeof(data),sfreq); alBufferData(Buffers[1],AL_FORMAT_MONO8,data2,sizeof(data2),sfreq); // Generate a source. alGenSources(1, &Sources); //Bind buffer to the source. alSourceQueueBuffers(Sources,2,Buffers); if (alGetError()!=AL_NO_ERROR) return AL_FALSE; alSourceUnqueueBuffers(Sources,2,Buffers); alSourcePlay(Sources); alSourcei(Sources,AL_LOOPING,AL_TRUE); sleep(10); Share your photos with Windows Live Photos – Free. Try it Now! _______________________________________________ Openal-devel mailing list Openal-devel@... http://opensource.creative.com/mailman/listinfo/openal-devel |
|
|
Re: Need help with clicking sound.Dear All, 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. 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 |
|
|
RE: Need help with clicking sound.
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. I agree this is the cause of clicking. 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. This means that every time I change the frequency of the waveform I'll have to change buffersize, which is not less than a pain in the neck as complex sounds will be just different frequency waves overlaid on each other. I personally think that it can be solved by using two buffers, as I have done. When one buffer ends the other start playing from the point where previous ended. For now, I have no idea what so ever how I will do this. Any suggestions!!! 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). Yes it is a good way of generating a waveform but I am not sure it will deal with low or high pass filters. Also I have tried this... The buffer doesn't automatically stops when the content in it is finished it stops after the duartion which is specified in the function. Thats what I think. Above all this also produces the same clicking problem. If you are interested I can send you the code. Thank you in advance for the help. Cheers. A Date: Mon, 9 Mar 2009 20:13:16 -0400 From: jdaly@... To: hkgi@... CC: openal-devel@... Subject: Re: [Openal-devel] Need help with clicking sound. Alfred Hawk wrote: Dear All, 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. 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" Share your photos with Windows Live Photos – Free. Try it Now! _______________________________________________ Openal-devel mailing list Openal-devel@... http://opensource.creative.com/mailman/listinfo/openal-devel |
|
|
Re: Need help with clicking sound.Alfred Hawk wrote:
> // > This means that every time I change the frequency of the waveform I'll > have to change buffersize, which is not less than a pain in the neck > as complex sounds will be just different frequency waves overlaid on > each other. Well, as I said, OpenAL isn't really meant for what you're trying to do. I'm not familiar with the range of audio synthesis tools that are available, or I'd probably recommend one. You'll probably have fewer headaches that way. > I personally think that it can be solved by using two buffers, as I > have done. When one buffer ends the other start playing from the point > where previous ended. For now, I have no idea what so ever how I will > do this. Any suggestions!!! That's certainly true, but you'll have to make sure that the amplitude (sample value) at the end of the first buffer matches the start of the second buffer, or you'll always have clicks. > > Yes it is a good way of generating a waveform but I am not sure it > will deal with low or high pass filters. There's also alutLoadMemoryWaveform, which simply creates an array of samples containing the desired waveform. You should be able to use that with any filters you like, then pass the results to alBufferData(). > Also I have tried this... The buffer doesn't automatically stops when > the content in it is finished it stops after the duartion which is > specified in the function. I'm not sure what you mean. The duration you give the function specifies the content of the generated buffer, so yes, it will stop after the specified duration. --"J" _______________________________________________ Openal-devel mailing list Openal-devel@... http://opensource.creative.com/mailman/listinfo/openal-devel |
|
|
RE: Need help with clicking sound.Well somehow I have managed to get rid of the clicking. For each different buffer filled, I played using seperate sources. Now this works fine if I run on Opensuse in a PC whereas it fails i.e. produces clicking, if I run the code in my Notebook with Vista and Ubuntu, dual boot. Can anyone explain why this is so? n.b I am using Linux. Cheers, A > Date: Mon, 9 Mar 2009 23:27:50 -0400 > From: jdaly@... > To: hkgi@... > CC: openal-devel@... > Subject: Re: [Openal-devel] Need help with clicking sound. > > Alfred Hawk wrote: > > // > > This means that every time I change the frequency of the waveform I'll > > have to change buffersize, which is not less than a pain in the neck > > as complex sounds will be just different frequency waves overlaid on > > each other. > > Well, as I said, OpenAL isn't really meant for what you're trying to > do. I'm not familiar with the range of audio synthesis tools that are > available, or I'd probably recommend one. You'll probably have fewer > headaches that way. > > > > I personally think that it can be solved by using two buffers, as I > > have done. When one buffer ends the other start playing from the point > > where previous ended. For now, I have no idea what so ever how I will > > do this. Any suggestions!!! > > That's certainly true, but you'll have to make sure that the amplitude > (sample value) at the end of the first buffer matches the start of the > second buffer, or you'll always have clicks. > > > > > Yes it is a good way of generating a waveform but I am not sure it > > will deal with low or high pass filters. > > There's also alutLoadMemoryWaveform, which simply creates an array of > samples containing the desired waveform. You should be able to use that > with any filters you like, then pass the results to alBufferData(). > > > > Also I have tried this... The buffer doesn't automatically stops when > > the content in it is finished it stops after the duartion which is > > specified in the function. > > I'm not sure what you mean. The duration you give the function > specifies the content of the generated buffer, so yes, it will stop > after the specified duration. > > --"J" Windows Live Messenger just got better. Find out more! _______________________________________________ Openal-devel mailing list Openal-devel@... http://opensource.creative.com/mailman/listinfo/openal-devel |
|
|
Re: Need help with clicking sound.Hi, Hard to say for sure. In general, you'll find that different audio hardware will react differently to certain inputs (especially non-continuous adjacent samples). By the way, I did a quick Google for "linux audio synthesis" and came up with CSound ( http://www.sourceforge.net/projects/csound ). I think it might suit your purposes better than OpenAL. You can also look here for a few alternatives: http://en.wikipedia.org/wiki/Comparison_of_audio_synthesis_environments --"J" _______________________________________________ Openal-devel mailing list Openal-devel@... http://opensource.creative.com/mailman/listinfo/openal-devel |
| Free embeddable forum powered by Nabble | Forum Help |