レナート   Wunschkonzert, Ponyhof und Abenteuerspielplatz   ﻟﻴﻨﺎﺭﺕ

Tue, 10 Jun 2008

A Sixfold Announcement

Let's have a small poll here: what is the most annoying feature of a modern GNOME desktop? You got three options to choose from:

  1. Event sounds, if they are enabled
  2. Event sounds, if they are enabled
  3. Event sounds, if they are enabled

Difficult choice, right?

In my pursuit to make this choice a little bit less difficult, I'd like to draw your attention to the following six announcements:

Announcement Number One: The XDG Sound Theming Specification

Following closely the mechanisms of the XDG Icon Theme Specification I may now announce you the XDG Sound Theme Specification which will hopefully be established as the future standard for better event sound theming for free desktops. This project was started by Patryk Zawadzki and is now maintained by Marc-Andr� Lureau.

Announcement Number Two: The XDG Sound Naming Specification

If we have a Sound Theming Specification, then we also need an XDG Sound Naming Specification, again drawing heavily from the original XDG Icon Naming Specification. It's based on some older Bango work (which seems to be a defunct project these days), and is also maintained by Monsieur Lureau. The list of defined sounds is hopefully much more complete than any previous work in this area for free desktops.

Announcement Number Three: The freedesktop Sound Theme

Of course, what would the mentioned two standards be worth if there wasn't a single implementation of them? So here I may now announce you the first (rubbish) version of the XDG freedesktop Sound Theme.. It's basically just a tarball with a number of symlinks linking to the old gnome-audio event sounds. It's only a very small subset of the entire list of XDG sound names. My hope is that this initial release will spark community contributions for a better, higher quality default sound theme for free desktops. If you are some kind of musician or audio technician I am happy to take your submissions!

Announcement Number Four: The libcanberra Event Sound API

Ok, we now have those two specs, and an example theme, what else is missing to make this stuff a success? Absolutely right, an actual implementation of the sound theming logic! And this is what libcanberra is. It is a very small and lean implementation of the specification. However, it is also very powerful, and can be used in a much more elaborate way than previous APIs. It's all about the central function called ca_context_play() which takes a NULL terminated list of string properties for the sound you want to generate. How this looks like?

{
	ca_context *c = NULL;

	/* Create a context for the event sounds for your application */
	ca_context_create(&c);

	/* Set a few application-global properties */
	ca_context_change_props(c,
	                        CA_PROP_APPLICATION_NAME, "An example",
				CA_PROP_APPLICATION_ID, "org.freedesktop.libcanberra.Test",
				CA_PROP_APPLICATION_ICON_NAME, "libcanberra-test",
			        NULL);
	
	/* ... */

	/* Trigger an event sound */
	ca_context_play(c, 0,
			CA_PROP_EVENT_ID, "button-pressed", /* The XDG sound name */
			CA_PROP_MEDIA_NAME, "The user pressed the button foobar", 
			CA_PROP_EVENT_MOUSE_X, "555",
			CA_PROP_EVENT_MOUSE_Y, "666",
			CA_PROP_WINDOW_NAME, "Foobar Dialog",
			CA_PROP_WINDOW_ICON_NAME, "libcanberra-test-foobar-dialog",
			CA_PROP_WINDOW_X11_DISPLAY, ":0",
			CA_PROP_WINDOW_X11_XID, "4711",
			NULL);

	/* ... */

	ca_context_destroy(&c);
}

So, the idea is pretty simple, it's all built around those sound event properties. A few you initialize globally for your application, and some you pass each time you actually want to trigger a sound. The properties listed above are only a subset of the default ones that are defined. They can be extended at any time. Why is it good to attach all this information to those event sounds? First, for a11y reasons, where visual feedback in addition of audible feedback might be advisable. And then, if the underlying sound system knows which window triggered the event it can take per-window volumes or other settings into account. If we know that the sound event was triggered by a mouse event, then the sound system could position the sound in space: i.e. if you click a button on the left side of the screen, the event sound will come more out of your left speaker, and if you click on the right, it will be positioned nearer to the right speaker. The more information the underlying audio system has about the event sound the fancier 'earcandy' it can do to enhance your user experience with all kinds of audio effects.

The library is thread-safe, brings no dependencies besides OGG Vorbis (and of course a Libc), and whatever the used backend requires. The library can support multiple different backends. Either you can compile a single one directly into the libcanberra.so library, or you can bind them at runtime via shared objects. Right now, libcanberra supports ALSA, PulseAudio and a null backend. The library is designed to be portable, however only supports Linux right now. The idea is to translate the XDG sound names into the sounds that are native the local platform (i.e. to whatever API Windows or MacOS use natively for sound events).

