Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在寻找一种在我的 c 程序中播放 .wav 文件的简单方法。我已经用谷歌搜索了这样做的方法,但大多数答案都来自 Windows 的 PlaySound(),而且我正在运行 mac。任何答案表示赞赏。谢谢。
您可以afplay在 Mac 上使用终端命令播放声音文件,例如wav或mp3. 由于您可以在 C 中使用 运行命令system(),因此您可以简单地使用以下代码:
afplay
wav
mp3
system()
int main() { system("afplay sound.wav"); // ... return 0; }