Illegitimi non carborundum


Speak[er Setup] Now, or Forever hold your Peace.

Well it's taken me a little time to commit this work, but here it is. This is the fruits of my labour from the KDE Multimedia Sprint earlier this year.

As well as taking part in various discussions, I was able to spend some time cooking up a UI to control the configuration of PulseAudio and the various cards attached.When adding PulseAudio support to the various parts of KDE that need it (Phonon, KMix), there was an important part of the puzzle missing: a card profile selector, and a sink/source port selector. I had always intended to include this functionality somewhere, but the KMix framework didn't really allow for it neatly (I could have created a separate dialog of course but it didn't quite feel right).

The eagle eyed readers may have seen a sneak preview of this feature when looking at the KDE-specific help page I wrote up on the PulseAudio website. So I give you this: the Speaker Setup tab in System Settings.

Speaker Setup GUI

Speaker Setup GUI

The little icon in the middle is your user icon, so you'll see this differently unless your a weird stalker type and have set your icon to mine :s

The various drop downs allow fully control over all cards that are attached to the system. The buttons on the main pane allow you to test each speaker separately. In order to test the speakers, libcanberra is used. libcanberra is an implementation of the Free Desktop Sound Theme specification. It allows this test to be implemented with minimum hassle and I'm not personally interested in reinventing the wheel, hence the use of this library and the additional dependency.  Some people dislike using libcanberra in KDE (as was apparent from some discussions at the Multimedia Sprint), but I believe the reasons were often personal ones and not related to the usefulness of the code. If someone really wants to factor this out, they can but I have no interest in doing so and will prefer to use the existing implementation whenever possible (and this would include any future implementation I may or may not do with regards to support the Sound Theme Specification in KDE (or maybe Qt) directly)

When a 5.1 surround system is presented, the GUI is obviously a bit more advanced:

Speaker Setup GUI (5.1)

Speaker Setup GUI (5.1)

For those naysayers, I've tried my best to ensure that the compile will work fine without PulseAudio installed. It should also degrade gracefully when it is compiled with PA support, but PA is not configured to be used at runtime. The whole tab will simply not be available.

There is still one small problem left in that I don't handle disconnection/reconnection yet. This causes the GUI to crash if the PA server is stopped and restarted. This is not typically something that happens, but it's still something I will fix shortly all the same.

This code is now in trunk (r1154776) so feel free to try it out and report other bugs etc. This GUI is also included in Mandriva Cooker (I did want to include it prior to 2010.1 release, but the timing didn't work out - tho' it probably would have been OK considering the delays that cropped up in the release process). I expect this functionality to be included in any updated/backported versions of KDE for 2010.1.

For reference, in case you didn't spot it yourself, this GUI was heavily inspired by the gnome-speaker-setup utility.

