FLAC and Ogg/Vorbis in iTunes

After buying my Squeezebox I wanted to rip all my music to a lossless music format to get maximum quality out of the little thing. And the Open Source lover that I am the choice fell on FLAC. One problem though…

The problem is that my girlfriend is using Windows with iTunes which isn’t compatible with FLAC or Ogg for that matter.

I googled around for FLAC/Ogg Vorbis support for iTunes and found xiph.org which has a FLAC/Ogg Vorbis plugin for QuickTime ( and therefor also iTunes). iTunes uses the QuickTimes components to playback different audio and video types.

To bad that their latest version 0.1.7 is released only for Mac. It seems that you need to have FLAC contained in Ogg containers to be able to playback FLAC.

This link: a blog about Xiphs development deserves attention as well.

Squeezebox

2 days ago I recieved my Squeezebox… finally I pulled my head out and bought one. I should have done this along time ago. This is one of the best investments since my IBM x40… and that says a lot. At first I got really disappointed because I couldn’t get the Squeezebox to connect to the wireless network. After a few hours tinkering with my wireless access point and the Squeezebox wireless settings I gave up. I plugged it to the network with a wire and installed the latest Slimserver on my Windows partition (I know, I know… Windows, not something I was proud of).

When the Squeezebox found the slimserver on the Windows box the Squeezebox asked me to allow it to update its firmware. After that the wireless ran without problem. Yay.

I’ve started ripping all our music to FLAC even though my girlfriend was almost finished with our over 300 CDs in mp3.

Right now I use Linksys NSLU2 (running Debian Etch) both as music storage and to run the slimserver. It feels a bit slow but it is really not that bad. I’m thinking of finding another NAS but it either has to as silent as the NSLU2 or it has to be wireless. If any of you guys know a good alternative the the NSLU2 let me know.

Back to the Squeezebox… Not only can you play all you digital music but you can listen to internet radio (there is a Pandora plugin). You can have it to wake you up, show RSS (news) feeds on the display, play you podcasts and much more. All you digital music needs gathered in one freaking cool looking, easy to navigate, low noise box in your living room. All in all the Squeezebox rocks! Period.

My very own hackergotchi head

Last week I found this Avatar while browsing the Ubuntu community forums. I really like the style and decided to make one myself which should also look kinda like me.<div> </div>

The result is my own personal “hand drawed” hackergotchi. I used a picture taken at work and Inkscape to do the magic. It might look even better if I applied an uneven stroke like the one from the Ubuntu forums. Right now Inkscape does the stroke which is kinda dull. But it will suffice for now.

Gtk.TreeView right click part 2

While on my winter vacation I played around with the Gtk.TreeView and the right click challanges. I found a way to extract the row which is clicked on and the data within. The following example shows how (it builds upon my last Gtk.TreeView right click example:

public class TreeViewExample {
    public static void Main ()
    {
        Gtk.Application.Init ();
        new TreeViewExample ();
        Gtk.Application.Run ();
    }

    public TreeViewExample ()
    {
        Gtk.Window window = new Gtk.Window ("TreeView Example");
        window.SetSizeRequest (500,200);

        MusicTreeView tree = new MusicTreeView ();
        window.Add (tree);
        window.ShowAll ();
    }
}

// Creating a new class MusicTreeView which is derived from the TreeView class
public class MusicTreeView : Gtk.TreeView {

        private Gtk.ListStore musicListStore;

        public MusicTreeView ()
        {
                musicListStore = new Gtk.ListStore (typeof (string), typeof (string));

                this.AppendColumn ("Artist", new Gtk.CellRendererText (), "text", 0);
                this.AppendColumn ("Title", new Gtk.CellRendererText (), "text", 1);

                musicListStore.AppendValues ("Garbage", "Dog New Tricks");
                musicListStore.AppendValues ("The Chemical Brothers", "Galvanize");
                this.Model = musicListStore;
        }

        // The TreeView has a build in function which is called upon a OnButtonPressEvent
        // We override the function to capture right clicks with the mouse
        protected override bool OnButtonPressEvent (Gdk.EventButton evnt)
        {
                if(evnt.Button == 3) {
                        Gtk.TreePath path = new Gtk.TreePath();
                        // Get TreePath from the xy-coordinates of the mouse from the event
                        // GetPathAtPos is a function from the TreeView class
                        GetPathAtPos (System.Convert.ToInt16 (evnt.X), System.Convert.ToInt16 (evnt.Y), out path);
                        Gtk.TreeIter iter;
                        // Get iter from the path
                        if (this.musicListStore.GetIter (out iter, path)) {
                                // Get artist and title from the iter
                                string artist = (string) this.musicListStore.GetValue (iter, 0);
                                string title = (string) this.musicListStore.GetValue (iter, 1);
                                System.Console.WriteLine ("Artist: " + artist + ", Title: " + title);
                        }
                        return true;
                }
                // Now if we would ever get this far
                // we run the TreeViews OnButtonPressEvent function
                // to make sure everything else works as normal
                return base.OnButtonPressEvent(evnt);
        }
}

Notes I found in Monodoc:

  • TreePath represents a particular node of a TreeView
  • The TreeIter is the primary structure for accessing a tree row.

Whatever that means :)

XSLT: Search replace attribute values

Yesterday I needed an xsl transformation which could replace a specific attribute value in a xml file and keep the rest intact. The following code is put together by pieces I found around the net (copy-paste FTW :) ):

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:param name="attribute"/>
    <xsl:param name="oldvalue"/>
    <xsl:param name="newvalue"/>

    <xsl:template match="node()|@*">
    <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
    </xsl:template>

    <!-- This is a generic search replace of attribute values -->
    <xsl:template match="@*" priority="10">
        <xsl:attribute name="{name()}">
            <xsl:choose>
                <xsl:when test="(name()=$attribute) and (. = $oldvalue)"><xsl:value-of select="$newvalue"/></xsl:when>
                <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
            </xsl:choose>
        </xsl:attribute>
    </xsl:template>
</xsl:stylesheet>

Lets say that the above code is saved in a file called attribute_replace.xslt. Now with xsltproc you would be able to replace the vaule 5011 with 5015 in all attributes called port:

xsltproc --stringparam attribute port --stringparam oldvalue 5011 --stringparam newvalue 5015 attribute_replace.xslt server_config.xml > new_server_config.xml

I used this to manupulate with some JBoss configuration files.