Cocoa audio recording support (or lack thereof)

February 2nd, 2006

There have been a lot of things happening lately, both at Polarian and otherwise.

First of all I have been working heavily on getting sound support into Screen Mimic for the 2.0 release. EVERYONE that has sent me feedback has said something akin to:

“This software is great…but can it record sound?”

or from the glass is half-empty people:

“This software stinks, it can’t record sound.”

I have looked at lots of options for this and I have to say Cocoa is rather lacking in the sound recording department unless you are working in Quicktime. For playing sounds, NSSound is great:

NSSound *mySound = [NSSound soundNamed:@"someCoolSound"];
[mySound play];

Cocoa will play the sound on a separate thread and send a notification to the delegate when it has finished playing. Nice. Clean. Very Cocoaesque. It sure would be nice if you could do something similar to record like:

[NSSound recordFromDefaultInput];

…(then in the delegate)

-(void)didFinishRecording:(NSSound *)recordedSound
{
[[recordedSound data] writeToFile:@”mySound.aiff” atomically:YES];
}

but alas, no.

Currently, the choices are:

  • Use Carbon
  • Use CoreAudio
  • Use a 3rd party framework like MTCoreAudio (which is a cocoa wrapper around CoreAudio)

Now each of these methods have their pros and cons (and I have explored each pretty thoroughly for Screen Mimic, and the point of this post isn’t to compare those (I have no where near the audio coding experience to do that fairly). The point is I guess, to gripe about the lack of native audio recording support in Cocoa.

One Response to “Cocoa audio recording support (or lack thereof)”

  1. At

    No idea how good this is, and it hasn’t been updated in about 2 years, but this guy made a Cocoa wrapper framework for CoreAudio here: MTCoreAudio. It’s free and you can modify the source, so it’s maybe a good base to start from.

Leave a Reply