A while ago, I got really tired of needing to change out the CD in my CD-ROM drive every time I got tired of hearing the same six songs over and over again. It's no big deal at first, but it gets old. So I devised this system:

  1. Rate all the tracks on all of your CDs according to how much you like them, on a scale from 1 to 10, 10 being the best.
  2. Rip all the tracks rated 5 or higher to WAV files on your hard drive, and either sort them into directories named 5 through 10, or create symlinks in directories named 5 through 10 pointing to the tracks in their actual locations. The directories 5 through 10 should all be in one base directory.
  3. From the base directory, run the code below. If you change any of the ratings later or add more CDs, you can put those tracks or symlinks in their respective directories and repeat starting at this step. The code will replace its previous work.
  4. The code creates (in the base directory) a probabilistic directory filled with symlinks. Higher-rated tracks are represented more times, so that the music you like most is played most often, and music you only sort-of like is played less often.
  5. Fire up your favourite media player and point it at all the files in the probabilistic directory. Tell it to use random order (or shuffle) and repeat. Hit play.

If you have a good-sized CD collection, the resulting playlist will have quite a variety of music in it, yet the music you really like a lot will come up often, so you won't feel like it's constantly playing stuff you only sort-of like. But everything rated 5 or higher gets played occasionally. (Tracks rated below 5 you don't even have to rip, and in any case they won't be on the playlist.)

There are only two downsides to this approach: it only works if your filesystem supports symlinks, and it uses up a few gigabytes of hard drive space. But for being able to set your media player going and leave it running on the same playlist for days and days without getting bored of the same old music or annoyed at the lack of variety, it's hard to beat.

The code, of course, is very simple:

#!/usr/bin/perl -- -*- cperl -*- `rm -rf probabilistic/*`; chdir "probabilistic" or die "Cannot change to probabilistic directory +: $!\n"; $.='_'; $weight=1; foreach $n (5..10) { $rating = sprintf("%02d", $n); print "*** Items rated $rating:\n"; foreach (<../$n/*>) { $target=$_; s/.*\///; # (Greedy match goes to last slash.) ($basedest, $ext) = ($_=~m/(.*)[.]([^.]+)/); foreach $dn (1..$weight) { print "ln -s $target $rating$.$basedest$.x$dn.$ext\n"; `ln -s $target $rating$.$basedest$.x$dn.$ext`; } } $weight+=2; }

update: As it happens, xmms is the media player I'm using, but I was not aware of IMMS. Still, my approach allows one "playlist" (directory of symlinks) to be used by any media player (err, any media player that will run on a system that supports symlinks). OTOH, IMMS appears to adaptively determine ratings on the fly by your skipping patterns; whereas, in my system you rate all the songs upfront. So the idea is similar, but the details are different.


;$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$;[-1]->();print

In reply to music playlist weighted by rating by jonadab

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.