Q: Our Cocoa based application currently uses NSMovie to play sounds throughout. This includes status sounds, alert sounds and so on. We would like to know if NSSound is a better choice for Mac OS X 10.3 on as our NSMovie implementation sometimes, but not always, suffers from gliches and dropouts. A: Yes!
While NSSound supports any audio encodings and file formats that QuickTime does (as it still uses QuickTime for certain things), as of Mac OS X 10.3 NSSound can also use CoreAudio for playback giving you a more flexible class to work with.
File support is interesting; it breaks down as follows. The NSSound initializer first tries to use CoreAudio with the file it is initialized with. If that fails, NSSound tries to use QuickTime. If that fails, NSSound initialization will fail.
There is currently no way to tell (with the NSSound APIs) whether a particular NSSound object is using CoreAudio or QuickTime as its engine.
NSSound will use CoreAudio for any files supported by the CoreAudio AudioFile APIs as long as the file type is supported in <AudioToolbox/AudioFile.h > and the encoding format has codec support (with the exeption of Linear PCM which is always supported).
Given the above information, NSSound will use the CoreAudio implementation to play AIFF, WAVE, NeXT, SD2, AU, and MP3 files leaving QuickTime to play everything else. This list applies to Mac OS X 10.3 and may expand in the future.
Additionally if your NSSound object is indeed using CoreAudio, you will not only get virtually glitch-proof (see note) audio but also significant performance improvements over the QuickTime implementation because the CoreAudio implementation is much lighter weight.
Note: With the CoreAudio implementation, all sound data is loaded in when the sound is initialized, and all audio conversions and hand-offs (to the AudioDevice) are done in a real-time thread, so unless you are working with a very large sound file that needs to be paged in, your non-realtime threads should be able to consume arbitrary processor time without affecting your audio playback at all.
|
References:
[Feb 04, 2004]
|