Piano - Breakdown

MongoDB

Bash Scripts

Cron

Youtube-uploader

HTML//CSS//PHP

Any database will be fine for this, mongo was choosen due to familiarity and ease of use.

Bash Scripts:

cronjob.sh Mongo will first query the database to see how many notes there are in the database. It will put this result in a file. There is an condition to check if the amount of documents is greater than 10, then it will continue on with the rest of the steps below, otherwise, it will stop here and wait for the next cron run. Provided the condition is true, a mongoexport command will be issued that will get the notes, and strip the headers and extra data and put them into a new songs.json file. The notes will then be deleted from the database. Then the piano.sh script is called

Piano.sh A while loop will loop over the enteries (notes) in the songs.json file. As well as an incrementer variable being initalised. For each note, a bash command with the same name, i.e. if the user submitted note C4, there will be a note in the note directory called C4.mp3 and this will be copied along with the incrementer variable to ensure the notes are put together in sequential order. In addition to the notes being copied, an image, again with the same naming convention will be copied into a video folder with the name of the incrementer variable, i.e. 4.jpg. Then the mp3wrap command is ran to correlate all of the mp3s into one mp3. Then the ffmpeg command is ran with a framerate of 1/1 due to each frame being one second long (all the notes were trimmed to this amount). This will bring together the sound and the images to produce a video. Finally, youtube-upload is ran to upload the video directly to youtube

Cron The cron job in /etc/crontab will be ran every 15 minutes and will trigger the cronjob.sh script.



The majority of the work was completed on the front-end side of the website. This was composed of a piano image that was found on the internet. It had to be large enough so that it could be subsectioned through the area command in HTML. This allowed for each of the keys to be drew out with their co-ordinates

A javascript method was used to switch the keys and play the music while the keys were hit through the Audio library. As well as the image being changed through getting the element and replacing the source. This means that there had to be N + 1 amount of images for the number of keys being coloured and one piano picture with no keys chosen.

The PHP takes the note that you selected (and if no note is selected, there will be validation against this, telling the user to select a note.) and send it to the mongo instance. The php-mongo library was used to accomplish this.