You are on page 1of 7

Weather Based Playlist Generation in Mobile Devices

Using Hash Map

Lavanya.S [1], Saranya.G [2], Navin.K [3]


[1]
Assistant Professor, Department of Information Technology, SRM University.
lavanya.se@ktr.srmuniv.ac.in
[2]
Assistant Professor, Department of Information Technology, SRM University.
saranya.g@ktr.srmuniv.ac.in
[3]
Assistant Professor, Department of Information Technology, SRM University
navin.k@ktr.srmuniv.ac.in

ABSTRACT
The nature as always been a source of music be it functioning of a music player will be applied. The
the thunders, the rustling of trees or the birds results of the study suggest that there is indeed a
chirping. The creative output of composers, writers, strong correlation between music and weather.
and artists is often influenced by their surroundings. Keywords: Music, Weather, hash map, genre, API.
Of course, an important part of what we see and hear 1. INTRODUCTION
is not only the people with whom we interact but Introduction to Weather and Mood Based Music
also our geophysical surroundings. Of all the Amalgamation of real life analytics into a full-
geophysical phenomena to influence us, the weather fledged working application that demonstrates the
is arguably the most significant because we are effect of weather on music. Large digital databases
exposed to it directly and daily. The main aim of this of Hindi music are available which creates an
paper is to implement this correlation between opportunity of filtering this data with multiple
weather and music. Most of the listeners listen to parameters [1]. One of the most important parameter
music using applications; this paper aims at creating used by the listeners is their moods. This paper
an application on android platform. This music focuses on Automatic generation of mood based
application uses a weather API to determine the playlist for Hindi popular music with minimum user
weather forecast at the instant when a user wants to intervention. There are two major modules of the
listen to music. The music application maps the proposed system. The first module identifies user’s
weather to the genre of the music present on the mood based on the inputs from social media and
phone’s memory (internal and external). The path of messaging app like WhatsApp. The second module
these songs is stored in tables in the SQLite is responsible for tagging the songs of available
Database. These tables are named according to the database. Tagging is done on the basis of Genre,
genres found in the metadata of the music files. The Artists, Tempo and Lyrics. The size of multimedia
metadata is inclusive of the details of the file such as data on the web is increasing in the exponential way
genre, album art etc. which can be extracted using and it provides easy accessibility to all kind of
the Metadata Retriever class in Java programming music. Due to this increase in data a new research
language. The application not only functions as a area of Music Information Retrieval has emerged. It
weather based music player also as a normal music deals with retrieval of data from large database by
application. Once the user launches the application searching the content and finding the pattern rather
on their screens, they will be asked for their than just using limited information available in
preferences. If the user chooses a weather based Metadata. This has made searching of audio data
music option only then therefore mentioned more efficient. Also, there are multiple approaches
functioning will be applied or else the normal made for creation of playlist based on user
preferences. With the advancement in the algorithms leading weather provider with over a billion users
based on searching data from the large digital worldwide, and correlated a year’s worth of five
corpus, users are now interested in filtering the data kinds of weather data (sun, clouds, rain, wind, and
based on various properties such as year, lyrics, snow), from nearly a thousand weather stations
genre, rhythm etc. Since time immemorial, music around the world, to over 85 billion anonymised,
has been an integral part of human life. In the Indian aggregated streams on Spotify on those same days
context, people can relate a song to any occasion or and locations. In the words of Spotify data
situation. Indian music has a rich history and large researcher Ian Anderson, who analysed the
dataset of songs for every mood. If we narrow down combined weather and music data set, “There is
to the Hindi popular music alone, that too could be definitely a connection between what’s in the skies
categorized under a specific mood or a different and what’s on users’ play queues.”
variety of moods. Indian music industry is built on At spotify.com/climate, you can see not only
the contribution from pop music industry as well as your weather, but details about a city in the study
from the Bollywood industry. Hence the corpus is with the same weather, including how moods and
quite large as compared to other music industries in audio attributes change there during that type of
the world. Increase in online music libraries has weather (you can also click to see what happens
expanded approaches for selecting the songs and has there in other weather conditions). There’s also a
also made it complex as a user might get confused or Spotify playlist where you can hear music that
could not sift through the entire dataset. Further it popped up disproportionately under that weather
can also create a situation of long tailing. condition in that city during the timeframe in which
Due to the complexity of Hindi music genre, any the analysis was done, November 2015 to November
one parameter such as metadata, rhythm or lyrics 2016.Some findings (there’s more city-level data in
cannot be considered for classifying the songs the graphs below):
according to the various moods. The proposed
model considers combination of multiple parameters x Sunnier days bring higher-energy, happier-
to precisely identify the mood of song. The common sounding music.
property used by people for playlist generation is x Conversely, on rainy days, people generally
their mood. In current systems, the users should tend to listen to lower-energy, sadder-
select songs based on their mood manually. The sounding music.
automated system will be useful in increasing the x Rainy day tracks were much more acoustic
speed to generate playlist. than electronic, and exhibited higher levels
Table 1.1 Genre based mood classification of “organism,” a measure of how “human” a
Genre Mood track sounds (i.e. a live drummer instead of a
Pop Happy, Excited drum machine).
Devotional Sad, Happy, Trance x Some cities respond strongly to the weather
Ghazal Romantic, Sad in their listening, while others respond less.
Sufi Trance, Sad x In the US (more cities in the graphs below).
Rock Excited, Happy x New York City and Philadelphia are most
Bollywood Any Mood musically-affected by the rain.
x Dallas listens to the same kind of music
Our research focus on people make different music- when it’s overcast and when it rains.
listening decisions based on weather. This simple x Seattle and Chicago are more impacted by
question led to what could be the largest-scale overcast days than rain.
research ever conducted into the connection between x Chicagoans are excited by rain, unlike most
music and atmospheric conditions [2]. For the cities, and least excited by clouds.
weather data, we partnered with Accuweather, a
x Houston responds the most strongly to rain, Dance ability describes how suitable a track is for
out of the cities in our study. The acoustic- dancing based on a combination of musical elements
ness of Houston’s listening in the rain including tempo, rhythm stability, beat strength, and
increases 121 percent. overall regularity.
x In the UK, like other countries, rainy weather
leads to sadder music –but brits aren’t always
happiest in the sun. Leeds is happiest on
cloudy days. Unlike almost every other
major city, Liverpool and Manchester
play happier music when it snows.
x Cloudy days are more danceable in the UK
than sunny days, bucking the global trend —
especially in London and Liverpool, which
see the biggest boosts in danceable music in
the sun.
x Manchester goes for instrumental music on
rainy days, and also listens to music that’s Figure 1. 2 Impact of Weather on Dance ability
Mapping the past research of weather and music
good for running when it rains.
x Of major Australian cities, Sydney listens to correlation into a simple algorithm which can search
songs from a phone’s external memory as per a
the saddest music when it rains, and is one of
the most affected cities in the world in weather at that instant.
that way. 2. PROPOSED MODEL
x Australian cities tend towards acoustic music The proposed model is the weather based
on rainy days, while Kiwis want acoustic- music application. It consists mainly of two views
namely the Music Listener and the OS, i.e., Android
sounding music when the sun’s out.
itself. The music listener can choose the mode in
x Unlike the rest of Australia (and most of the which he/she would like to listen to the music. The
world), Brisbane chooses more runnable modes being the weather based mode and the non-
music on cloudy days. weather based mode. In the former mode, the
weather is fetched using the weather API and songs
Acousticness is a measure of how many prominent are mapped from the music listener’s library
“acoustic” sounds (for example acoustic guitar and according to weather genre mapping.
Now irrespective of the mode the listener has
tambourine) a given track has, versus how many
chosen he/she can navigate to the next song from the
electronic sounds (synthesizer, drum machine) it current song, or go back to the previous song. They
has, as determined by computers listening to music. can play/pause the song using the corresponding
button. In our application, the user can view all the
songs in a list view. There is also a provision for a
toggle button which when turned off, provides the
functionality for the music application to act like a
normal music application and when turned on,
displays an image corresponding to the current
weather and the songs that were fished out from the
listener’s music library.
Firstly, app asks for the required permission from
the user. If the user accepts WeaPlay proceeds, else
Figure 1.1 Impact of Weather on Acousticness it terminates itself. This is to happen as the
permissions required by API level 23
(Marshmallow/6.0) and above requires permission at
runtime. Then WeaPlay asks the user whether it use then once we get hold of the files we extract the
wants to run in normal mode or in weather based metadata of the files using MediaMetadataRetriever
mode, using an Alert Dialogue Box. Once the user class. Once the metadata is retrieved we make use of
makes a choice the data flow proceeds. the metadata named ‘Genre’.
The proposed model consists of two modes: Once Genre of the song is retrieved we store the
1. Non-Weather Based Module path of the song into SQLite database based on their
2. Weather-Based Module Genre. This means all EDM songs will be kept in a
table called EDM, similarly all Ghazals will be kept
1. Non- Weather Based Module: in a table called Ghazals. Now once all the song
In this module WeaPlay reads the files paths are stored into database, we use the class
present in the internal and external file directory of Location Manager to fetch the correct co-ordinates
the user. It does so using recursion and file handling. of the device. Once we get hold of the coordinates
Once it gets hold of all the ‘.mp3’ and the ‘.wav’ we send them to the Yahoo Weather Server who
files it sends it to an Array List of files. This Array send us back the weather data in form of JSON
List is read using a loop and the set into an Array object. Now, from this JSON object we get the
Adapter. Now, this array adapter is used to set it into current ‘Weather Condition’.
the list.

