tags:

views:

297

answers:

3

I am using OpenAL to pitch shift a note. e.g.

alSourcef(source, AL_PITCH, aPitch);

I am noticing however an audible click when I do this. Other than that the pitch is perfect, correct pitch etc. Any ideas what might be causing this?

A: 

Hi

I haven't used OpenAL, but in other sound libraries I have seen this "artifact". There is usually, when dealing with tone generator etc. a variable for the time it takes a tone to reach 100% volume level, I can for the life of me not remember what it is called :)

like this:

playTone(400 Hz, 40 dB, 50 ms, 3000 ms).

where 400 is the Hz, 40 dB the volume, 3000 milliseconds is the duration and 50 milliseconds is the time it takes from starting the tone at volume 0 (or +100dB) to it reaches 40 dB. I simply can't find the word right now.

Anyways, if you have the ability to set this variable, try doing that, just set it to something like 10 ms. You wont be able to hear it, but it has removed clicking sounds for me in both an open source sound library I used for the iPhone and in some Java/Processing libraries I used in the past.

Maybe it has to do with the way the underlying code is triggering some hardware connected to the speaker?

RickiG
I'll have a dig around in OpenAL (I am new to it so not fully up to speed).
Ian1971
A: 

i have experience on this one, mostly it is because you shift the pitch too high or too low, shifting pitch is stretching or shrinking wave-data length, the case is if your data does not have enough sample to stretch it will sound "weird", in case of shortening the length (pitch-up) if your playback buffer does not have enough sample to feed in time, it will lag or jitter because conceptually the playing rate is increased to due shortened the length of audio, mostly clicking or popping is what you heard.

to prevent this, you should limit the shifting range, mostly 0.5 to 2.0 is the limit on most sound-card, and it is vary across soundcard, since shifting the pitch could be make better by using some advanced smoothing and processing in DSP, so it will depend on processing power of your DSP or CPU to do such processing. i've tried it using onboard intel HDA that the limit is mostly 0.5 to 2.0, but using X-Fi soundcard it is better, shifting to 0.1 .. 5.0 doesn't have a problem

uray
Thanks for this info. My pitch shift is within that range (normally 1 or 2 semitones). I am doing this on the iPhone so not sure what the limits of the sound hardware is. Maybe I should try playing around with buffer size? (I am an OpenAL novice)
Ian1971
A: 

Can anyone tell me why the volume in openal becomes lower and lower if I change the pitch higher and higher? Thanks in advance.

alSourcef(source, AL_PITCH, 1.2f); alSourcef(source, AL_GAIN, 1.0f);

with this setting, the volume is still very very low. is there a way to cheat it to make the gain above 1?

Xiu