在 Unix 上输出自制合成声音的简单方法是什么?

发布于 2024-08-19 12:24:33 字数 159 浏览 3 评论 0原文

我想使用 ANSI C 在 Mac OS X(最好是其他类 Unix 操作系统)上进行一些声音合成。

这是出于学习目的,而不是“我需要一个解决方案,任何解决方案,快点!”

假设我的 C 程序中有一个 8 位缓冲区,每秒更新 22050 次。如何让我的扬声器将其输出为波形?

I want to do some sound synthesis on Mac OS X (and ideally other Unix-like OS) using ANSI C.

This is for learning purposes rather than "I need a solution, any solution, quick!"

Say I have an 8-bit buffer in my C program that I update 22050 times a second. How can I get my speakers to output that as a waveform?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

埋情葬爱 2024-08-26 12:24:33

SDL 可以播放声音缓冲区。但是PortAudio可能工作得更好,PA会在需要更多数据时调用你的C回调,然后你可以将下一个缓冲区交给它。实际上这相当容易。

SDL can play sound buffers. But PortAudio may work better PA will call your C callback when it needs more data, and then you can hand it the next buffer. It's fairly easy actually.

内心激荡 2024-08-26 12:24:33

没有 POSIX 音频 API 或类似的东西。因此,如果您想要在 Linux、OSX 等上支持声音,您需要一个包含不同操作系统的本机声音 API 的库。看看这个SO问题。它不是直接询问 OSX,但大多数答案也应该适用于它,除了 libao。至少我在他们的主页上没有找到任何表明他们支持 OSX 的内容。

There is no POSIX audio API or something similar. So if you want sound support on Linux, OSX, etc. you need a library that wraps around the native sound APIs of the different OSs. Take a look on this SO question. It's not asking directly for OSX, but most of the answers should also work for it, except maybe libao. At least I haven't found anything on their homepage, that says they support OSX.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文