Phonon Sample Cache

Ian Wadham iandw.au at gmail.com
Sat Aug 27 00:54:53 BST 2011


On 27/08/2011, at 2:37 AM, Trever Fischer wrote:
> As we discussed forever ago back in lovely Randa, Switzerland, Phonon was
> going to get a sample cache for rapid playback of tiny sound files. This
> is needed because phonon really isn't designed to do that.
> 
> I've come up with a preliminary UML diagram to illustrate what I think
> might work: http://i.imgur.com/4VIEr.png
> 
> The delay between calling play() and the speakers making some noise must
> be as low as possible. Eventually, the latency should be low enough that
> even games can rely on low-latency audio to Just Work.
> 
> A quick discussion with Colin suggests to me that some further design
> refinement is needed. To illustrate, everything should be handled with
> libcanberra on Linux because reinventing the wheel sucks. That raises one
> minor problem: using libcanberra on linux, we'd only need the correct
> sample name, such as "new-message-im". For other desktops, we would need
> the path to the sound or at least a place to look for the sound.
> 
> One more note: This is in no way intended to replace KNotify or to create
> a cross-desktop notification system. The primary intent is for something
> such as the meego dialer to quickly play a DTMF tone the instant the
> keypad button is pressed, or KGoldRunner to not be laggy and cut off the
> sounds. libcanberra supports game sounds to be themed, so playing nice
> with that is the reason for sound theme support.

Errrmmm, whilst I applaud this initiative, it may be a case of too little too
late.  As KGoldrunner author, I spent months earlier this year trying to get
Phonon to play sounds nicely after I had been forced to disable them
completely a month or so before the KDE 4.6 release.  Not the least of
the problems was battling with the effects of the move to "git" on the KDE
build system as I struggled to install the "latest and greatest" Phonon and
produce massive Phonon debugging logs, as requested by Harald Sitter.

I sent several emails to this list, some of which got stuck in moderation, but
AFAICT nobody paid attention, except for recommending more upgrades.

Finally I balked at upgrading my entire desktop to KDE 4.6, which would
risk disrupting other uses of my laptop that are not to do with KDE devel.

Instead, I decided to cut my losses and switch from Phonon to TagaroAudio.
This is a small library which I expect will become part of libkdegames soon.
It is based on the OpenAL sound library.  At present, the KGoldrunner and
Granatier games are using TagaroAudio (statically) and OpenAL.

See http://websvn.kde.org/trunk/KDE/kdegames/kgoldrunner/src/TagaroAudio/

It took only a day or so to get game sounds working this way, as opposed
to months of struggling with Phonon and its ramifications.  And they came
crisp, clear and in time with the game action.  Maybe you heard my sigh of
relief as far away as Germany ... :-)

Furthermore, I was able to hear sounds that had never played properly
before and "tune" the sound-class code for relative volume and precise
overlapping --- things I was never able to begin to do with Phonon.  Who
knows, I may even play the KGoldrunner sounds in stereo one day ... :-)

> A possible solution to this is to make the MRL arguments optional and
> implement our own naive theme search algorithm that uses a supplied
> directory to find samples.
> 
> Personally, I think theming game sounds is silly and would hardly ever be
> used; I'm looking for input from those who disagree with me because I
> don't think I'd be able to make a solution that satisfies that audience.

KGoldrunner sounds are already themed and have been for more than
three years.  It is no sweat.  The sounds just go in the same directory
structure as the graphics themes.  It is true, however, that while there are
six graphics themes, there is only one sound theme.  I think that is just
because sound composers are even harder to find than graphics artists.

Mind you, I could always ask my son to write another sound theme ... :-)

Cheers, Ian W.
KGoldrunner author, Australia



More information about the kde-multimedia mailing list