YJ Park's profileYJParkPhotosBlogListsMore Tools Help

Blog


    9/21/2006

    Use Mpd to Stream Music as Internet Radio

    Mpd can work with icecast for streaming music, but the current statble version doesn't include this feature yet, so you have to check out the latest code from svn, here are the commands I used to build it.

    sudo apt-get install icecast2
    sudo apt-get install autoconf automake1.9 libtool make
    sudo apt-get install libshout3-dev liblame-dev libmad0-dev libao-dev libflac-dev libasound2-dev
    svn co https://svn.musicpd.org/mpd/trunk mpd
    cd mpd
    ./autogen.sh
    ./configure
    #make sure the shout is enable
    make
    sudo make install

    Or if you are lazy can download the binary I built, but make sure to install the needed libs

    wget http://yjpark.googlepages.com/mpd
    sudo mv mpd /usr/bin

    In your mpd configuration (/etc/mpd.conf or ~/.mpdconf), add these lines

    audio_output {
            type              "alsa"
            name              "local playback"
    }

    ################# SHOUT STREAMING ########################
    #
    # Set this to allow mpd to stream its output to icecast2
    # (i.e. mpd is a icecast2 source)
    #
    audio_output {
            type              "shout"
            name              "yjpark's stream"
            host              "localhost"
            port              "8000"
            mount             "/yjpark"
            password          "******"
            quality           "10.0"  
    #       bitrate           "64"
            format            "44100:16:2"

    # Optional Paramters
            user            "source"
    #       description     "here's my long description"
    #       genre           "jazz"
    } # end of audio_output
    ##########################################################

    If you don't want to hear the music from the computer's local speaker, can remove the first audio_output section.

    You need to change the name and mount point and password, and can change the quality or bitrate and format if you want, for more detail please check icecast2's documents.

    And you need to edit /etc/icecast2/icecast.xml, the only things I changed are source-password(same as the one in mpd configuration), and admin-user, admin-password(can use this to admin through web interface)

    then restart icecast2 and mpd, play some songs, then you can use a browser to connect to http://localhost:8000, you should see the source played by mpd, then can listen to it using an radio player(amarok, rhythembox, xmms...)

    For the guys in ExoWeb, you can listen to the same songs I am listenning with http://yjpark:8000/yjpark.m3u (Hope this will not slow down my machine too bad :) )

    Links:

        * http://my.opera.com/chongmeng/blog/show.dml/362421
        * http://mpd.wikia.com/wiki/Configuration
        * http://etnoy.broach.se/2006/06/your-own-internet-radio-station-with-mpdicecast.html

    Fix on ncmpc to make chinese display working

    Ncmpc is a command line mpd client, it's very good, but the chinese support has some problem, in the song list window, chinese names are truncated.

    At first I thought might be some unicode bug in it, after read some source code, here is what I found: it deal with unicode correctly, the problem is it didn't consider the wide-charactors like chinese charactors, so in the list window, it just show the correct chinese charactors then erase some of them later. change two lines this is ok.

    the patch is

    Index: src/list_window.c
    ===================================================================
    --- src/list_window.c (revision 4813)
    +++ src/list_window.c (working copy)
    @@ -203,10 +203,10 @@
    if( show_cursor && selected )
    wattron(lw->w, A_REVERSE);

    + if( fill )
    + mvwhline(lw->w, i, 0, ' ', lw->cols);
    //waddnstr(lw->w, label, lw->cols);
    waddstr(lw->w, label);
    - if( fill && len<lw->cols )
    - mvwhline(lw->w, i, len, ' ', lw->cols-len);

    if( selected )
    wattroff(lw->w, A_REVERSE);

    Using the following commands, you can build ncmpc automatically.

    sudo apt-get install build-essential
    svn checkout https://svn.musicpd.org/ncmpc/trunk@4813 ncmpc
    cd ncmpc
    wget http://yjpark.googlepages.com/ncmpc_chinese_patch
    patch -p0 < ncmpc_chinese_patch
    ./autogen.sh
    ./configure --enable-artist-screen
    make
    sudo cp src/ncmpc /usr/bin/

    Or if you are lazy, can just download the binary I build and try it

    wget http://yjpark.googlepages.com/ncmpc
    sudo mv ncmpc /usr/bin/


    Can edit ~/.ncmpc/config to setup ncmpc, here is my settings

    auto-center = yes
    wide-cursor = yes
    enable-colors = yes

    set-xterm-title = yes
    xterm-title-format = "[[%artist% - ]%title%]|[%file%]"


    And if you want to run ncmpc in real console(not gnome-terminal or xterm), you can use zhcon(just apt-get), I cannot run zhcon with fb driver, here is how I start it

    zhcon --utf8 --drv=vga

    the --utf8 is needed for ncmpc to working correctly, and you can edit .zhconrc to change defaultencoding to GBK for better compatibility.

    It's still not perfectly running ncmpc in zhcon, especially there are some bad encoding strings in your songs' tags.

    Using mpd to play music

    Lately I moved to use mpd for my music playing, mpd is "Music Player Daemon", as its name says, it's a daemon to play music, not like amarok or rhythembox, it do not need X windows at all, so the music will not stop even if you restart X, this is one advantage of it, others includes multiple clients to control it, from command line tools, scriptable tool, web pages, X clients; very easy remote control; low resource requirement. And it's easy to stream as internet radio(will talk about this later in another post)

    mpd's website: http://www.musicpd.org/ there you can find kinds of clients for it, Personally I like ncmpc and pympd(not listed there) most, ncmpc base on ncurses lib, so console base, it's very easy to use with keyboard. pymod is a python client looks like rhythembox.

    To install mpd, under Debian or Ubuntu

    sudo apt-get install mpd

    ncmpc is in both Debian and Ubuntu too, but pympd is not avaliable to Ubuntu yet, you can install it by

    sudo apt-get install python2.4-profiler build-essential
    wget http://jaist.dl.sourceforge.net/sourceforge/pympd/pympd-0.07.tar.gz
    tar xzvf pympd-0.07.tar.gz
    cd pympd-0.07
    make
    sudo make install

    Ncmpc does not support chinese well, it support unicode, but for chinese like double byte, it will not show the song list correctly, some part is cutted, after some research in ncmpc source code, I finally resolve this problem. (Again, will talk about this in another post)
    9/15/2006

    Install Internet Explorer on Linux for Testing

    We need to test our site under Internet Explorer, to me this is the only reason I need to install vmplayer on my Debian machine, it works fine, but a little bit slow and complicate, the Wine project is used to provide windows api on linux, so it's possible to use it to run IE without a virtual machine, but the setup is not very easy for it, I did try once, didn't get it.

    Recently I know that there is an open source project for this, the name is ies4linux. It's objective is download IE's installer and setup wine then install it automatically for you, it works great, The only problem I met is the download process is not very reliable, I need to run it several times to get it installed successfully, so I include the files I downloaded, it only has IE6 in it, if you want to install other version, you need to download them by yourself.

    For the ExoMates with exosetup installed, you can do:

    exosetup import nordicbet
    cd /tmp
    sudo exosetup install nordicbet-ie

    If you do not have exosetup, you can just run the following scripts:

    apt-get install wine cabextract
    mkdir ~/.ies4linux
    cd ~/.ies4linux
    wget -nd -N -r http://exobox.lan.exoweb.net/~yjpark/exosetup/nordicbet/ie/downloads.tar.gz
    tar xzvf downloads.tar.gz
    rm downloads.tar.gz
    cd /tmp
    wget -nd -N -r http://exobox.lan.exoweb.net/~yjpark/exosetup/nordicbet/ie/ies4linux-2.0.3.tar.gz
    tar xzvf ies4linux-2.0.3.tar.gz
    cd ies4linux-2.0.3
    ./ies4linux

    ies4linux: http://www.tatanka.com.br/ies4linux/index-en.html
    6/9/2006

    Use kdesvn for Easier svn Browsing

    svn is very easy to use, but if you want to browse the files in it, and tired of typing commands, you can use some gui svn tools for it.
    I tried esvn and kdesvn, think kdesvn is very useful, and it can use kompare to show the diff.

    If you are using debian, just 'apt-get install kdesvn'

    Tip: 'diff revisions' is under 'Subversion' -> 'General', and its result depends on the current selected files/folders, so if you want to see the whole diff, you need to select the root folder or just select nothing

    5/16/2006

    Use Kompare for Better Format Diff

    As a programmer, diff is an everyday tool for me, but the text only output of diff is quite hard to read, comparing to Trac's colorful source browser.
    Spend little time to try some graphic diff tools, I like kompare most, it's very easy to use, and the output is very nice.
    You can just 'apt-get install kompare' if you're under Debian.
    Tip: for use it with svn, you can do 'svn diff | kompare -'
    4/27/2006

    Debian Testing Upgrade Problem

    Today I did a apt-get upgrade, everything goes well, but when I try to reboot, it just stuck, waiting for mounting root filesystem for ever.
    It's good that I have a system rescue cd with me, seems the file system is very well, not know what's wrong, but after restore my /boot folder, it just works fine again.
    4/3/2006

    Remotely Running X Program

    For thost that don't know that yet.
    If you want to remotely run a x program, it's very easy and secure with ssh.
    run 'ssh -X user@host' in xterm or gnome-terminal, that's all, then you can start program in it, the window will just pop up to your screen.

    3/30/2006

    Access Samba Network Under Gnome

    I am using Debian testing now, after the default installation, the smb:// is not working in nautilus, there are two packages need to be installed
    apt-get install gnome-vfs-extfs libgnomevfs2-extra
    After that, the samba access in nautilus just works fine for me.
    3/29/2006

    Setup ssh to use public key authentication (without input password)

    Under Linux, we use ssh and scp a lot, just tired of input password all the time, I know there is some way to do it, but always too lasy to check it out.

    Thanks Vincent for telling me how to do this. I think most of you should already know how to do it, if you still type in password all the time, this is very simple and useful.

    First you need to generate a public/private key pair to identify yourself, use 'ssh-keygen -t dsa'

    Then you need to add the generated public key to the remote host, here is how I do it

    At Local Machine

    scp id_dsa.pub yjpark@exobox:
    ssh-add
    
    At Remote Machine:
    mkdir .ssh
    chmod 600 .ssh
    cd .ssh
    cat ../id_dsa.pub >> authorized_keys
    chmod 600 authorized_keys
    

    That's all

    make sure that .ssh and authorized_keys is not accessed by anyone except the owner, otherwise it will not work

    How to setup window's background color under Gnome

    In current version of gnome, there is no tools for setting up background color of window, it's background setting only change desktop's background.

    I really don't like white background, I want the background gray, so I setup some applications's background manually, but some application do not have background color setting(e.g. some versions of Eclipse), and it's not a good way to do that, so I spent little time on it.

    First I tried some themes, some of them has gray background, while I don't like there colors setting, so what I need to do is to modify some themes to fit my requirement.

    In gnome's theme setting -> Theme Details, you can choose different setting of Controls, window Border or Icons, window's background belongs to Controls, I picked up !LighthouseBlue as a base setting.


    The themes file are under /usr/share/themes, I only modified gtk-2.0/gtkrc

    bg[NORMAL]       = "#D0D0D0"	//background color of window
    base[NORMAL]     = "#CCCCC0"	//background color or controls
    

    That make me quite happy. I didn't find good tool for editing theme, there is a definition of the values