English 中文(简体)
麦克OSX上C++的声音如何播放?
原标题:How do I play sounds with C++ on Mac OS X?

我正在更新二十年前写成的 C++ 程序, 以进行科学实验, 其中包括声音的精确启动和停止。 此程序还需要能够控制播放量、 暂停声音或启动在指定位置的播放、 循环听到指定次数, 以及控制频道映射 。

研究人员希望在现代的Mac OS X上运行程序,但我以前从未在Mac上做过任何发展。 实现上述目标的最简单方法是什么? C++在Mac上?

CoreAudio 似乎太复杂了。 NSSound 似乎具有我想要的所有特征,但据我所知,它只能在目标C中找到?能否将目标C与C++混合? 还是我应该使用SDK?

谢谢你的帮助

最佳回答

是的, 您可以混合目标- C 和 C++ 。 它是一种混合语言, 叫做 < a href=" http:// en. wikipedia. org/ wiki/ Objective- C#Objective- C.2B" rel = “ nofollow” > Objective- C/ a > 。 如果 > NSSound 具有你需要的所有特征, 可以选择它; 如果不是的话, CorAudio 是前进的道路。 建立和整合大型图书馆, 如 QuickTime、 OpenAL 或 FMOD, 将更具挑战性。

问题回答

是的, 您可以混合目标- C 和 C++ 。 目标- C 只是 C, 添加了一些东西, 而同样的东西也可以在 C++ 上层, 而不是在 C++ 上层, 以获得目标- C++ ( 特别是 目标- C++ 没有 C 在目标- C 中的 C 特性, 但不是 C++ ) 。

如果您需要非常低的潜伏时间, 直接使用 CoreAudio 可能有用 。

另一个选项可以是 OpenAL, 它只是另一个内置框架, OpenAL. framework。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签