Besides all that fancy property stuff it also can do implicit on-demand cacheing of samples in the sound server, cancel currently playing sounds, notify an application when a sound finished to play and other features.

My hope is that this piece of core desktop technology can be shared by both GNOME and the KDE world.

Check out the (complete!) documentation!

Download libcanberra 0.1 now!

Read the README now!

Announcement Number Five: The libcanberra-gtk Sound Event Binding for Gtk+

If you compile libcanberra with Gtk+ support (optional), than you'll get an additional library libcanberra-gtk which provides a couple of functions to simplify event sound generation from Gtk+ programs. It will maintain a global libcanberra context, and provides a few functions that will automatically fill in quite a few properties for you, so that you don't have to fill them in manually. How does that look like? Deadly simple:

{
	/* Trigger an event sound from a GtkWidget, will automaticall fill in CA_PROP_WINDOW_xxx */
	ca_gtk_play_for_widget(GTK_WIDGET(w), 0,
                               CA_PROP_EVENT_ID, "foobar-event",
			       CA_PROP_EVENT_DESCRIPTION, "foobar event happened",
			       NULL);

	/* Alternatively, triggger an event sound from a GdkEvent, will also fill in CA_PROP_EVENT_MOUSE_xxx  */
	ca_gtk_play_for_event(gtk_get_current_event(), 0
                              CA_PROP_EVENT_ID, "waldo-event",
			      CA_PROP_EVENT_DESCRIPTION, "waldo event happened",
			      NULL);
}

Simple? Yes, deadly simple.

Check out the (complete!) documentation!

Announcement Number Five: the libcanberra-gtk-module Gtk+ Module

Okey, the example code for libcanberra-gtk is already very simple. Can we do it even shorter? Yes!

If you compile libcanberra with Gtk+ support, then you will also get a ne GtkModule which will automatically hook into all kinds of events inside a Gtk+ program and generate sound events from them. You can have sounds when you press a button, when you popup a menu or window, or when you select an item from a list box. It's all done automatically, no further change in the program is necessary. It works very similar to the old sound event code in libgnomeui, but is far less ugly, much more complete, and most importantly, works for all Gtk+ programs, not just those which link against libgnomeui. To activate this feature $GTK_MODULES=libcanberra-gtk-module must be set. So, just for completeness sake, here's how the example code for using this feature in your program looks like:

{
}

Yes, indeed. No code changes necessary. You get all those fancy UI sounds for free. Awesome? Awesome!

Of course, if you use custom widgets, or need more than just the simplest audio feedback for input you should link against libcanberra-gtk yourself, and add ca_gtk_play_for_widget() and ca_gtk_play_for_event() calls to your code, at the right places.

Announcement Number Six: My GUADEC talk

You want to know more about all this fancy new sound event world order? Then make sure to attend my talk at GUADEC 2008 in Istanbul!

Ok, that't enough announcements for now. If you want to discuss or contribute to the two specs, then please join the XDG mailing list. If you want to contribute to libcanberra, you are invited to join the libcanberra mailing list.

Of course these six announcements won't add a happy end to the GNOME sound event story just like that. We still need better sounds, and better integration into applications. But just think of how high quality the sound events on e.g. MacOS X are, and you can see (or hear) what I hope to get for the free desktops as well. Also my hope is that since we now have a decent localization infrastructure for our sounds in place, we can make speech sound events more popular, and thus sound events much more useful. i.e. have a nice girl's voice telling you "You disc finished burning!" instead of some annoying nobody-knows-what-it-means bing sound. I am one of those who usually have there event sounds disabled all the time. My hope is that in a few months time I won't have any reason more to do so.

posted at: 18:46 | path: /projects | permanent link to this entry | 19 comments


Posted by Marc-Andre Lureau at Tue Jun 10 19:08:00 2008
Awesome! and you made it happen so quickly! HoooooRay to Lennart!

Posted by Lennart at Tue Jun 10 19:28:09 2008
And indeed, I cannot count. ;-)

Posted by Étienne BERSAC at Tue Jun 10 19:36:06 2008
Hi,

Congratulation. I'm actually willing to add a "scan-complete" event or so along GNOME Scan, actually useful when you scan 15 pages document into one PDF.

Regards,
Étienne.

Posted by Lennart at Tue Jun 10 20:08:29 2008
Étienne: the git version of the naming spec now has a "complete-scan" sound event.

