User Tools

Site Tools


projects:music_station

Music Station (Linuxeyes)

Hi, I'm Alex, one of the fonders of Wyliodrin. This project is very important to me, as this is how I learned both Linux and C/C++. If you can get through reading it, you will see that it is written rather like a blog, than a project tutorial.

Let's go back

The project I want to share with you started somewhere back in 2000. I was still in high school and I heard about a really nice operating system called Linux, which does not crash every time you want to do something more complicated. So, I asked a friend to help me and I installed Linux on my computer.

After waiting for some hours, I finally had a RedHat Linux 6.0 installed. I remember it was called Hedwig - not to be confused with RedHat Enterprise Linux 6, we are talking about the year 2000. The install system looked like the one in the picture above.

Having Linux installed, I started playing with it, or better said wondering what I should do with it. The system started in command line with the login prompt. Nowadays, one should press CTRL+ALT+F1 to get the same effect. In order to start the graphical interface (Windows similar stuff as it was called back then), you should type

startx 

.

After waiting some time, you would get a user interface similar to the one in the picture below. This was GNOME 1.2 or similar. Still I was very happy about it, especially because I had something different from all the others. I remember all my friends coming over would ask me what system it was.

I was used to listening to music, so the first thing I did was ask whether there was Winamp for Linux. Surprisingly, there was: XMMS. It was 100% Winamp, same skins, same plugin system. Only one problem … it worked really slow (I had a 600 MHz CPU).

Next, I started wondering if I could do some programming on Linux. As no IDE was available in the graphical interface, I used Midnight Commander's 1) editor to code (mcedit). I know, vim and emacs were available, but they seemed so hard at that time. So here comes my issue: I wanted to listen to music while programming. And I could, but I always had to switch between the graphical user interface and text mode to switch the songs.

As no player in text mode player was available (except mpg123, but no user interface, just command line), I decided to write my own. I had no idea on how to do it (I was programming in Delphi at the moment), I started learning C/C++ while writing the player.

So this is how LinuxEyes began. You could ask: what about the name? If you look at the picture above, you will see a set of eyes looking a the mouse. This software is available on Windows, as well. I started working on my first Delphi project by doing something similar, called WinEyes, and eventually adding so many features to it that it became an mp3 player. The Linux version was called the same.

Here are some of the features that I added over time and seem hilarious:

  • I always wanted to have the possibility to select the next song to be played and Winamp did not have this option, so I implemented it;
  • As selecting the next song was not enough, I made it possible to select a next songs list;
  • I used a JazzPiper MCD 650s mp3 player, but the problem whas that it only displayed the song number and it was annoying to search a song. I implemented a function that would read a CD in the exact same way as the player and display the number and the title for each song
  • Using the player at parties was really nice, as nobody would know how to use it (Linux) and people did not fight for changing the songs. Still, people learn fast and after a some parties, they figured it out. So I made a password protection function
  • New Year's Eve parties are all about midnight, so I programmed a screen saver to show the clock on the screen

As Linux became more popular and its graphical user interfaces improved, there was no need for my player anymore. All this changed when I found out about the Raspberry Pi. Somehow this small computer reminded me of the first time I used Linux. It brought back the Linux I knew. I realised that I can use my player on it.

I modified it to work with Raspbian 2) and uploaded the code on GitHub 3).

What you need?

To install Linuxeyes on the Raspberry Pi, we will need:

  • a Raspberry Pi Model B board 4)
  • 10 LEDs (optional)
  • 10 ~200 Ohm resistors (optional)
  • 11 jumper wires (optional)

Installing

Linuxeyes is build using the ncurses libraries 5). These are usually not installed by default on the Wyliodrin Raspberry Pi SD Card Image (or Raspbian). In order to install them, you will need to run a shell.

  1. If you use Wyliodrin,
    1. go to your Wyliodrin dashboard
    2. click on the wheel next to your board (on the right) and a menu will appear
    3. click Shell
  2. otherwise just login on your Pi

In the shell, we will use apt-get to install the libraries

sudo apt-get install libncurses5-dev 

if asked to confirm the installation, press y and ENTER.

If you are not using the Wyliodrin Raspberry Pi SD Card Image, you probably will need to install the following libraries

sudo apt-get install g++ make git fpc 

fpc - Free Pascal Compiler is needed for help compilation. With small modifications to the Makefile, you can leave it out.

Next we will have to download Linuxeyes from git.

git clone https://github.com/alexandruradovici/linuxeyes.git 

Once downloaded, you will need to compile it.

cd linuxeyes 
make 

Putting music

The Raspberry Pi works from an SD card, so you cannot store a lot of music on it. The easiest way to access music is to mount an external hard drive. Let's see how you can do this.

