Difference between revisions of "ECE497 Project Music Server"

From eLinux.org
Jump to: navigation, search
m
(done with theory of operation)
(22 intermediate revisions by 3 users not shown)
Line 11: Line 11:
  
 
<pre style="color:red">
 
<pre style="color:red">
00 Executive Summary
+
09 Executive Summary - Watch the 'tense'.  "which will be playable" vs. "which is playable". (See my "Cleaned up wording" edit.)
00 Installation Instructions  
+
05 Packaging - Wrong content.  Show how your boxed up your Beagle. Include a picture (show off what you have done.)
00 User Instructions
+
06 Installation Instructions - Show the npm commands that need to be run.
00 Highlights
+
10 User Instructions
00 Theory of Operation
+
00 Highlights - Missing.  Needs YouTube video.
00 Work Breakdown
+
05 Theory of Operation
00 Future Work
+
05 Work Breakdown - Seems rather imbalanced.
00 Conclusions
+
10 Future Work - Good suggestions
00 Demo
+
10 Conclusions - Good
 +
10 Demo - It works!
 
00 Late
 
00 Late
Comments: I'm looking forward to seeing this.
+
Comments: A lot of work went into this project. I'm having trouble making it work on my Bone, but I'm not running Ubuntu, so I won't hold it against you.
  
Score:  10/100
+
Score:  65/100
 
</pre>
 
</pre>
 
+
There are a few things that need fixing up before I'll assign your final score.  They are marked in <span style="color:red">red</span>.  The comments in <span style="color:green">green</span> are just comments and don't need further action.
<span style="color:red">(Inline Comment)</span>
 
  
 
== Executive Summary ==
 
== Executive Summary ==
  
This project focused on creating a music server hosted on the BeagleBone. The server contains a number of MP3 files which will be playable from the Beagle via either direct access or network access over ethernet/wireless. Currently you can upload and download songs, add to and subtract from the playlist, play your custom playlist over hdmi or headphone jack, adjust the output volume, load new media, etc, ''all from your web browser''.
+
This project focused on creating a music server hosted on the BeagleBone. The server contains a number of MP3 files which can be played from the Beagle via either direct access or network access over ethernet/wireless. Currently you can upload and download songs, add to and subtract from the playlist, play your custom playlist over hdmi or headphone jack, adjust the output volume, load new media, etc, ''all from your web browser''.
  
 
We realize it's an odd choice to have a project that focuses solely on software, rather than a combination of that and hardware (ignoring the audio output). But when approaching the project, we wanted to build something that we would actually use afterwards, and not just relegate to the dust bin of history. I would happily say we succeeded.
 
We realize it's an odd choice to have a project that focuses solely on software, rather than a combination of that and hardware (ignoring the audio output). But when approaching the project, we wanted to build something that we would actually use afterwards, and not just relegate to the dust bin of history. I would happily say we succeeded.
  
 
== Packaging ==
 
== Packaging ==
 +
 +
The beagle bone was fitted into a cardbored tube for protection. It had holes cut into it for the various ports.
 +
 +
[[File:ethernetside.jpg|thumbnail|ethernet side of the package]]
 +
[[File:usbhdmiside.jpg|thumbnail|usb and hdmi side of the package]]
 +
 +
== Installation Instructions ==
 +
 +
 +
1) Go to https://github.com/Guiltygate/beaglebone-classwork and clone the beaglebone-classwork folder somewhere on your beagle. <b>NOTE: </b>Does not work on Windows. Does not play nicely with IE. Should work with Firefox, Chrome, possibly Safari.
  
 
<b>What's in the repo</b>
 
<b>What's in the repo</b>
Line 44: Line 54:
 
<b>What's NOT in the repo</b>
 
<b>What's NOT in the repo</b>
  
