You're listening to your MP3 player in shuffle mode and have just been lulled into a mellow mood by Miles Davis, when suddenly the mood is shattered by a blast from the Pixies. If, as Apple claims of the iPod, "random is the new order", it has its drawbacks.

But the jarring leaps of MP3 shuffling could be banished by new digital music software being developed by researchers at the University of Munich in Germany. AudioRadar, a program devised by Otmar Hilliges and his colleagues, promises to fit your music selections to your mood.

Choosing music by genre or artist doesn't guarantee to give you what you want. If you hanker after a lilting Irish air, you could be in for a shock when your machine alights on the Pogues. Musical genres don't necessarily capture the emotional qualities of a particular song.

That's why people make their own categories on their iPods, sorting music by suitability to moods or events, creating one list for high-paced jogging and another for romantic dinners. But, with personal digital music collections now easily including more than 10,000 songs, that's a time-consuming process.

Hilliges thinks he and his colleagues have found a way to make such groupings automatically. "A lot of people don't know what songs their library contains. We try to give people a means to navigate their collection."

Four-dimensional music

The AudioRadar software, which began as a student project, breaks down musical pieces into four attributes: fast/slow, rhythmic/melodic, calm/turbulent and rough/clean. The last two are measures of the amount of change, rhythmically or melodically, within a song on long and short time scales.

The four characteristics are then used to locate all the songs in a playlist within a four-dimensional space, with the distance between them giving a measure of their similarity. To determine which music is selected from this space, the user specifies the preferred levels of each of the four attributes to match their mood.

“A lot of people don't know what songs their library contains.”

Otmar Hilliges, University of Munich.

The researchers have developed a way of projecting these results onto a two-dimensional display, in which a 'reference song' appears at the centre and the other songs are placed in concentric circles surrounding it. The users can decide to move in a specific trajectory from the current song, for example getting music that's similar but faster. Or the MP3 player could be set to meander randomly in this part of the mood space.

Easy listening

Some other projects are also currently trying to sort music by mood, but usually by using mass amounts of public feedback rather than computer automation. The Musical Genome Project, launched by Californian company Pandora Media, is one of the most extensive, employing a team of 30 musical analysts to classify songs based on up to 400 different attributes.

The information from the Musical Genome Project is used to create an online streaming music station that, for a subscription fee, supplies music from the region of the 'musical universe' corresponding to a particular song or artist specified by the user. Pandora's library contains more than 400,000 songs from 20,000 artists, and its recommendations are fine-tuned by user feedback.

But that system, Hilliges says, is biased towards music that is already popular, and is slow to add new sounds.

Classic heavy metal

The AudioRadar researchers confess that in their prototype system, the analysis used to measure these quantities is rather crude. "We just took algorithms others had developed," says Hilliges. And they aren't perfect. "We can't distinguish an uninspired rip-off from the original great song by just considering their technical qualities," they say. They suggest that one solution would be to build-in feedback and reviews from critics and fans.

Another tricky problem is that the classification scheme struggles when faced with very different types of music. "Classical music comes out as very similar to heavy metal," Hilliges admits, adding that this is a common problem for other music-rating systems.

All the same, he says that even the prototype system doesn't do too badly: in informal tests, he says "most people are excited by the results". Hilliges will present the work at the International Symposium on Smart Graphics in Vancouver, Canada, next week.