The Raspberry Pi has not enough power to supply to the external hard drive. Please use a drive that is powered separately. You should have a drive that has another power cable connected to it, besides the USB one. You may also use a powered USB hub.

  1. Power off the board.
  2. Connect the hard drive to it and power it on again.
  3. Open a shell to the board and mount the drive

Mounting a drive can be done using udisks. First of all, you need to list all the disks.

udisks --enumerate-device-files 

You should see something like this

 
/dev/mmcblk0p2  
/dev/disk/by-id/memstick-SA04G_0x4248601a-part2   
/dev/disk/by-uuid/af599925-1134-4b6e-8883-fb6a99cd58f1  
/dev/sda 
/dev/sda1 
/dev/sda2 
/dev/mmcblk0  
/dev/disk/by-id/memstick-SA04G_0x4248601a  
/dev/mmcblk0p1  
/dev/disk/by-id/memstick-SA04G_0x4248601a-part1  
/dev/disk/by-uuid/056E-4E83 

Usually the hard drives are the ones with /dev/sdXN where X is a letter and N is a number. In my example, I have one hard drive /dev/sda that has two partitions: 1 (/dev/sda1) and 2 (/dev/sda2). I will mount the first partition.

udisks --mount /dev/sda1 

This command will take some time and might fail the first time. Just type it again. When completed, it will print the location of the mount.

Running

Once compiled, running Linuxeyes is easy, just type

make play 

You should now see the user interface with an empty playlist. In order to use it, please read linuxeyes keys help.

LEDs VU Meter

One of the modifications that I have made to Linuxeyes for the Raspberry Pi is a LEDs vumeter. This uses 10 LEDs to display the average of the music levels. My example uses 10 LEDs: 5 green, 3 yellow and 2 red.

Wiring it up

This is the schematics for wiring up the cables. I have connected a black wire from the ground pin to the blue line of the breadboard. This means that all the holes along the blue line will be connected to the ground.

Next, I placed the 10 LEDs on the breadboard and connected a 220 Ohm resistor between each LED's cathode (-) and the blue line. This way, all the cathodes will be connected through a resistor to the ground.

Each LED will be controlled by a separate pin on the Raspberry Pi. I wired each anode (+) of the LEDs to the pins 0 thorough 9 in such a way that the green LEDs are connected to the pins 0-4, the yellow ones to the pins 5-7 and the red ones to pins 8 and 9. Please take a look at the pins numbering for the Raspberry Pi.

Running

Running linuxeyes with the VU meter is by typing

make playvumeterleds 

This uses the wiringPi library to access Raspberry Pi GPIO pins that requires root access. make playvumeter leds will run linuxeyes as root.

You can change the number of LEDs by changing the Makefile variable LEDS. Open Makefile and change the playvumeterleds rule.

SDK_LIB=library 
SDK_INC=include 
 
CC                 = g++ -g -Wno-deprecated -w 
LIBRARIES        = -L$(SDK_LIB) -lcurses -lpthread -ldl -lz -lbass -lwiringPi 
INCLUDES        = -I$(SDK_INC) 
 