*Any node module <i>dependencies</i>. If you receive any errors regarding the node modules, you will want to download and install NPM (NodeJS Package Manager) and reinstall whichever module is throwing the errors. This will also grab any dependencies it requires that you do not already have. If, when trying to reinstall, it won't let you download the module, this is most likely due to a conflict between NPM and your distro. You'll need to download the files on another distro, port them over, and use node-gyp (https://github.com/TooTallNate/node-gyp) to compile them locally, and install their dependencies manually. Have fun!
+
*Any node module <i>dependencies</i>. If you receive any errors regarding the node modules, you will want to download and install NPM (NodeJS Package Manager) and reinstall whichever module is throwing the errors. This will also grab any dependencies it requires that you do not already have. If, when trying to reinstall, it won't let you download the module, this is most likely due to a conflict between NPM and your distro. You'll need to download the files on another distro, port them over, and use node-gyp (https://github.com/TooTallNate/node-gyp) to compile them locally, and install their dependencies manually.
  
 
  beagle$ '''npm install lame'''
 
  beagle$ '''npm install lame'''
Line 53: Line 63:
  
 
*For USB audio, you'll need to edit a config file. Those details are below.
 
*For USB audio, you'll need to edit a config file. Those details are below.
 
== Installation Instructions ==
 
 
 
1) Go to https://github.com/Guiltygate/beaglebone-classwork and clone the umbreon folder somewhere on your laptop <span style="color:red">(Why not beagle?)</span>. <b>NOTE: </b>Does not work on Windows. Does not play nicely with IE. Should work with Firefox, Chrome, maybe Safari.
 
 
  
 
<b>FOR USB-Audio and browser volume control</b>
 
<b>FOR USB-Audio and browser volume control</b>
Line 65: Line 69:
  
 
2) You will need NodeJS, v.0.8.xx or higher, along with NPM. While I include the different node_modules in the git repo, installing them through NPM also installs their dependencies. If you run into issues with the distro not allowing module installation, use node-gyp here: https://github.com/TooTallNate/node-gyp .
 
2) You will need NodeJS, v.0.8.xx or higher, along with NPM. While I include the different node_modules in the git repo, installing them through NPM also installs their dependencies. If you run into issues with the distro not allowing module installation, use node-gyp here: https://github.com/TooTallNate/node-gyp .
 +
 +
Use
 +
beagle$ '''sudo apt-get install npm'''
 +
 +
or your distro equivalent to install npm. Again, some distro's don't directly support NPM, and you'll need to go to their site here (https://npmjs.org/) in order to manually download and install.
  
  
3) Due to the whole 'unable-to-reflash-with-Angstrom' problem, I am unable to guarentee this will work on a standard BBB. However, I only use general linux architecture features, so feasibly as long as you can install Express 3.xx on Angstrom, it should be perfectly fine.
+
3) Due to the whole 'unable-to-reflash-with-Angstrom' problem, I am unable to guarantee this will work on a standard BBB. However, I only use general Linux architecture features, so feasibly as long as you can install Express 3.xx on Angstrom, it should be perfectly fine.
  
 
== User Instructions ==
 
== User Instructions ==
Line 73: Line 82:
 
See the README for further detail, but here's the basics.
 
See the README for further detail, but here's the basics.
  
Run this command <span style="color:red">(I had to do a chmod +x startServer.sh to make this work.)</span>
+
Run this command  
  ./startServer.sh
+
beagle$ '''./startServer.sh'''
if you wish to automatically mount your current usb drive. Server will start at 192.168.7.2:8080.
+
 
 +
If that does not work run the following command first
 +
  beagle$ '''chmod +x startServer.sh'''
 +
 
 +
if you wish to automatically mount your current usb drive. Server will start at 192.168.7.2:8080. If you receive a permissions error, run
 +
beagle$ '''chmod +x startServer.sh'''
 +
to grant the proper permissions.
  
 
If you'd rather just start the server without auto-mounting, run
 
If you'd rather just start the server without auto-mounting, run
  node umbreonServer.js
