如何生成不同频率的连续音调?
我想生成并播放具有随时间变化的特定频率和幅度的连续声音。我不想声音之间有延迟。我如何使用 Delphi 或 C++ Builder 来做到这一点?
I want to generate and play a continuous sound with specific frequencies and amplitudes that change over time. I don't want to have a delay between sounds. How can I do this with Delphi or C++ Builder?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这个非常简单的示例应该可以帮助您入门。
特别注意您获得的简洁界面:
This very simple example should get you started.
Notice in particular the neat interface you get:
通过使用 WaveAudio 库,可以生成连续的余弦波。
我本来想发布一些代码,但我不知道如何正确地做到这一点,所以我不会。
但您需要做的就是使用 TLiveAudioPlayer,然后覆盖 OnData 事件。
如果没有消息泵,请将 Async 设置为 true。
我会推荐 Delphi 的 ASIO 库!
https://sourceforge.net/projects/delphiasiovst/
使用这个非常简单,不是所有文件必须包含在内,从主要部分开始,然后从那里添加其余部分,另请参阅示例。
最终,它就像 OnSomeEvent/OnSomeBuffer 一样简单
,然后只需用浮点值填充数组即可。
不记得 OnEvent 的确切名称,但您可以在示例中轻松找到它。
另一件要做的事情是将某些组件设置为 active/true ,瞧。
ASIO 的优点是延迟非常低,甚至可以降低到 50 微秒甚至更低。
它确实需要您的声音芯片的 ASIO 驱动程序。
音频流输入输出
ASIO=音频工程师设计的
API!可能没有比这更好的了! ;)
By using WaveAudio library it's possible to generate a continous cosinus wave.
I was gonna post some code but I can't figure out how to do it properly so I won't.
But all you need to do is use TLiveAudioPlayer and then override the OnData event.
And also set Async to true if there is no message pump.
I would recommend ASIO library for Delphi !
https://sourceforge.net/projects/delphiasiovst/
Using this is super easy, not all files have to be included, start with the main one and add the rest from there, also see the examples.
Ultimately it's as easy as OnSomeEvent/OnSomeBuffer
and then simply filling an array with floating point values.
Don't remember the exact name of the OnEvent but you'll find it easily in the examples.
Another thing to do is set some component to active/true and voila.
The nice thing about ASIO is very low latency, it's even possible to get it down to 50 microseconds or even lower.
It does require an ASIO driver for your sound chip.
ASIO = audio stream input output
API designed by audio engineers !
It probably doesn't get any better than this ! ;)