Results

The end result of the SmartRaspberry Pi music player met our expectations - we were able to sort songs on the Pi based on weather and create a list of songs that complement the current climate. However, this project did go through several different iterations before we decided what the end result should be capable of and how we should implement it. Thus, this results section is both a description of the evolution of the project and how that ended up affecting the way we tested individual components of the project.

The two main changes from the project the way it is now and our initial vision have to do with how music actually ended up being played and getting realtime audio feedback. Initially, we wanted to both sort songs and play them directly from the Raspberry Pi. However, when we tested audio playback through the headphone jack on the Pi, the quality was terrible and filled with noise. There are several software fixes for this, but before we decided to implement those, we decided to test the music streaming capabilities of the Raspberry Pi. In order to stream music from Spotify on the Raspberry Pi, we had to install a music player daemon (MPD) - we chose mopidy. This is the server side of music streaming - mopidy also needs a client that connects to it, from which users can browse and select music to play. The client we decided to use was ncmpcpp. ncmpcpp proved to be fairly difficult to use; specifically, it was not possible to search for songs using their URIs on ncmpcpp. At the same time, we also noticed that the Pi tended to overheat while the microphone was being used. We ran htop and concluded that the current microphone and music client/server setup would probably not be feasible on the Pi if we wanted to stream music in realtime. This is what led us to developing the protocol to send songs over from the Pi to another device that would stream the music. An added bonus was that good sound quality was guaranteed when streaming from a laptop.

In the final iteration of the project, we decided to sort songs from a playlist or by a certain artist on Spotify - in our first proposal of the project, we were looking to sort songs to match weather criteria from the entirety of Spotify. However, we quickly realized that that was beyond the scope of the project, given that Spotify has millions of songs. Additionally, it isn't very logical either - even real DJs only play songs from a subset of all songs that exist, so it made sense to us to sort from a playlist of songs of all genres that we already liked.

Testing the hardware was straightforward as it could be tested visually or audibly. To confirm that all of the LEDs worked, we wrote to each pixel in each of the three possible colors. The pushbuttons were debugged by printing to the terminal when a press was detected. The USB microphone was tested by recording snippets of songs at different sampling rates using arecord and determining which rates worked and sounded best when played back using aplay. The simplicity of the hardware for the project allowed us to spend time developing an algorithm and exploring different ways to play music from the Pi.

One interesting effect we noticed about using scp and sshpass is that every time the whole system is setup on a new wifi network, we first had to ssh in from the Pi to the laptop (ssh username@IPaddress) from the command line. Otherwise, we would get an error saying that the device was unrecognized.