+
  beagle$ '''node umbreonServer.js'''
 +
 
 +
<span style="color:green">(I'm running v 0.8.22 of node, but I'm getting a "Module version mismatch" from the speaker module)</span>To play the current playlist (initializes to all .mp3 files in the top directory of your flash drive), hit the big arrow button. To view the current playlist/remove songs from it, hit the '-' button on the right. To view the entire directory of mp3 files and possible add them to the playlist, hit the '+' button on the left.
  
To play the current playlist (initializes to all .mp3 files in the top directory of your flash drive), hit the big arrow button. <span style="color:red">(Show a picture)</span>To view the current playlist/remove songs from it, hit the '-' button on the right. To view the entire directory of mp3 files and possible add them to the playlist, hit the '+' button on the left.
+
[[File:umbreonGUI.png|thumb|Umbreon Interface.]]
  
 
To swap out flash drives, press the 'Eject' button, physically switch them, and then hit the 'Load Media' button. To stop the current playlist from playing, hit the 'Stop Playlist' button. Warning: Stop button stops the playlist, but not the current track.
 
To swap out flash drives, press the 'Eject' button, physically switch them, and then hit the 'Load Media' button. To stop the current playlist from playing, hit the 'Stop Playlist' button. Warning: Stop button stops the playlist, but not the current track.
Line 98: Line 115:
 
*GUI font/style is ugly. Which is kind of a bug.
 
*GUI font/style is ugly. Which is kind of a bug.
  
