Clusty's Blog

    Just another WordPress weblog

    Browsing Posts published in October, 2009

    Today I wanted to attract your attention to a funky contraption which dates from the 80′s, and no, it has no connection to Homer’s favourite brand of beer.

    I am talking about a nice exploit of the C programming language, related to the case-label fall-through invented by Tom Duff. This function performs the simple task of copying data from one place to another in memory.

    send(to, from, count)
    register short *to, *from;
    register count;
    {
        register n=(count+7)/8;
        switch(count%8){
        case 0: do{ *to++ = *from++;
        case 7:     *to++ = *from++;
        case 6:     *to++ = *from++;
        case 5:     *to++ = *from++;
        case 4:     *to++ = *from++;
        case 3:     *to++ = *from++;
        case 2:     *to++ = *from++;
        case 1:     *to++ = *from++;
            }while(--n>0);
        }
    }

    In the dawn of C and compiler optimization, this function performed almost twice as fast as the naive looping approach due to the loop unrolling (unwinding).

    Nowadays it is probably nothing more than a curiosity as memcopy is doing a better job on almost all platforms. Actually at some point the performance of XFree86 got a serious boost from replacing all Duffs. At least one good thing came from the awkward behaviour of C’s switch-case…

    If you are like me, and have tens and tens of gigs of music, you understand the pain of keep everything sorted and with the right album art, especially when you use all sorts “smart” media players like Windows Media Player, that screw up your hand written ID tags.

    This new free tool I found not only fills in missing info by matching preexisting tags, but also can compute a unique hash of your mp3 based on some proprietary algorithm. So you should be able in theory to tag mp3′s that are called “file1.mp3″

    Well, today during of one of my usual weekend random internet wanderings, I stumbled across an awesome project that does just that and does it semi automatically. To top things, all files including the database is released under GNU (to be read free, costs nothing, zilch, nada).

    I am talking about the guys at MusicBrainz. This is just a database containing lots of music meta-information uploaded by lots of people, pretty much they way FreeDB is for audio CDs. There are quite a few taggers that are able to get their information from this site, but I personally tried just two of them: EasyTag available for *nix and Picard available for Win/Mac/*nix (available on the MusicBrainz site). While EasyTag is “easier” to use, as all operations are automatic and the program makes all the decisions for you. From now on I will make an in depth presentation of Picard.

    For some strange reason the default version of Picard can view Album Cover, but you cannot download any missing covers for your files. The downloading capability is enabled through an extra plugin available on the same site, Cover Art Downloader Plugin. Follow the instructions on how to install plugins and make sure you enable it.

    For an quick intro on how to use Picard check out these two links: How to tag files with Picard and the screencast made by one of the authors:

    The docs are quite decent but there are certain GUI elements which are not self explanatory. Every so often you will notice that a song has a musical note icon. This basically means that the file is missing from the album (file missing or assigned to another album). Other times there is a musical note but there are two items in the subtree. This means that it found two duplicate files that match same position in the album. This can be resolved by scanning the file to get it’s fingerprint since there certain albums which contain multiple tracks with the same Name (like different studio takes).

    Picard has more or less two working modes: a very fast, but inaccurate mode that matches just ID tags which is triggered by clicking Lookup, and a slow and accurate mode that matches ID tags but also MP3 fingerprint (a unique ID that does not depend on tag codec used to encode, etc) that is somewhat slower but dead accurate.

    Hello world!

    No comments

    I’ve been meaning to start off a web project for some time now, but I just never found an idea that felt good enough. Till the little light bulb lights up above my head, I will be flexing that web muscle maintaining this blog.

    Now some might run in tears: “OHHH NOES, yet another blah blah blog by a guy that has nothing to say telling us about the great omelette they had for breakfast”. I am planning to keep this blog as informative as possible. The blog will include howtos related to IPhones, Linux, Mac, Photography, etc, call it my way of giving back to the community.