Skip to content

1. Controller and Model

Akshay Chacko edited this page Apr 20, 2021 · 90 revisions

Story Map

Story Map

Music Streaming

This app uses the Spotify API for Android. Spotify API allows us to not only get the publishment information about a song (title, artist, album, Spotify link, etc.), but also get calculated audio features, such as its danceability, energy, valence, and more.

Music Features & Analysis

This app uses the Spotify API to track and analyze the audio features of each song. The tracked features can be categorized as follows:

  • Mood: Danceability, Valence, Energy, Tempo
  • Properties: Loudness, Speechiness, Instrumentalness
  • Context: Liveness, Acousticness
  • Other In-depth Features: Segments, Tatums, Bars, Beats, Pitches, Timbre, and more

The major focus of our recommendation algorithm is to find songs with similar sentiments. When the recommender receives a song, it will run the music analysis on it and return other musical tracks with similar keys, BPM, and other user-specified features.

Recommendations

The Kotlin project file is composed of numerous activities that work together to call the back-end and push it to the front-end.

StartingActivity link to source code

This activity corresponds to activity_starting.xml, which is the main screen of the app. From here, the user either chooses to import a song from Spotify, or to pick a premade genre playlist to seed the recommender with. Each button has an onclick handler that calls the appropriate function to spawn the next activity using intent. For instance, the "Import from Spotify" button calls the importSong() function, which proceeds to load the ImportActivity. Similiarly, the genre buttons have an onclick handler that calls one of the chooseGenre() functions, which in turn loads the HiphopActivity with whatever genre the user chose.

HiphopActivity link to source code

This activity handles the case of the user wanted to import a premade playlist. NOTE: Although the name says HiphopActivity, it actually handles all genres as it is passed a playlist of the genre that the user selected. This activity has four classes: HipHopList, RockList, PopList, and DanceList. Each of these classes essentially have private variables that contain all the metadata for the chosen genre playlist, as well as a getView() function that loads this data into a ListViewAdapter for the user to interact with. In the onCreate() function of the HiphopActivity, we check what genre the user chose and pass the corresponding class (ie. DanceList) to an instation of the listView. There is a back button in the top left of the activity_hiphop.xml which calls the goBack() onclick handler to return to the StartingActivity. There is also a checkmark in the bottom right of the screen, which calls the choosePlaylist() onclick handler to continue on to the RecommendationActivity.

ImportActivity link to source code

This activity corresponds with activity_import.xml and allows the user to load a song or playlist from Spotify via URL/URI, or search for one by name.

MainActivity link to source code

RecommendationActivity

SongListAdapter

SearchListAdapter

Clone this wiki locally