[[File:umbreonGUI.png|thumb|Again, it's rough.]][[File:umbreonGUIPlaying.png|thumb|Again, it's rough.]]
+
[[File:umbreonGUI.png|thumb|Again, it's rough.]]
 +
 
 +
== Highlights ==
 +
Video highlights can be found in the link below.
 +
 
 +
[[File:HighlightsVideo.mp4|thumbnail|Video showing the highlights of the project]]
 +
 
 +
Highlights include adding and removing songs from the playlist and changing the volume of the song being played. Not mentioned in the video the webpage can be accessed by any computer on the same network so it is easy to change the playlist from across the room.
  
 
== Theory of Operation ==
 
== Theory of Operation ==
Line 104: Line 128:
 
Using express framework in NodeJS. Enables user to upload songs for playing, download the currently playing song, view playlist, edit playlist, add songs from the directory, change media by swapping out usb drives, etc.
 
Using express framework in NodeJS. Enables user to upload songs for playing, download the currently playing song, view playlist, edit playlist, add songs from the directory, change media by swapping out usb drives, etc.
  
 +
Express framework uses socket.io which has 2 major functions to communicate, socket.on and socket.emit. When socket.emit is used in mediaplayback.js it uses the socket.on equivalent in umbreonserver.js.
 +
 +
example:
 +
socket.emit('addSong', songNum);
 +
socket.on('addSong', function(songNum){}
 +
 +
This also works the other way. For uploading the file names to the webpage you use a socket.emit call within umbreonserver.js.
  
 
Everything was planned for maximum user convenience, as I plan on using this in my dorm room once I obtain a wireless router for the bone.
 
Everything was planned for maximum user convenience, as I plan on using this in my dorm room once I obtain a wireless router for the bone.
Line 132: Line 163:
  
  
<b>Editing the Wiki/Writing Installation Guide</b>---------Eric---------5hrs
+
<b>Editing the Wiki/Writing Installation Guide</b>
 +
: ---------Eric---------5hrs
 +
: ---------David--------2hrs
  
<b>Network access</b>--------Eric------1.5hr
 
  
  
=====Notes on Work Distribution=====
+
<b>Network access</b>--------Eric------1.5hr
(To be removed after grading)
 
 
 
I wasn't going to put this final bit in here, but I'm also worried my partner may try and suggest it was my fault for the uneven distribution of work, so I'll give a brief summary below of what happened.
 
 
 
Neither of us knew NodeJS, Express, etc. going into the project. When discussing what our project should be, we both agreed on the music server- but while I made it clear we would both need to know JS and the rest to be effective, and looked up what I needed to know, David did not. I tried to involve him in the project later, as I realized he was slipping away, but that didn't work out. To be specific:
 
 
 
*I suggested he research radio-streaming, and see if we could use pianobar. He didn't do any research that he told me of, and was unsuccessful with pianobar after spending an hour (at most) with it.
 
 
 
*I suggested he come up with other cool ideas we could implement into the project. He never gave me any, although I ended up adding the ability to swap media easily, in-browser sound control, and a number of GUI refinements.
 
 
 
*I asked him to learn NodeJS in order to "proofread" my coding. He did not.
 
 
 
*The one time I directly asked him to do some more research (this was Tuesday of 10th week), he simply said he was tired and headed home for the evening.
 
 
 
David Cooper is a nice guy and a friend, but I feel that he did not contribute his fair share of the work. I will admit that near the beginning of the project, my instructions to him were vague, only being to learn NodeJS and research what was possible with it for media control. I do feel, however, that as a senior ECE student, David does not need me to constantly remind him when and what to work on. A good team should communicate, but one member should not have to constantly hold the other's hand.
 
 
 
I apologize for this lengthy rant, and also for any portion of it that may be unprofessional. As I am biased, I highly suggest talking to David and to others in the class who knew the two of us. He may suggest that I kept all the work to myself or something such like it, although I certainly tried to include him- I hardly enjoy doing all the work myself. I would also like to mention that he has no doubt never read the contents of our wiki, or he would have already noticed my various comments. I know he hasn't noticed his name no longer appears in the web GUI I built.
 
  
Again, sorry for all this.
+
<span style="color:red">(I don't see many hours for David here. Unless I hear otherwise I'm inclined to assign two different grades.)</span>
  
 
== Future Work ==
 
== Future Work ==

Revision as of 15:01, 18 November 2013

thumb‎ Embedded Linux Class by Mark A. Yoder


Team members: Eric Ames, David Cooper


Grading Template

I'm using the following template to grade. Each slot is 10 points. 0 = Missing, 5=OK, 10=Wow!

09 Executive Summary - Watch the 'tense'.  "which will be playable" vs. "which is playable". (See my "Cleaned up wording" edit.)
05 Packaging - Wrong content.  Show how your boxed up your Beagle. Include a picture (show off what you have done.)
06 Installation Instructions - Show the npm commands that need to be run.
10 User Instructions
00 Highlights - Missing.  Needs YouTube video.
05 Theory of Operation
05 Work Breakdown - Seems rather imbalanced. 
10 Future Work - Good suggestions
10 Conclusions - Good
10 Demo - It works!
00 Late
Comments: A lot of work went into this project. I'm having trouble making it work on my Bone, but I'm not running Ubuntu, so I won't hold it against you.

Score:  65/100

There are a few things that need fixing up before I'll assign your final score. They are marked in red. The comments in green are just comments and don't need further action.

Executive Summary

This project focused on creating a music server hosted on the BeagleBone. The server contains a number of MP3 files which can be played from the Beagle via either direct access or network access over ethernet/wireless. Currently you can upload and download songs, add to and subtract from the playlist, play your custom playlist over hdmi or headphone jack, adjust the output volume, load new media, etc, all from your web browser.

We realize it's an odd choice to have a project that focuses solely on software, rather than a combination of that and hardware (ignoring the audio output). But when approaching the project, we wanted to build something that we would actually use afterwards, and not just relegate to the dust bin of history. I would happily say we succeeded.

Packaging

The beagle bone was fitted into a cardbored tube for protection. It had holes cut into it for the various ports.

ethernet side of the package
usb and hdmi side of the package

Installation Instructions

1) Go to https://github.com/Guiltygate/beaglebone-classwork and clone the beaglebone-classwork folder somewhere on your beagle. NOTE: Does not work on Windows. Does not play nicely with IE. Should work with Firefox, Chrome, possibly Safari.

What's in the repo

  • Server files
  • node module files
  • Basically all files I created/used

What's NOT in the repo

  • Any node module dependencies. If you receive any errors regarding the node modules, you will want to download and install NPM (NodeJS Package Manager) and reinstall whichever module is throwing the errors. This will also grab any dependencies it requires that you do not already have. If, when trying to reinstall, it won't let you download the module, this is most likely due to a conflict between NPM and your distro. You'll need to download the files on another distro, port them over, and use node-gyp (https://github.com/TooTallNate/node-gyp) to compile them locally, and install their dependencies manually.
beagle$ npm install lame
  • NPM. It's a separate program that you may or may not need, depending on the above.
  • NodeJS version 0.8.xx or higher. Again, you need to install this. May work with 0.6.12, hasn't been tested. I use the Express module, which supposedly required NodeJS 0.8 and higher, but who knows. I personally used the 0.9.9 (unstable) build for Debian. Ubuntu shouldn't have any issues.
  • For USB audio, you'll need to edit a config file. Those details are below.

FOR USB-Audio and browser volume control 1a) If you want to use a USB-audio device, you need to set it to default. I used the guide here http://crunchbang.org/forums/viewtopic.php?id=9852 . Also make sure that you have alsamixer, as the sound controls in-browser use command-line arguments sent to amixer, a module of alsamixer. If you don't have alsamixer, you simply won't be able to adjust the volume from the browser.


2) You will need NodeJS, v.0.8.xx or higher, along with NPM. While I include the different node_modules in the git repo, installing them through NPM also installs their dependencies. If you run into issues with the distro not allowing module installation, use node-gyp here: https://github.com/TooTallNate/node-gyp .

Use

beagle$ sudo apt-get install npm

or your distro equivalent to install npm. Again, some distro's don't directly support NPM, and you'll need to go to their site here (https://npmjs.org/) in order to manually download and install.


3) Due to the whole 'unable-to-reflash-with-Angstrom' problem, I am unable to guarantee this will work on a standard BBB. However, I only use general Linux architecture features, so feasibly as long as you can install Express 3.xx on Angstrom, it should be perfectly fine.

