views:

862

answers:

3

I have a conundrum:

I need to find a way to capture the raw audio data that is being piped to the Built-in Output on Mac OS X. Core Audio, HAL, etc.

I can "listen" in on the Built-in Output and the mic, but neither of these appear to offer the correct data stream - the exact stream (all combined data from all input sources) that goes to the speakers/built-in output.

Any advice is welcomed with appreciation.

A: 

Do you need to access to that stream from your program, or do you just want to rip audio from it? In the second case, a quick Google search turned up http://www.ambrosiasw.com/utilities/wiretap/ and http://www.rogueamoeba.com/audiohijackpro/. None of those are open-source or free though.

Edit -- whoops, you want to access to programmatically, that answers my own question, sorry. I think I'll keep my answer here in case some folks stumbles upon this page wanting to record audio non-programmatically.

Etienne Perot
Wiretap is like what I need to implement - it captures the outgoing stream. I just need some deep insight as to how an application such as wiretap interfaces with either Core Audio and/or the HAL.
Demi
A: 

You need will need your app to install a system extension. Soundflower is an open-source implementation of such an extension.

weichsel
explain further, please. I have seen Soundflower and understand it to be a bridge between differing audio devices. I do not understand how this applies to this particular scenario...
Demi
if I understand you correctly, you want to record mixed system audio.With soundflower you could do exactly that. As far as I remember that's how system audio recording works in Rogue Amoebas Audio Hijack Pro. If you select "System Audio" as input source, it asks you if the soundflower system extension should be installed. Of course wo need code that does the actual recording. (As we answered to your SO question here: http://stackoverflow.com/questions/871819/code-sample-for-capturing-audio-from-a-mac-in-cocoa-and-saving-to-file/874855#874855 )
weichsel
Here's the thing that bugs me, though. If SoundFlower is installed, it requires a restart. However, when one uses an application such as WireTap, it requires no additional installs - you copy it to the Applications directory and can just run it. What I need to know is the "magic" that permits such an application to get the mixed system audio without additional installations.
Demi
A: 

maybe you should have a look at the Jack source code...

http://sourceforge.net/projects/jackosx

kent