About · Blog · Projects · Papers · Contact

I said I'd never blog

DeforaOS, NetBSD, reverse-engineering and stuff
A graphical mixer for NetBSD
Blog post by khorben
on Friday, December 18 2009, 18:16

Member of

On my way to making some noise about it, I'd like to mention a few things about the Mixer program I just wrote [1].

Some background information: NetBSD [2] has an audio API of its own [3][4], which I'll call "audioio" because it sits in /usr/include/sys/audioio.h [5]. It seems to be based on Solaris' historical audio sub-system, but I've always had a hard time obtaining decent documentation about Solaris [6] on the web so I'll skip this part.

To the point: NetBSD thankfully provides an OSS emulation layer [7]. Unfortunately, it is outdated (version 3), and assumes that controls are always fixed and resemble those of the "historical" cards (eg the SoundBlaster 16 [8]). Therefore, fewer and fewer controls are actually functional, since they are implemented in totally different ways in newer sound cards.

Therefore, until recently, I had to use the native NetBSD tool, mixerctl [9], to operate with the mixer (volume controls). Just for fun, I'll paste here what it looks like on my laptop:
$ mixerctl -av
outputs.spdif.source=os  [ os adc ]
outputs.lineout.source=dac  [ dac mixerout ]
outputs.lineout.mute=off  [ off on ]
outputs.lineout=240,240  delta=4
record.lineout=85,85  delta=85
outputs.lineout.dir=output  [ input output ]
outputs.lineout.boost=off  [ off on ]
outputs.lineout.eapd=on  [ off on ]
outputs.headphones.src=dac  [ dac mixerout ]
outputs.headphones.mute=off  [ off on ]
outputs.headphones=124,124  delta=4
outputs.headphones.boost=off  [ off on ]
outputs.mono.mute=off  [ off on ]
outputs.mono=124  delta=4
record.mic=85,85  delta=85
outputs.linein.source=dac  [ dac mixerout ]
outputs.linein.mute=off  [ off on ]
outputs.linein=124,124  delta=4
record.linein=85,85  delta=85
outputs.linein.dir=output  [ input output ]
outputs.mono.source=dac  [ dac mixedmic linein mixerout lineout mic2 ]
inputs.beep.source=digitalbeep  [ digitalbeep beep ]
inputs.beep.mute=off  [ off on ]
inputs.beep=119  delta=17
inputs.dac.mute=off  [ off on ]
inputs.dac=248,248  delta=8
inputs.mic.mute=off  [ off on ]
inputs.mic=120,120  delta=8
inputs.linein.mute=off  [ off on ]
inputs.linein=120,120  delta=8
record.source=mixedmic  [ mixedmic linein mixerout mono cd lineout mic2 aux ]
record.mute=off  [ off on ]
record.master=255,255  delta=17
outputs.mic2.source=dac  [ dac mixerout ]
outputs.mic2.mute=off  [ off on ]
outputs.mic2=124,124  delta=4
record.mic2=85,85  delta=85
outputs.mic2.dir=output  [ input output ]
inputs.lineout.mute=off  [ off on ]
inputs.lineout=120,120  delta=8
inputs.aux.mute=off  [ off on ]
inputs.aux=120,120  delta=8
inputs.mic2.mute=off  [ off on ]
inputs.mic2=120,120  delta=8
inputs.cd.mute=off  [ off on ]
inputs.cd=120,120  delta=8
record.mixedmic.mute1=off  [ off on ]
record.mixedmic.mute2=off  [ off on ]
playback.mode=analog  [ analog spdif ]
That's 49 lines of cryptic controls indeed. To be fair, the mixerctl tool is great for scripts, but totally impractical when poking at the different controls just to understand what they mean and how they work.

Although, looking at the code, I found the API very interesting. In fact, it describes the different controls in terms of groups of values, sets or switches, providing their different names every time. I then imagined that I could generate an interface on the fly, based on Gtk+ [10], using sliders, checkboxes and radio buttons. It doesn't solve the whole problem understanding your own sound card, but I guess it would be much more practical this way.

It looks like this:
I think it's quite funny actually :)

To conclude about alternatives, I don't know how well pulseaudio [11] and others are working on NetBSD, since I'm not an avid GNOME/KDE/XFCE/etc fan. But if you have any idea or suggestion about mine, please do not hesitate! [12]

[1] http://www.defora.org/os/project/display/3305/Mixer
[2] http://www.netbsd.org/
[3] http://netbsd.gw.com/cgi-bin/man-cgi?audio+4+NetBSD-5.0
[4] http://netbsd.gw.com/cgi-bin/man-cgi?audio+9+NetBSD-5.0
[5] http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/sys/audioio.h?only_with_tag=netbsd-5
[6] http://www.opensolaris.com/get/index.jsp
[7] http://netbsd.gw.com/cgi-bin/man-cgi?ossaudio+3+NetBSD-5.0
[8] http://en.wikipedia.org/wiki/Sound_Blaster_16
[9] http://netbsd.gw.com/cgi-bin/man-cgi?mixerctl+1+NetBSD-5.0
[10] http://www.gtk.org/
[11] http://pulseaudio.org/
[12] http://people.defora.org/~khorben/place/wiki/13/Contact

Come back...

Creative Commons License RSS