Linux Jukebox Project Presented by Andrew Dumitrascu Murray
Linux Jukebox Project Presented by: Andrew Dumitrascu Murray Saul
Linux Jukebox Project Background: n n n Faculty member purchased wall-mount jukebox 20 years ago. The wall-mount jukebox was popular in restaurants in the 50 s, 60 s and 70 s. The device is a remote-control device to select songs to be played on a remote record player or centralized computer.
Linux Jukebox Project Objective: n n n Connect Jukebox to CPU to play MP 3 s 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).
Linux Jukebox Project Required: n n n Wall-mount Jukebox (AMI W-120) CPU with soundcard running Linux OS Serial cable Power transformer for Wall-mount jukebox manual (obtained over the Internet) Drill to “drill-out” lock … it didn’t come with a key!
Linux Jukebox Project How a Wall-mount Jukebox Works: According to AMI W-120 manual: n n Wall-mount jukebox sends out a series of lowvoltage 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).
Linux Jukebox Project The Solution: 1. 2. Connect portion of serial cable to send electronic pulses to CPU Write a bash-shell script to: n n 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 MP 3 player to play MP 3 s that are queued in the song file. Continually check every 5 seconds to see if any songs are queued for playing
Linux Jukebox Project Files: rawrite 1097186586. 976415000 1097186587. 049701000 1097186587. 119054000 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) 1097186587. 190131000 1097186587. 259130000 1097186587. 332167000 1097186587. 408929000 1097186587. 568426000 1097186587. 640651000 Contains the timing of the first and second train. Train data in this file will be used to help determine which selection was made.
Linux Jukebox Project Files: songs 1 Train 1: 2 Train 2: 1 2 Train 1: 2 Train 2: 2 3 Train 1: 2 Train 2: 3 4 Train 1: 2 Train 2: 4 5 Train 1: 2 Train 2: 5 Contains information regarding the trains, and MP 3 filename to be parsed and played when train is determined 01 -Meng_Tian. mp 3 01_-_Fatboy_Slim_-_Don't_Let_The_Man. mp 3 01_-_Tangerine_Dream_-_Prime_Time. mp 3 02 -Summer_in_Shauxi. mp 3 01_Engelbert_Humperdinck_-_Release_Me. mp 3 Train information is associated with a particular MP 3 file…
Linux Jukebox Project Files: queue Meng_Tian. mp 3 Fatboy_Slim_-_Don't_Let_The_Man. mp 3 Tangerine_Dream_-_Prime_Time. mp 3 02 -Summer_in_Shauxi. mp 3 01_Engelbert_Humperdinck_-_Release_Me. mp 3 Contains pathnames to songs that MP 3 player has been configured to read from…
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/step 1 > /tmp/rawtime & echo "End step 1. . . " }
Linux Jukebox Project Shell Script (Part II): Record Timed Pulses #Start an infinite loop while [ true ] do train=0 pulse 1=1 pulse 2=1 #Call the capture function to capture the incoming electrical pulses capture < /dev/tty. S 0 #Sleep for 2. 5 seconds to avoid accidentally capturing a final pulse #that sometimes get sent at the end. # usleep 2100000 sleep 5 #End the pulse capture program killall step 1
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 pulse 1=$((pulse 1+1)) else pulse 2=$((pulse 2+1)) fi fi time=$input done
Linux Jukebox Project Shell Script (Part IV): Play MP 3 Song song=$(grep "Train 1: $pulse 1 Train 2: $pulse 2 " /root/jukebox/songs | awk -F' ' '{print $4}') if [ "$song" != "" ] then echo $song >> /tmp/queue fi Done # End of while loop # End of shell script
Linux Jukebox Project Questions?
- Slides: 14