Don't you wish your life had it's own soundtrack? Wouldn't it be cool if music were recommended for you based on your current environment? We thought so, and that's the inspiration for SoundTrax!
What it does
As you travel through the environment, SoundTrax queries your current location for information about the local terrain. Is it flat and boring? Is it hilly and dynamic? Somewhere in-between? A "ruggedness" index (using elevation and slope) is used to query the Spotify REST API for songs whose energy and valence match the terrain. When it's time for a new song, the query is made again for your location. Wherever you are, your tunes will match the terrain!
How we built it
- ArcGIS Pro was used to create a 1-mile X 1-mile grid to summarize local terrain ruggedness (based on a high-resolution Digital Elevation Model image). This dataset was published as a feature service on ArcGIS Online for access through the REST API.
- A Xamarin iOS project was created to design the UI (the app was envisioned as a mobile app for iOS or Android).
- A Windows app was created to prototype and test application logic (C# wrappers of the Spotify API were not available for Xamarin).
- Authentication code was added to log the user into Spotify. The user's profile (favorite artists, genres, etc) were read.
- Geocoding and routing functionality were added to the app. A location simulation class was created to simulate driving a route determined by the user.
- To find a recommended track, a call was made to our "ruggedness" service to read values for the current location (latitude and longitude). These values were passed to the Spotify API. Recommended tracks were returned based on the ruggedness values, but within the parameters of the user's tastes (based on their favorite artists, ie).
- Information about the recommended track was shown to the user (artist, track name, album art, etc.). The track was played on the currently active device (if any) for Spotify. Note: Spotify Premium was required to programmatically play a track like this.
Challenges we ran into
- We spent too much time initially with Xamarin iOS, since in the end we weren't able to work with Spotify from that platform.
- We spent too much time getting our location simulation to work as we wanted. This functionality made testing and demoing easier, but is not necessary for the app.
- Data processing took much longer than anticipated for the area/scale we originally wanted. Even the much more limited area we fall back on took a long time to process.
- ArcGIS Runtime on Xamarin iOS has a bug when authenticating with the ArcGIS world routing service that we were not aware of. Trying to troubleshoot that issue took some time.
- We had a lot of great Python code to make a variety of queries against the Spotify REST API that we weren't able to bring into the app (translate to C#, e.g.).
Accomplishments that we're proud of
- We think the overall idea is really cool and interesting.
- The data ultimately gave us the information we needed.
- We discovered lots of cool properties of the Spotify API and ways to get interesting recommendations. Ankit composed a lot of really interesting Python queries against the API.
What we learned
- Spotify offers a very rich API for finding music using a variety of attributes (danceability, energy, liveness, loudness, valence, etc., etc.).
- Leveraging REST calls against a service (whether it's Spotify or ArcGIS Online) can bring lots of functionality to a light-weight client.
What's next for SoundTrax
We're continuing to flesh out the backend functionality and mobile UI. If we're unable to find a suitable C# wrapper for calling into Spotify from Xamarin, we may author some of these libraries ourselves. We'd also like to incorporate other factors into the recommendation logic (weather, traffic conditions, etc.).