Figure 1. 4 Flow Diagram for WeaPlay


Application

Once the current weather condition is retrieved, we


turn to the Hash Map where the key we put is the
weather condition and the value we receive are the
playable genres. Now we turn back to the SQLite
Figure 1. 3 Flow Diagram for Non-Weather table and turn back to the genre given as output by
the Hash Map. We take the file paths and set them
Module
into an Array List of files which is put in turn into an
2. Weather Based Module: Array Adapter. This array adapter is finally put into
In this module, WeaPlay uses the nearly list.
same steps as above. Hence, internal and external
storages are scanned, a Hash Map of possible Genres
with respect to the weather conditions are created
and a SQLite database is made into which tables are
created named on the genre of the songs. Then we
song which is further used to go to a SQLite
database that contains a table by the name of genre
of song. Each table has list of all songs that belong
to the genre. Now this based on the genre the
corresponding table is chosen and then the file paths
present within are taken and read from phone
storage. Later these paths are used to display the
songs mapped to the weather condition in the list.
Pseudocode:

getWeather () {
// reads all music files
}

serviceSuccess () {
//called when weather information is
successfully received from Yahoo Weather API.
// set toggle state to ON
// get weather condition
// change toggle background based on
weather
// get genre from HashMap with weather
condition as input
// get path of songs of files from database
based on genre
// set the list items
// place toggle button on Click () code same
as above logic
// place list onItemClick() code same as
above logic
}