Share and Enjoy:
  • Digg
  • StumbleUpon
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
  • Slashdot
  • Name (required)

    Thank you!

  • Tsiolkovsky

    Wow, thanks for this work, Looks very usefull. It would only need a talk with KDE graphic designers and usability experts to make it look more attractive.

  • Dennis

    Looks very good. Maybe this should replace kmix?

    • Colin

      Nah, this doesn’t really replace kmix. The PA support in KMix allows full control of the volume levels, and this UI allows you to change the setup/speaker arrangement. They are really rather different task. I consider the kmix case to be something you may do quite regularly (i.e. daily), but this configuration GUI is probably less commonly used.

      • Dennis

        Hm well perhaps you are right. But kmix feels a little long in the tooth to me.

  • cloose

    Would it be possible to vertical align the comboboxes in the Hardware group with the combobox in the Output group?

    It’s, IMHO, otherwise more diffult to scan this dialog.

    • Colin

      Yeah, that would be nice. I’m not really a GUI guy tho’, so struggled with the various spacers etc. to get it to look vaguely OK as it is. If someone more experienced than me in this kind of thing wants to take a look, then I’d really appreciate it 🙂

  • Fri13

    Looks very nice. I really like the idea to be able press single element to play test sound from there. Maybe if possible, make the user icon as the login icon (or then somekind universal anonym user) and when you press it, it plays all the elements from front left -> middle -> right -> rear right > left.

    • Colin

      Yeah the icon looks as you suggest (login icon, falling back to generic), but the idea of cycling through all the outputs is a good one. I’ll look into it (eventually!)

  • Markus

    As long as PulseAudio keeps randomly muting my speakers by itself, I keep that crap disabled.
    Pure Alsa FTW!

    • Colin

      As long as people don’t report and try and debug such issues, they wont get fixed…. living in a bubble FTW :p

      • Markus

        Why would I go through all that trouble when simply disabling and using pure Alsa fixes the countless PA problems?

  • Volker

    Thanks, very nice! A bit offtopic: did you read my message on IRC regarding this problem?

  • TheBlackCat

    This is great! Glad to see better 5.1 control.

    Will there be any support for rewiring different channels? That is one thing there is still no GUI for of any sort that I have seen.

    So for instance I have 2 2.1 speakers and 2 1.0 speakers. I use it as a 5.1 speaker setup, but this requires re-routing the various channels on my sound card as so:
    Left-front and LFE -> Left Front
    Right-front and LFE -> Right-front
    Left-rear -> Left-rear
    Right-rear -> Right-rear
    Center and LFE -> Center
    Center and LFE -> LFE

    There is no GUI for this that I know of. It should be possible to do, you would need a list of output channels, and then have a drop-down list where you could select the input channel and the volume of that channel, and probably a +/- button for adding input channels to each output channel. It might also be needed to set it individually for 2 channel, 4 channel, 6 channel, and 8 channel inputs.

    This would also be really useful for people with surround sound systems running stereo inputs who want to, for instance, route Left to Left-front and left-rear, right to right-front and right-rear, and both to center/LFE.

    • Colin

      Longer term I’d certainly like such a GUI to exist, but I think it will all depend on one of my other modules in PA that I’ve not given much love to of late: module-loader. This is ultimately going to replace module-gconf and should basically be a glorified module loader. This could then automatically load the appropriate module-remap-sink modules that would allow for your kind of setup.

      I’ve not really got a schedule for this, but if no-one else does it first, I’ll get round to it eventually.

  • Quintesse

    Hi Colin, nice work on the GUI!

    One thing that always seems missing in these dialogs is the input side. Wouldn’t it be great to have a tab for microphone setup as well? Lot’s of times I wonder if my input is working and need to fall back to trying to record samples with audio recording apps, some of which are so comlpex that I don’t know if the fault is with the hardware or with me just not understanding the options 🙂

    A dialog like the one you made would be perfect. As an example would server the typical sound setup dialogs with programs like Skype where you can see a meter showing if anything is being recorded and the ability to listen back to it.

    • Colin

      I was kinda half intending to eventually add a VU Meter to kmix for output and inputs, so this would probably be sufficient for testing levels which is probably enough to confirm it “works”. Maybe a little dedicated GUI for recording and playback for testing purposes would be quite nice too tho’.

  • frapell

    Hi Colin. First of all, HUGE thanks for your work 😀

    i wanted to ask, i’m trying to get this working, i’m using kde 4.6.2 under Ubuntu 10.10 and there’s no way i can click on the “Front left”, “Front right”, etc buttons, and have the system play *any* sound… the sound works well though, i can play music with Amarok, etc.

    I installed all the libcanberra packages i could find, but it won’t work. Can you give me some pointers on what to do ?

    dunno if it helps, but i’m using the Gstreamer phonon backend, and i have all gstreamer-plugin-* packages installed.

    thanks a lot.

    • Colin


      Yeah the problem you are encountering is Ubuntu being dumb. They have patched their libcanberra package in such a way that it breaks the Sound Theme Specification. I have mentioned this to them several times and even publicly in the libcanberra development mailing list.

      It actually took me a good couple hours of debugging with an Ubuntu user to work this out. It’s very annoying when downstream distros break things so recklessly and cause us upstream people problems like this.

      Anyway, make sure you have both the Ubuntu and FreeDesktop sound themes installed and things *might* work. Otherwise file a bug report in Ubuntu (high priority please) and complain about their reckless, patch-happy approach that breaks things and ask them to issue an update ASAP 🙂

      If you can’t get it working, come find me on IRC and we can work out what is needed (I know the other user I spoke with got it working, but I forget the exact steps).

      All the best!

  • Mikko


    Is there any way to configure a mono setup?

    • Colin

      It somewhat depends on your hardware as to whether it’s available as a default card profile. If it’s not available, then you can still do some tricks to make it happen using a module-remap-sink to turn your stereo sink into one that outputs the same to both speakers. From memory, the command would be something like: pacmd load-module module-remap-sink sink_name=mono master=ASLASINK_NAME channels=2 channel_map=”mono,mono” master_channel_map=front-left,front-right remix=no