Mapping audio topologies to mixer topologies

Yesterday, I described the internal topology of an audio card.

But there's no Windows API to expose that topology directly (you can generate the topology using the KS IOCTLs (KS stands for Kernel Streaming) but the reality is that it's not an API for mortals - a quick browse through the API makes that quite clear.

Instead, the internal topology of the audio card is exposed via the MME mixer API set.

But the mixer APIs only provide a rough approximation of the functionality in the topology.  A lot of this is because of the architecture of the mixer APIs.

Instead of viewing the internal topology of the audio card as a graph, the mixer APIs represent the internal audio topology as an audio mixer.

Consider this mixer:

On the left hand side, there are 8 input channels (or source lines).  On the right hand side, there's a single output channel (or destination line).

On each of the channels, there are a series of controls - mute, treble, bass, volume, etc - in the pictured mixer (a Mackie 1202VLZPRO), the volume for each of the input channels is the silver knob at the bottom, there's a gray button above it which is the mute.  On the output, there's a meter (that's the two rows of LEDs and a bunch of volume controls (and some more controls that I can't recognise).

Well, the mixer APIs take the audio adapter's topology and attempt to turn that graph into something that looks like the mixer above.

Here's the picture of the topology of my test machine's AC97 adapter again, for reference.

Here's a snapshot of another tool written by the same developer:

You can see the wave pin (pin 9), the CD Player (pin 6) etc here.

The mixer API's really only concerned with the topology filter - the wave filter isn't very interesting as far as the mixer's concerned (the mixer does look at the wave filter, but not deeply).  The mixer API takes the 10 pins on the left hand side and calls them "sources"  And it takes the 3 pins on the right and calls them "destinations".  It then walks the connections from the source to the destination pins and takes every control that's on the path and adds it to the source line.

But it turns out that that isn't quite right.  Consider  what happens when the code walking the source lines hits the mixer control #18.  Every source line generated would have the master volume and mute controls.

So there's a special case - controls to the right of a mixer (or mux) control get assigned to the destination, controls to the left get assigned to the individual source lines.  In the case of the mux control, the mux control is added to the destination (which makes sense).  Mixers don't get added to the destination because they don't have any controls.

One other thing to notice is what happens to mux controls (essentially switches) like #27 and 30.  For instance, the mux control #27 is connected to most of the input sources - if it's set incorrectly however, then you can't capture off of that input source.

It turns out that mux's are one of the common problem areas in audio trouble shooting.  Because if the mux isn't set correctly, you don't get audio.

And there's something else going on here.  If you looked carefully at the wave mixer, you noticed that the mixer line has a volume and mute control.  But if you looked at the topology, there's no mute or volume. Why is that?  Well, in Windows XP, the kernel drivers that provide audio support recognize that the source line doesn't have any volume controls and they add them in for you.  That's also where the SW Synth source line and a number of the other lines come from - they're controls that are synthesized by the kernel drivers even though they're not actually implemented in the hardware.

During review, I was pointed to the MSDN article that describes this translation, here.

Comments

  • Anonymous
    June 14, 2005
    From a more general perspective is there any good sources of reading about the internal workings of sound cards?
  • Anonymous
    June 15, 2005
    Aahh... That's what you're working on. A re-architecture of Windows Audio for Longhorn.
  • Anonymous
    January 12, 2007
    In the Windows CE audio stack, the term "mixer" is used to refer to a couple of different, unrelated