Presentation is loading. Please wait.

Presentation is loading. Please wait.

Linux Jukebox Project Presented by: Andrew Dumitrascu Murray Saul.

Similar presentations

Presentation on theme: "Linux Jukebox Project Presented by: Andrew Dumitrascu Murray Saul."— Presentation transcript:

1 Linux Jukebox Project Presented by: Andrew Dumitrascu Murray Saul

2 Linux Jukebox Project  Background: Faculty member purchased wall-mount jukebox 20 years ago. The wall-mount jukebox was popular in restaurants in the 50s, 60s and 70s. The device is a remote-control device to select songs to be played on a remote record player or centralized computer.

3 Linux Jukebox Project  Objective: Connect Jukebox to CPU to play MP3s or other types of audio files… There is a commercial solution in the U.S. which costs $129 (US) for the appropriate “black-box” converter and software (MS-Windows only). Linux club wanted to see if they could provide an open source solution using Linux OS without using a “black-box” (e.g. serial cable connection).

4 Linux Jukebox Project  Required: Wall-mount Jukebox (AMI W-120) CPU with soundcard running Linux OS Serial cable Power transformer for Wall-mount jukebox Wall-mount jukebox manual (obtained over the Internet) Drill to “drill-out” lock … it didn’t come with a key!

5 Linux Jukebox Project  How a Wall-mount Jukebox Works:  According to AMI W-120 manual: Wall-mount jukebox sends out a series of low- voltage direct current pulses to a receiver (e.g. central player or central computer). The number and spacing between these pulses are determined by what selections are made by user (i.e. which buttons were pressed).

6 Linux Jukebox Project  The Solution: 1. Connect portion of serial cable to send electronic pulses to CPU 2. Write a bash-shell script to: Record the timings of the pulses and store in a file. Calculate the difference in the pulses Access another file and parse song information regarding the pulse timing difference (train info) and add song’s pathname to a song file. Run an MP3 player to play MP3s that are queued in the song file. Continually check every 5 seconds to see if any songs are queued for playing

7 Linux Jukebox Project  Files: rawrite Contains the timing of the first and second train. Train data in this file will be used to help determine which selection was made. Actually, 2 series of pulses are sent to CPU. The differences in these times provide information for a song sequence (referred to as a train)

8 Linux Jukebox Project  Files:  1 Train1:2 Train2:1 01-Meng_Tian.mp3  2 Train1:2 Train2:2 01_-_Fatboy_Slim_-_Don't_Let_The_Man.mp3  3 Train1:2 Train2:3 01_-_Tangerine_Dream_-_Prime_Time.mp3  4 Train1:2 Train2:4 02-Summer_in_Shauxi.mp3  5 Train1:2 Train2:5 01_Engelbert_Humperdinck_-_Release_Me.mp3 songs Contains information regarding the trains, and MP3 filename to be parsed and played when train is determined Train information is associated with a particular MP3 file…

9 Linux Jukebox Project  Files:  Meng_Tian.mp3  Fatboy_Slim_-_Don't_Let_The_Man.mp3  Tangerine_Dream_-_Prime_Time.mp3  02-Summer_in_Shauxi.mp3  01_Engelbert_Humperdinck_-_Release_Me.mp3 queue Contains pathnames to songs that MP3 player has been configured to read from…

10 Linux Jukebox Project Shell Script (Part I): Setup & Declare functions stty -clocal time=$(date +%s.%N) train=0 #Start the player to look for songs in the queue /root/jukebox/playmusic & CID=$! trap "kill -9 $CID; exit 0" INT #Put the time into a temporary file to be retrieved later... capture() { echo "Starting step 1...." /root/jukebox/step1 > /tmp/rawtime & echo "End step " }

11 Linux Jukebox Project Shell Script (Part II): Record Timed Pulses #Start an infinite loop while [ true ] do train=0 pulse1=1 pulse2=1 #Call the capture function to capture the incoming electrical pulses capture < /dev/ttyS0 #Sleep for 2.5 seconds to avoid accidentally capturing a final pulse #that sometimes get sent at the end. # usleep sleep 5 #End the pulse capture program killall step1

12 Linux Jukebox Project Shell Script (Part III): Calculate the “Trains” #Start the time processing to calculate the number of pulses sent. for input in $(cat /tmp/rawtime) do diff=$(echo "$input $time" | awk '{print int(($1-$2)*1000)}') echo $diff if [ $diff -gt 100 ] then train=$((train+1)) elif [ $diff -gt 20 ] then if [ $train -eq 1 ] then pulse1=$((pulse1+1)) else pulse2=$((pulse2+1)) fi time=$input done

13 Linux Jukebox Project Shell Script (Part IV): Play MP3 Song song=$(grep "Train1:$pulse1 Train2:$pulse2 " /root/jukebox/songs | awk -F' ' '{print $4}') if [ "$song" != "" ] then echo $song >> /tmp/queue fi Done # End of while loop # End of shell script

14 Linux Jukebox Project  Questions?

Download ppt "Linux Jukebox Project Presented by: Andrew Dumitrascu Murray Saul."

Similar presentations

Ads by Google