User Instructions

See the README for further detail, but here's the basics.

Run this command

beagle$ ./startServer.sh

If that does not work run the following command first

beagle$ chmod +x startServer.sh

if you wish to automatically mount your current usb drive. Server will start at 192.168.7.2:8080. If you receive a permissions error, run

beagle$ chmod +x startServer.sh

to grant the proper permissions.

If you'd rather just start the server without auto-mounting, run

beagle$ node umbreonServer.js

(I'm running v 0.8.22 of node, but I'm getting a "Module version mismatch" from the speaker module)To play the current playlist (initializes to all .mp3 files in the top directory of your flash drive), hit the big arrow button. To view the current playlist/remove songs from it, hit the '-' button on the right. To view the entire directory of mp3 files and possible add them to the playlist, hit the '+' button on the left.

Umbreon Interface.

To swap out flash drives, press the 'Eject' button, physically switch them, and then hit the 'Load Media' button. To stop the current playlist from playing, hit the 'Stop Playlist' button. Warning: Stop button stops the playlist, but not the current track.

To download the current track, hit the 'Download' button at the bottom of the page. To upload, simply drag-and-drop the desired file.

Known/Previous Bugs
  • Previously, hitting the 'play' button while songs are already playing will cause a system crash. HOWEVER, this SHOULD be fixed. I haven't been able to replicate it since fixing it, at least.
  • Previously, the load button stopped working for some reason and kept new media from being loaded. It had to do with pulling out the USB before unmounting it, so now users should press the 'eject' button before removing the flash drive, then plugging in the new media and pressing the 'load' button.
  • Cannot skip songs backwards. The button is disabled, as I couldn't find a time-effective way of implementing this.
  • Stopping and forward skipping 'works', but only if pressed in the first three seconds of a song beginning playback. The entire playlist will still stop (if pressing the 'stop' button), but not the current track.
  • GUI font/style is ugly. Which is kind of a bug.