xmp: xmp.cpp inc/*.cpp inc/help/*.cpp generators/*.pas generators/help.le generators/le_data.build 
        ./generators/le_ver 
        ./generators/le_help 
        $(CC) $< $(INCLUDES) $(LIBRARIES) -o $@ 
 
play: 
        LD_LIBRARY_PATH=. ./xmp 
 
playvumeterleds: 
        sudo LD_LIBRARY_PATH=. VUMETER=LEDS LEDS=10 ./xmp 
 

Disco Lights

Another modification that I have made to Linuxeyes for the Raspberry Pi is a a disco light. This uses an RGB LED to produce light upon the music.

Wiring it up

This is the schematics for wiring up the cables. I have connected a black wire from the ground pin to the blue line of the breadboard. This means that all the holes along the blue line will be connected to the ground.

Next, I have placed an RGB LED on the bread board. The LED is in fact build out of 3 LEDS and has 4 legs. One is the common cathode (-) and the other for are each of the LED's anodes(+). The order in the drawing is red, cathode, green, blue.

The cathode of the LED is connected to the blue line of the breadboard, that in turn is connected to board's ground.

The red, green and blue legs of the LED are connected through an 220 Ohm resistor to the pins 0, 1, 2 of the Raspberry Pi.

Running

Running linuxeyes with the Disco Lights is by typing

make playvumeterrgb 

This uses the wiringPi library to access Raspberry Pi GPIO pins that requires root access. make playvumeter rgb will run linuxeyes as root.

You can change the pins for the RGB LED using the Makefile RGB_LED variable. It signifies the first leg of the RGB LED. Open Makefile and change the playvumeterledrgb rule.

SDK_LIB=library 
SDK_INC=include 
 
CC                 = g++ -g -Wno-deprecated -w 
LIBRARIES        = -L$(SDK_LIB) -lcurses -lpthread -ldl -lz -lbass -lwiringPi 
INCLUDES        = -I$(SDK_INC) 
 
xmp: xmp.cpp inc/*.cpp inc/help/*.cpp generators/*.pas generators/help.le generators/le_data.build 
        ./generators/le_ver 
        ./generators/le_help 
        $(CC) $< $(INCLUDES) $(LIBRARIES) -o $@ 
 
play: 
        LD_LIBRARY_PATH=. ./xmp 
 
playvumeterrgb: 
        sudo LD_LIBRARY_PATH=. VUMETER=LED_RGB LED_RGB=0 ./xmp

LEDs and Disco Lights

You can have the VU meter and the disco lights together by using the setup.

Wiring it up

Running

Running linuxeyes with the VU meter and disco lights is by typing

make playvumeter 

This uses the wiringPi library to access Raspberry Pi GPIO pins that requires root access. make playvumeter will run linuxeyes as root.

You can change the number of LEDs and RGB LED legs by changing the Makefile variables LEDS and LED_RGB. Open Makefile and change the playvumeterleds rule.

SDK_LIB=library 
SDK_INC=include 
 
CC                 = g++ -g -Wno-deprecated -w 
LIBRARIES        = -L$(SDK_LIB) -lcurses -lpthread -ldl -lz -lbass -lwiringPi 
INCLUDES        = -I$(SDK_INC) 
 
xmp: xmp.cpp inc/*.cpp inc/help/*.cpp generators/*.pas generators/help.le generators/le_data.build 
        ./generators/le_ver 
        ./generators/le_help 
        $(CC) $< $(INCLUDES) $(LIBRARIES) -o $@ 
 
play: 
        LD_LIBRARY_PATH=. ./xmp 
 
playvumeter: 
        sudo LD_LIBRARY_PATH=. VUMETER=LEDS_RGB_LED LEDS=10 RGB_LED=10 ./xmp 
 

Keys

Even if the software has a user interface, you still need to know the keys. The help menu is available by pressing the h letter on the keyboard. You have here a listing of all the keys necessary.

 
COMMAND LINE 
 -p           : play 
 --colors     : force color usage 
 --nocolors   : B&W, for dummy terminals (telnet) 
 --autoscr    : force autodetect the screen's size 
 --noautoscr  : don't autodetect the screen's size 
 --fakelines  : draw lines on terminals without ACS 
 --new_start  : start with default configuration 
 --debug      : show debug (not for users) 

PLAYER 
 z            : previous 
 x            : play 
 c            : pause 
 v            : stop 
 b            : next 
 Z            : previous in playlist 
 B            : next in playlist 
 s            : Shuffle On/Off 
 <ENTER>      : Play  
 <SPACE BAR>  : Set As Next  
 <TAB>        : Add/Remove to/from filter  
 <LEFT>       : Backward 1% 
 <RIGHT>      : Forward 1% 
 <            : Backward 5% 
 >            : Forward 5% 
 f            : Filter Options 
 f,c          : Clear Filter 
 f,p          : On/Off persistent filter 
 f,a          : Add filter (load, don't delete old) 
 f,l          : Load filter (delete old) 
 f,s          : Save filter 
 r            : Repreat current song  
 i or ALT+3   : ID3v1.1 TAG Editor (for selected song) 
 I            : ID3v1.1 TAG Editor (for current song) 
 j or F3      : Jump to file 
 m            : Quick Message 
 M            : Messages List 
 <INSERT>     : Volume +  
 <DELETE>     : Volume -  
 <HOME>       : PCM +  
 <END>        : PCM -  
 ,            : Balance left  
 .            : Balance right  
 e            : Equalizer 
 A            : Automatic Equalizer On/Off 
 '            : Repaint Desktop 
 *            : Increase desktop width 
 /            : Decrease desktop width 
 +            : Increase desktop height 
 -            : Decrease desktop height 
 @            : Full Screen Desktop 
 t            : Switch clock display mode 
 \\            : Change Password 
 !            : Lock Display 
 =            : Cycle Status Bar Modes 
 h or F1      : Help 
 F2           : What's New 
 ?            : About and Statistics 
 {            : Set Alarm On Time 
 }            : Set Alarm Off Time 
 T            : Set Sleep mode 
 |            : On/Off Shut Down mode 
 o            : Settings 
 ESC          : Screen Saver 
 ALT+Q or Q   : Quit 

PLAYLIST 
 a            : Add File 
 d            : Delete File 
 D            : Add Directory 
 R            : Delete All 
 S            : Sort Playlist 
 <UP>         : Cursor Up 
 <DOWN>       : Cursor Down 
 <PAGE UP>    : Page Up 
 <PAGE DOWN>  : Page Down 
 0..9         : Fast Scroll 
 [            : Move Up 
 '            : Move Down 
 l            : Locate Current Song 
 L            : Autolocate Current Song 
 p            : Playlist Options 
 p,n          : New Playlist 
 p,l          : Load Playlist 
 p,s          : Save Playlist 
 p,i          : Import Playlist 
 p,e          : Export Playlist 
 E            : Edit playlist file entry 
 n            : Refresh list 
 ;            : On/Off save playlist position on exit 

JUMP TO FILE 
 <ENTER>      : Play 
 <SPACE BAR>  : Set as next 
 <TAB>        : Add/Remove to/from filter 
 F            : Add/Remove all songs to filter 
 i            : ID3 TAG Edditor 
 ESC or q     : Close window 

EQUALIZER WINDOW 
 <PAGE UP>    : Up ALL 
 <PAGE DOWN>  : Down ALL 
 a/z          : Up/Down Band #1 
 s/x          : Up/Down Band #2 
 d/c          : Up/Down Band #3 
 f/v          : Up/Down Band #4 
 g/b          : Up/Down Band #5 
 h/n          : Up/Down Band #6 
 j/m          : Up/Down Band #7 
 k/,          : Up/Down Band #8 
 l/.          : Up/Down Band #9 
 ;//          : Up/Down Band #10 
 r            : Set all bands to 0 (reset equalizer) 
 L            : Load Preset 
 S            : Save Preset 
 I            : Import Preset(s) 
 D            : Delete Preset(s) 
 A            : On/Off Automatic Equalizer 
  
FILE DIALOG 
 <Up>         : Move Up 
 <Down>       : Move Down 
 <Left>       : Backward 1% 
 <Right>      : Forward 1% 
 <PgUp>       : Page Up 
 <PgDn>       : Page Down 
 <            : Backward 5% 
 >            : Forward 5% 
 <ENTER>      : End Selection (Open) 
 <SPACE BAR>  : Select 
 <TAB>        : Play 
 ALT+<SPACE>  : Set As Next 
 z            : previous 
 x            : play 
 c            : pause 
 v            : stop 
 b            : next 
 i or ALT+3   : ID3v1.1 Tag Editor 
 ALT + _      : Goto a _*.mp3 file (_:[A..Z,a..z]) 
 ESC or q     : Close Dialog 

ID3 TAG EDITOR 
 Load +       : Load Settings from ID3+ Info 
 Save +       : Save Settings to ID3+ Info 
                * Save + won't have any effect 
                  if you close the dialog with 
                  the ESC key. 
 <Enter>      : Close and Save Information 
 <ESC>        : Close, don't save 

MESSAGES LIST 
 <INSERT>     : Add a message 
 <DELETE>     : Delete selected message 
 <TAB>        : Edit selected message 
 L            : Load messages form a file 
 S            : Save messages to a file 
 <ENTER>      : Close and Save 
 <ESC>        : Close, don't save 

STATISTICS 
 R            : Reset current session statistics 

SPECIAL FUNCTIONS 
 P            : Make playlist for MP3 CD Player 
                * The player will ask you for the CD 
                  mount path (usualy /mnt/cdrom) 
                * A list with the files on that CD 
                  will be displayed. 
                * Press <ENTER> to save the list. 
                * Tested on JazzPIPER MCD650S 

PLAYER MODES 
 Normal       : Next song in playlist (don\'t shuffle) 
 Shuffle      : Random next song (shuffle) 
 Next Song    : Next song is already selected 
 Filter       : There are files in the filter 
 P-Filter     : The filter is persistent 
 Password     : Display is locked with password 
 Sleep        : Shut Down at a specific time 
 Shut Down    : Shut Down after current song 

STATUS BAR 
 Mode 1       : Displays mode, vol, pcm, bal & flags 
 Mode 2       : Displays next song's name 
 Mode 3       : Displays nr of files in filter 
 Mode 4       : Displays alram start & stop time 
 Mode 5       : Displays shut down time 
 Flags   S - save playlist on exit 
         E - auto equalizer 
         L - autolocate current song 
         P - use persistent filter 
         A - Alarm is set 
         + - Use ID3 Plus Information 

SONG DISPLAY FORMAT 
 %1 or %t     : Track Number 
 %2 or %a     : Artist 
 %3 or %s     : Song 
 %4 or %A     : Album 
 %5 or %y     : Year 
 %6 or %g     : Genre 
 %7 or %c     : Comment 
 %8 or %f     : File Name 
projects/music_station.txt · Last modified: 2014/01/29 22:27 by alexandru.radovici