在 OpenAL 中变换音高时发出咔嗒声
我正在使用 OpenAL 来改变音符的音高。例如,
alSourcef(source, AL_PITCH, aPitch);
当我执行此操作时,我注意到会听到咔哒声。除此之外,音调是完美的,音调正确等等。 有什么想法可能导致这种情况吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我没有使用过OpenAL,但在其他声音库中我见过这个“神器”。在处理音调发生器等时,通常有一个变量表示音调达到 100% 音量水平所需的时间,我可能一辈子都不记得它叫什么了:)
像这样:
其中 400 是 Hz ,40 dB 音量,3000 毫秒是持续时间,50 毫秒是从音量 0(或 +100dB)开始音调到达到 40 dB 所需的时间。我根本找不到现在这个词。
无论如何,如果您有能力设置此变量,请尝试这样做,只需将其设置为 10 毫秒之类的值即可。你将听不到它,但它为我消除了我用于 iPhone 的开源声音库和我过去使用的一些 Java/处理库中的点击声。
也许这与底层代码触发连接到扬声器的某些硬件的方式有关?
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:
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?
我在这方面有经验,主要是因为你将音调移得太高或太低,移动音调会拉伸或缩小波数据长度,情况是如果你的数据没有足够的样本来拉伸它听起来会“很奇怪” ”,在缩短长度(音高)的情况下,如果您的播放缓冲区没有足够的样本来及时输入,它将滞后或抖动,因为从概念上讲,播放速率会增加,以缩短音频的长度,主要是点击或你听到的是爆裂声。
为了防止这种情况,您应该限制变速范围,大多数声卡的限制大多为 0.5 到 2.0,并且不同声卡的变化范围不同,因为通过在 DSP 中使用一些高级平滑和处理可以更好地改变音调,所以进行此类处理将取决于您的 DSP 或 CPU 的处理能力。我已经尝试过使用板载intel HDA,限制主要是0.5到2.0,但是使用X-Fi声卡更好,转移到0.1 .. 5.0没有问题
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