serviceSuccessForToggle () {
//called when weather information is
successfully received from Yahoo Weather API.
// set toggle state to ON
Figure 1. 5 Flow Diagram for Weather API based
//set flag to true
playlist generation. // get weather condition
// set toggle button background as weather
3.IMPLEMENTATION based background
The Proposed model architecture describes // call getPathList ()
that uses the Location Manager to get hold of the //use getToggle () method of ToggleHandler class to
exact coordinates of the device. This is then sent to set the songs in list view , redirects to toggleSuccess
the Yahoo Weather server via a query. Upon, the ()
processing of the query we get a response as a JSON }
object which contains the weather information of the
location inferred from the coordinates sent. From the
JSON object we derive the weather condition
(sunny, rainy, windy, etc.) and then send it to the
HashMap. Upon, receiving the weather condition,
HashMap uses it as a Key and finds the
corresponding value. Now this value is Genre of the
This music application uses a weather API to
determine the weather forecast at the instant when a
user wants to listen to music. The music application
maps the weather to the genre of the music present
on the phone’s memory (internal and external). The
path of these songs is stored in the form of relations
in the SQLite Database.

5. CONCLUSION
We as human beings, express our innermost emotions
and feelings through various art forms like paintings,
dance, music, plays etc. The idea behind this paper
was a human mood or expression can also change due
to many external factors such as weather and climatic
conditions. This paper implements the correlation
between the internal and external factors (emotions
and weather). Initially there was no evidence to prove
that indeed people do change their preferences of
music according to the weather. So, we researched the
existing system, which indeed proved that weather
was a strong determinant of people moods which
Figure 1. 6 Flow Diagram for Weather API based
indeed affected their music preferences. The
playlist generation. application currently is working successfully as
weather based application. In the future, this
4. RESULTS application can also be implemented as a mood based
The Proposed model evaluated the properties of the music player by the application of Fast Fourier
music and determining its mood classification, no Transform using machine learning algorithm.
such devices like the camera/sensors were used
which can give us a transparent view of the person's
mood. An individuals’ musical preferences may not REFERENCES
always be contingent with their mood, for instance 1. Petra Kern, David Aldridge “Using Embedded
they could be happy but would prefer listening to Music Therapy Interventions to Support Outdoor
soothing or dull music. Thus, the mood based model Play of Young Children with Autism in an Inclusive
is not efficient in gauging the unambiguous mood Community-Based Child Care Program”. Journal of
of an individual. Music Therapy, XLIII (4), 2006, 270-294.

2. David M. Greenberg, Simon Baron-Cohen, David


J. Stillwell, Michal Kosinski,
Peter J. Rentfrow. “Musical Preferences are Linked
to Cognitive Styles”. July 22, 2015.

3.https://insights.spotify.com/us/2017/02/07/spotify-
accuweather-music-and-weather/

4.Aplin KL, Williams PD. 2011. “Meteorological


phenomena in Western classical orchestral music”.
Weather 66(11): 300–306.

5. Aplin KL, Williams PD. 2012. “Weather affects


music”. EOS Trans. Am. Geophysics.
Figure 1. 7 Screenshots of WeaPlay Application
6. Kunal Gajjar, Siddhi Shah “Mood Based Playlist
Generation for Hindi Popular Music: A Proposed
Model”. International Journal of Computer
Applications (0975 – 8887).

7. Spotify, Accuweather Reveal How Weather


Affects Music Listening
February 7, 2017 by Eliot Van Bus Kirk

You might also like