Navigatie overslaan.

matlab

Graphing Amarok with Matlab

The DCOP interface to Amarok provides lots of fun. Especially interesting is the query command, that accepts SQL queries on the collection.

For example:
% dcop amarok collection query "SELECT count(rating) FROM STATISTICS GROUP BY rating" > stats.txt

Once this kind of data is available, the best way to visualise it is obviously to plot it. As I've spent a lot of my time in Matlab recently, that's the tool I'll use for this exercise.

>> load rating.txt;
>> plot([0:0.5:5], rating);
(I've left out the commands title the axes and stuff like that).

By default I set my songs to rating 2.5 . I've too much music to spend a lot of time on rating each song. Therefore I assume that each song is reasonably OK, otherwise it wouldn't be in my collection. I've still have to set about 500 songs to this default rating. From this graph it's obvious that I'm not very good at judging how much I like a song, as I have more songs rated 4 than 3.5, and almost exactly as much songs rated 4.5 as 5.

Now let's see how often the songs in my playlist have been played.
($ = shell code, >> = matlab code)
% dcop amarok collection query "SELECT count(playcounter) FROM STATISTICS GROUP BY playcounter" > playcounter.txt
>> load playcounter.txt;
>> plot([0:length(playcounter)-1], playcounter);

That was easy. This plot reveals that I've heard the majority of my collection only once. Only 22% has been played more than once (about 5200 songs), and only 3% (about 750 songs) more than twice.

Now let's try something slightly more complex. This time I'm interested in the number of songs played per day. Unfortunately that information is not available anywhere, but I found a way to get an approximation. My music collection is fairly large. In fact it is so large that I have heard most songs only once (as has been shown above). Therefore the number of songs I've heard last on a certain day is an approximation for the number of songs I've heard that day. This is of course biassed, but not too much.

$ dcop amarok collection query "SELECT accessdate FROM STATISTICS WHERE accessdate<>0" > accessdate.txt
>> load accesdate.txt; % load the data
>> accessdate2 = accessdate(accessdate~=0); % not interested in songs that have never been played
>> tabulated = tabulate(floor(((accessdate2-min(accessdate2))/(24*3600)))); % convert the unix timestamps to days, and tabulate the date
>> plot(tabulated(2:end, 1), tabulated(2:end, 2)); % plot it all

Clearly visible from this image are two incidents (at day 51 and day 164) where a broken sound backend caused Amarok to skip through the playlist rapidly. Between day 417 and 446 I was abroad, which is clearly visible from the drop in the graph. On average I play 122 songs per day.
Another thing visible from the graph is that I'm never at home at the weekends, causing the steep drops every few days. Until day 183 this was every other weekend, as can be seen by the wider peeks.

Inhoud syndiceren