Posted by FACORAT Fabrice at Tue Jun 10 20:44:37 2008
I guess that you know that there are also sounds events under KDE, and that eventually taking some sounds from the KDE project will increase the chance that the KDE project will use your specs ?
Presently by reading your posts, it's like a GNOME only project ...

Posted by Stoffe at Tue Jun 10 21:02:17 2008
Great! I can't thank you enough for all the great job you do for free sound! :)

Fabrice, it's not about having GNOME sounds in KDE, it's about finding a common framework for event sounds that all could use, and then each project and indeed each distribution and ultimately even each user could have their own actual sounds for the events...

Posted by Lennart at Tue Jun 10 21:07:02 2008
Fabrice: I don't think that taking their sounds is going to win the KDE developer's hearts. In the end the idea of theming is that we get themes that use neither current GNOME nor the current KDE sounds.

I sent this mail to the kde-devel ML today:
<a href="http://lists.kde.org/?l=kde-devel&m=121312214011502&w=2">http://lists.kde.org/?l=kde-devel&m=121312214011502&w=2</a>

Posted by Goran Raki&#263; at Tue Jun 10 21:09:29 2008
Awesome!

Posted by David at Tue Jun 10 22:15:15 2008
Hrm, were the KDE developers involved in the making of this? I was under the impression that such specs were to be made so that they are a convergence of the desktops' current handling of this, rather than one side forcing adoption of the other's stuff.

Posted by Lennart at Tue Jun 10 22:18:31 2008
David: if both sides just wait for each other we will never get to something useful.

So to jumpstart this I now prepared some code that works how I think things should work, and posted that on the kde ML for discussion. Let's see how they respond.

Posted by Marc-Andre Lureau at Tue Jun 10 23:17:34 2008
@David: the specs have been posted on xdg mailing list several times (there were similar attempts in the past).

Furthermore, I was in contact with Olivier Goffart  about them (although we did not review the spec in detail).

The specs are open.

Posted by AAk at Wed Jun 11 00:08:47 2008
How does that relate to the KDE sound API (phonon) ?

Posted by Richard Hughes at Wed Jun 11 09:37:45 2008
Legend, ROCK ON.

Posted by Dan Nicholson at Wed Jun 11 19:15:33 2008
Lennart, I don't even know how you find the time manage all these projects. I love the fact that while some people are talking about overhauling the desktop, you're taking the existing desktop and just making it better. Keep up the good work.

Posted by Achim at Thu Jun 12 19:21:43 2008
I would like to know if the event sound will support surround sound?

For example if you close a window in the lower left-hand corner of your screen, will the event sound come from the rear left speaker?

Regards
Achim

Posted by Esben Stien at Thu Jun 12 21:13:32 2008
Having an official synth in GNOME would be nice.

Like vector graphics, we should have a synth daemon, like supercollider, csound, etc to synthesize sound that is part of GNOME.

Having this format requires less space and you're able to synthesize at any quality and rate that the user configures.

Posted by Marc-Andre Lureau at Wed Jun 18 16:58:04 2008
@Achim: that's the idea, there will be different ways to achieve this, but yeah, it supports different sound profile/systems.

@Esben: totally agree, but SoundFont/FluidSynth is  easier to use and create appealing bank/themes, I guess. CPU consumption should be taken seriously too.

Posted by whujfiw at Wed May 25 20:03:23 2011
xKpV9l  zmqclybxsxyr

Posted by credit loans at Sat Sep 17 04:02:35 2011
freelance writer

Leave a Comment:

Your Name:


Your E-mail (optional):


Comment:


As a protection against comment spam, please type the following number into the field on the right:
Secret Number Image

Please note that this is neither a support forum nor a bug tracker! Support questions or bug reports posted here will be ignored and not responded to!


It should be obvious but in case it isn't: the opinions reflected here are my own. They are not the views of my employer, or Ronald McDonald, or anyone else.

Please note that I take the liberty to delete any comments posted here that I deem inappropriate, off-topic, or insulting. And I excercise this liberty quite agressively. So yes, if you comment here, I might censor you. If you don't want to be censored your are welcome to comment on your own blog instead.


Lennart Poettering <mzoybt (at) 0pointer (dot) net>
Syndicated on Planet GNOME, Planet Fedora, planet.freedesktop.org, Planet Debian Upstream. feed RSS 0.91, RSS 2.0
Archives: 2005, 2006, 2007, 2008, 2009, 2010, 2011

Valid XHTML 1.0 Strict!   Valid CSS!