Again, it's rough.

Highlights

Video highlights can be found in the link below.

File:HighlightsVideo.mp4

Highlights include adding and removing songs from the playlist and changing the volume of the song being played. Not mentioned in the video the webpage can be accessed by any computer on the same network so it is easy to change the playlist from across the room.

Theory of Operation

Using express framework in NodeJS. Enables user to upload songs for playing, download the currently playing song, view playlist, edit playlist, add songs from the directory, change media by swapping out usb drives, etc.

Express framework uses socket.io which has 2 major functions to communicate, socket.on and socket.emit. When socket.emit is used in mediaplayback.js it uses the socket.on equivalent in umbreonserver.js.

example: socket.emit('addSong', songNum); socket.on('addSong', function(songNum){}

This also works the other way. For uploading the file names to the webpage you use a socket.emit call within umbreonserver.js.

Everything was planned for maximum user convenience, as I plan on using this in my dorm room once I obtain a wireless router for the bone.

Work Breakdown

I would like to point out this wouldn't have taken so long if I hadn't had to learn NodeJS, Express, NPM, alsa, CSS, html, and all the little quirks associated with them. On top of my Beagle dying Sunday and refusing to reflash to Angstrom. Spent all day trying to reflash it, had to switch to Debian Wheezy and re-dowload all the software.


Server Core-----------Eric------10hrs

Server Features-------Eric------30hrs (minimum)

Beginning with Express, NodeJS, NPM, als-arch, :: 18hrs (last Friday and Saturday. Sunday was spent praying and trying to fix the Beagle. Monday was spent swapping over to express.)
Playlist------------1hr
Playlist viewing----20min
Playlist editing----20min
Radio-Stream--------6 hrs - partially included in the 'Beginning' section
Basic GUI-----------1hr
Enhanced GUI--------4hrs
Song uploads--------6hrs
Song downloads------1hr
Tracklist-----------10min

Express Test----------David-----1hr

Initial Planning and Discussion----------Both---------2hrs


Editing the Wiki/Writing Installation Guide

---------Eric---------5hrs
---------David--------2hrs


Network access--------Eric------1.5hr

(I don't see many hours for David here. Unless I hear otherwise I'm inclined to assign two different grades.)

Future Work

1) Add wireless router for easy streaming, no ethernet cord hassle.

2) Fully implement the Stop and Skip buttons. Currently, they can't stop the audio stream currently outputting, only the rest of the playlist.

3) Add a 'reboot server' button, in case of server failure. Tying into this, the server needs to be able to start on boot- I lost the config files when my board self-destructed on Monday.

4) Due to not knowing CSS or html, the current GUI is a bit crap. I'd like to build a GUI I can actually be proud of, rather than the slap-a-dash affair I have now.

5) Song playback bar, graphically lets you know time remaining.

6) Button feedback. It's weird to select a song and having no feedback if it worked or not. Annoying.

7) The audio modules I use only process .mp3 files, so adding additional modules to process .ogg and other popular audio files would be something nice to add. I myself only have/use .mp3s, so no guarantee I'll do this.

Conclusions

Wish I could have done more with the hardware, like a lightshow tied to the audio or something. But it took a lot of time to learn the different languages/styles/formats I needed for the project. It was all high-level (mostly), but there's a bunch of little gotcha's that will trip you up if you're not careful. Probably would have helped to have someone double-check my work.


As time-intensive as it was, what with other classes, I had a blast learning so much, and I'm looking forward to continuing to work on this over break and into the future. I also want to look into what other useful applications I could run on the bone with nodejs/express web-servers. Many, many possibilities...




thumb‎ Embedded Linux Class by Mark A. Yoder