如何制作和播放程序生成的线性调频声音
我的目标是创建一个“Chirper”课程。鸣叫器应该能够发出按程序生成的鸣叫声。具体想法是,鸣叫声必须按程序生成,而不是回放预先录制的声音。
在 iPhone 上实现程序生成的鸣叫声的最简单方法是什么?
My goal is to create a "Chirper" class. A chirper should be able to emit a procedurally generated chirp sound. The specific idea is that the chirp must be procedurally generated, not a prerecorded sound played back.
What is the simplest way to achieve a procedurally generated chirp sound on the iPhone?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如您所说,您可以使用正弦波来做到这一点,您可以使用 sin 函数来定义它。只要您想要样本中的声音,就创建一个缓冲区,例如:
然后选择一个起始频率和结束频率,您可能希望起始频率高于结束频率,例如:
无论如何,类似的东西。
如果您想要嗡嗡声或其他声音,请使用不同的波形 - 创建它们以与 sin 非常相似的方式工作,并且您可以互换使用它们。这样你就可以创建 saw() sqr() tri(),并且你可以做一些事情,比如将它们组合起来形成更复杂或更多样化的声音
==================== ====
编辑 -
如果你想玩,你应该能够使用 OpenAL 做一些类似的事情。重要的是使用 OpenAL 或类似的 iOS API 来播放原始缓冲区。
You can do it with a sine wave as you said, which you would define using the sin functions. Create a buffer as long as you want the sound in samples, such as:
Then pick a start frequency and end frequency, which you probably want the start to be higher than the end, something like:
Something like that, anyway.
And if you want a buzz or another sound, use different waveforms - create them to work very similarly to sin and you can use them interchangably. That way you could create saw() sqr() tri(), and you could do things like combine them to form more complex or varied sounds
========================
Edit -
If you want to play you should be able to do something along these lines using OpenAL. The important thing is to use OpenAL or a similar iOS API to play the raw buffer.
您可以在远程 I 的渲染回调中使用 Nektarios 的代码/O 单位。您甚至可以实时更改波形(低延迟)。
You can use Nektarios's code in the render callback for remote I/O unit. Also you can even change waveforms real-time (low latency).