November 9, 2007
-
Audio Units
I'm going to spend a moment explaining how I got something to work on my Mac. It's a little tech-heavy and jargon-laden, so please skip if you don't want to exercise those muscles.
Doing all this stuff arises out of solving a problem I didn't have initially. Don't you hate that? The problem I was trying to solve was how to minimally allow streaming audio conversations over the network, without using something like Skype. When I figure that part out, I'll be sure and let you know.

The problem: Use more than one USB audio input source to record using GarageBand (or to broadcast over Skype, or Second Life, or whatever). (GarageBand is Apple's audio recording and editing app, and it's pretty k-rad, especially since it comes with your Mac.)
The solution: AU Lab and Soundflower.
I have a USB headset (which is actually a mini-plugs headset with a USB adaptor, but who's counting), as well as a Griffin iMic. But really, this can apply to any audio on any Mac running OS X.
Step One: Install the Developer's Tools. For some reason, Apple decided to put all the really cool and useful stuff on the Developer's Tools disc. For instance Quartz Composer. But really, what we're interested in is a buggy piece of almost-ware called AU Lab. If you don't have a Developer's Tools disc, you can download one for free by signing up with Apple's Developer Connection. And you're the kind of nerd who already did this, aren't you? Yes, you are.
'AU' stands for Audio Units, which is Apple's low-latency audio architecture. It competes with other similar projects such as OSS, ALSA, and jackit, but is also compatible in some ways. So AU Lab is basically a demonstration of what you can do with AU. But it's also pretty darn useful, and is free.
So now that your Mac has the DevTools installed, you download and install Soundflower. Soundflower is a loopback device. All it does is take an input and make it available to an output. It can do this for two channels, or for 16 channels. We'll stick to the 2 channels, but I'm getting ahead of myself.
What's so useful about Soundflower is that it lets you set an output device for one app that can be the input device for another. So for instance, if you set GarageBand to have your microphone as an input, and Soundflower as an output, you can then apply effects to your voice for other applications, such as voice chat on Second Life or Skype. You'd set Soundflower as the input to the voice chat. See? No? Well forget about it then. Go read something else, because it's about to get a lot more complicated.
So let's say we want two inputs to go into Soundflower, for subsequent piping to some other app. Soundflower doesn't let you do this; it can only deal with one input. This is also a limitation of GarageBand; it can't mix inputs. So we need a mixer.
And that mixer will be AU Lab. AU Lab even adopts a mixer metaphor: It looks like a physical audio mixer like you'd find in a recording studio. But even then.... It only works per device. It was designed for demonstrating the technology, not to be perfect. I think Apple wanted to encourage someone else to make the real app.
So. This leaves us with the last piece of the puzzle: Aggregate Devices.
Apple's sound architecture allows you to group devices into aggregates. So for instance my Mac has a built-in sound system (two speakers, stereo line/optical in, mic on the lid, for a total of 5 channels). I also have an iMic (two in, two out), and the headset device (two out, one in). I could (and have...
) create a single aggregate device that includes all of these in and out channels. Or just some... Say I want to input from the iMic and the headset mic, I make an aggregate device with an output (soundflower, usually), and the two input devices.How do you make an aggregate device? With Audio MIDI Setup, of course!
It's located in /Applications/Utilities. When you run it, you'll see a menu item: Audio -> Open Aggregate Device Editor. A sheet pops down over the window. Click the + to add one, give it a name, and then start ticking off the devices you want to include.In this case, Soundflower, iMic input, and headset input.
It should also be noted that you have to do this for all devices on an Intel Mac. Apparently the hardware is ahead of the software in this regard. On Intel Macs, for instance, the Built-In Output is not automatically associated with the Built-In Input. Crazy, yes, but there you go. You must make an aggregate of the two if you want them to act as one.
So you've aggregated your devices, and given that aggregate a good name (I chose 'soundflower imic headset'). Now you run AU Lab and prepare for another learning curve.
Because AU Lab kinda sucks. It inspires me to write a better version, which of course I'll never do. Anyway.
You run it, and it asks you for an output device. Choose the aggregate device you just created and click OK.
Now you'll see a master output channel, complete with panning and fader and mute button. Just like a real mixer. w00t. This represents your output device, whatever it may be. In our case, whatever gets fed to this output will be going out to Soundflower (and subsequently to whatever other app we choose). It could also be going out to your speakers or headphones or whatever, depending on how the aggregate device is set up.
So let's add some inputs. We do this from the Edit menu: Edit -> Add Audio Input. We see a similar dialog box to the previous one. But this one's a little more tricky. In my case, it shows five inputs available (the rectangles in the middle of the box). The first two inputs are provided by Soundflower, and in this case they're labeled as such. We don't want inputs from Soundflower; we want the other three. But channel #3 is mono, and #4 and #5 are stereo. This is a problem because the user interface sucks. I will leave it as an exercise to discover why this is, and offer only the solution: Put the popup in Mono, and delete everything, then add everything, and then switch mono to stereo in the places you want it, and delete the channels you don't want. These directions will make sense if you try it.

Then save the document, because you don't want to have to go through that again, do you?
So. Conceptually, here's what we've got:
iMic + headset + Soundflower => Aggregate
Aggregate => AU Lab for mixing => Aggregate
Now run GarageBand, set its input to the aggregate device, and hit record. Which adds:
Aggregate => GarageBand
Wasn't that easy?
For further conceptual overload: AU Lab also gives you access to a jillion other Audio Units-based effects and transports. Which means that, for instance, if you have two Macs on a network that both run AU Lab, you can connect the two and stream audio between them for whatever purpose you have in mind, nefarious or otherwise. AU Lab lets you group inputs into busses with their own mixes and effects sends (pre and post), and on and on. It's a very cool technology, and it's a shame that there aren't more routing/mixing apps available than just AU Lab.
Comments (3)
my head asplode!
boom.
a garage-bandy, soundflowery, quintaphonic boom no less!
Comments are closed.