Mining the social web for music-related data: a hands-on tutorial
-
Upload
ben-fields -
Category
Technology
-
view
6.067 -
download
0
Transcript of Mining the social web for music-related data: a hands-on tutorial
Claudio Baccigalupo amp Benjamin Fields ISMIR 2009 ndash Kobe (Japan)
Mining the social web for music-related data
a hands-on tutorial
1
Welcome
ismir2009beneldsnet
Claudio BaccigalupoIIIAndashCSIC
Barcelona Spain
Ben FieldsGoldsmiths
University of London UK
2
You will write code for real MIR applications
exploring multiple languages and web sites
Itrsquos a hands-on tutorial
1 Evaluating hypotheses
2 Comparing lyrics by genre
3 Revealing trends
4 Performing audio analysis
5 Capturing social data
6 Collecting feedback
3
Source code archive
All the code examples are included in the le ismir2009beneldsnettutorialzip
Unzip the archive and open a shell in its folder en check that Python and Ruby are installed
Or download them frompythonorg and ruby-langorg
$ ruby --version$ python --version
4
1EVALUATING
HYPOTHESES
5
The evaluation process
Say you have built theldquoultimate genre recogniserrdquo
How would you evaluate its precision rate
1 Build a local collection of varied songs
2 Assign them with a genre label
3 Run the algorithm and check its output
genre recogniser
song genre
A cumbersome boring process
6
The traditional approach
Evaluate with a few manually labelled examples
e ldquoultimaterdquo recogniser or just a coincidence
$ cd ltPACKAGE PATHgtc
$ python isrockpy mrockmp3
$ python isrockpy mmetalmp3
$ python isrockpy mvocalmp3
$ python isrockpy mexperimentalmp3
=raquo True
=raquo True
=raquo False
=raquo False
7
The web-based approach
e web contains thousands of genre-classied songs that can be legally downloaded for free
Jamendo only includes 170K songs by 14K artists
8
A web API allows to retrieve data in a compact format from a site by means of simple queries
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
From browser to web API
jamendocomenalbums
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
9
From browser to web API
Documentation at developerjamendocom
API query to retrieve 50 random Rock songs apijamendocomget2streamtrackplaintag_idstr=rockampn=50amporder=random_desc
10
Creating a Python script
Verify the genre recogniser on Jamendo tracks
$ pythonfrom urllib import urlopenfrom isrock import isRockquery = httpapijamendocomget2streamtrackplainn=50amptag_idstr=rockamporder=random_descresult = urlopen(query)read()songs = resultsplit()rock = [isRock(song) for song in songs]print The ratio of rock songs is 2f (float(rockcount(True))len(songs))
11
Evaluating the genre recogniser
e code is included in the le cjamendo_1py
e script cjamendo_2py allows to specify the number of tests and multiple genres at once
e result shows that the isRock recogniser is not able to distinguish Rock from other genres
$ python jamendo_1py
$ python jamendo_2py 30 rock jazz country rnb
=raquo The ratio of rock songs is 058
12
Lessons learnt
Music data can easily be retrieved from the web
ousands of songs can be downloaded for free
Songs in Jamendo already have a genre label attached so you do not have to decide for one
Working with a web API simplies the process
Dierent musical objects are available (songs artists albums playlists users) to work on
13
2COMPARING
LYRICS BY GENRE
14
The relevance of lyrics
Recent interest for lyrics-based analysis
1 Knees Schedl Widmer Multiple Lyrics Alignment Automatic Retrieval of Song Lyrics 2005
2 Geleijnse Korst Ecient Lyrics Extraction from the web 2006
3 Kleedorfer Knees Pohle Oh Oh Oh Whoah Towards Automatic Topic Detection in Song Lyrics 2008
4 Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Lyrics were retrieved without using any web API
15
Lyrics$y provides a web API to retrieve lyrics
An online song lyrics database
lyricsycomsearchviewphp1524965aadampview=578812
lyricsycomapiapiphpi=KEYampa=Rihannaampt=Umbrella
16
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ echo $lyricsfly_key = PASTE YOUR KEY HERE gt lyricsfly_keyrb
17
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ irbrequire nethttprequire rexmldocumentrequire lyricsfly_keyurl = httplyricsflycomapiapiphpa=Rihannaampt=Umbrellaampi=$lyricsfly_keyresult = NetHTTPget_response(URIparse(url))response = REXMLDocumentnew(resultbody)elements[tx]puts responsetext
18
Retrieving multiple lyrics
e code is included in the le clyricsy_1py
e script clyricsy_2rb allows to specify the artist name and track title
$ ruby lyricsfly_1rb =raquo You have my heart[br] And well never be
$ ruby lyricsfly_2rb John Lennon Imagine
=raquo Imagine theres no Heaven
Its easy if you try
No Hell below us
19
Lyrics-based analysis
Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Textual features of lyrics are related to the genre
Hip-hop lyrics have more lsquorsquo than Country ones
Evaluated on 29 Hip-hop and 41 Country songs
Does this hold with larger data sets
20
Repeating the experiment
music web API 1
lsquoCountryrsquo and lsquoHip-hoprsquo
List songs by genre
music web API 2
List lyrics by genre Count lsquorsquo by genre
21
Lastfm has 4M songs classied by tagsgenres
Retrieving songs by genre
lastfmmusic+tagcountry lastfmapishowservice=285
22
Lastfm has 4M songs classied by tagsgenres
wsaudioscrobblercom20method=taggettoptracksamp
tag=discoamp api_key=KEY
Retrieving songs by genre
lastfmmusic+tagcountry
23
e code is included in the le clyricsy_3rb
require nethttprequire rexmldocumentrequire Filedirname(__FILE__)lyricsfly_keyrequire Filedirname(__FILE__)lastfm_key
def get_lyrics(artist_and_title) artisttitle = artist_and_titlecollect|arg| arggsub([^a-zA-Z0-9]25)
url = httplyricsflycomapiapiphp url += a=artistampt=titleampi=$lyricsfly_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody)elements[tx] responsetextgsub([br] ) unless responsenilend
Combining two music web APIs
24
Finally $ ruby lyricsfly_3rb country hip-hop
def get_artists_and_titles(genre) url = httpwsaudioscrobblercom20method= url += taggettoptracksamptag=genreampapi_key=$lastfm_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody) responseelementscollect(track) do |track| [ trackelements[artist]elements[name]text trackelements[name]text ] end unless responsenilend
ARGVeach do |genre| tracks = get_artists_and_titles(genre) lyrics = trackscollect|track| get_lyrics(track)compact qm = lyricsinject(00) |qm lyric| qm + lyriccount() p genre avg question marks 2f (qmlyricslength)end
Combining two music web APIs
25
Lessons learnt
Hip-hop lyrics have more ldquordquo than Country ones
Any programming language with libraries to retrieve pages and parse XML can do the work
Data from dierent web APIs can be aggregated
A mash-up application can uncover hidden musical relationships among dierent domains
26
A more advanced mash-up
ismir2009beneldsnetgmapradio
27
From instance to concept
ere is no limit to the chain of API calls
To connect even more resources unique identiers work better than ambiguous names
Many web sites identify musical objects through a specic set of Musicbrainz IDs which allow to easily match the same item in multiple places
28
e Linking Open Data project is a prominent attempt at expressing and connecting objects of dierent domains using semantic web technology
Music and web ontologies
linkeddataorg musicontologycom
29
3REVEALING
TRENDS
30
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Welcome
ismir2009beneldsnet
Claudio BaccigalupoIIIAndashCSIC
Barcelona Spain
Ben FieldsGoldsmiths
University of London UK
2
You will write code for real MIR applications
exploring multiple languages and web sites
Itrsquos a hands-on tutorial
1 Evaluating hypotheses
2 Comparing lyrics by genre
3 Revealing trends
4 Performing audio analysis
5 Capturing social data
6 Collecting feedback
3
Source code archive
All the code examples are included in the le ismir2009beneldsnettutorialzip
Unzip the archive and open a shell in its folder en check that Python and Ruby are installed
Or download them frompythonorg and ruby-langorg
$ ruby --version$ python --version
4
1EVALUATING
HYPOTHESES
5
The evaluation process
Say you have built theldquoultimate genre recogniserrdquo
How would you evaluate its precision rate
1 Build a local collection of varied songs
2 Assign them with a genre label
3 Run the algorithm and check its output
genre recogniser
song genre
A cumbersome boring process
6
The traditional approach
Evaluate with a few manually labelled examples
e ldquoultimaterdquo recogniser or just a coincidence
$ cd ltPACKAGE PATHgtc
$ python isrockpy mrockmp3
$ python isrockpy mmetalmp3
$ python isrockpy mvocalmp3
$ python isrockpy mexperimentalmp3
=raquo True
=raquo True
=raquo False
=raquo False
7
The web-based approach
e web contains thousands of genre-classied songs that can be legally downloaded for free
Jamendo only includes 170K songs by 14K artists
8
A web API allows to retrieve data in a compact format from a site by means of simple queries
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
From browser to web API
jamendocomenalbums
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
9
From browser to web API
Documentation at developerjamendocom
API query to retrieve 50 random Rock songs apijamendocomget2streamtrackplaintag_idstr=rockampn=50amporder=random_desc
10
Creating a Python script
Verify the genre recogniser on Jamendo tracks
$ pythonfrom urllib import urlopenfrom isrock import isRockquery = httpapijamendocomget2streamtrackplainn=50amptag_idstr=rockamporder=random_descresult = urlopen(query)read()songs = resultsplit()rock = [isRock(song) for song in songs]print The ratio of rock songs is 2f (float(rockcount(True))len(songs))
11
Evaluating the genre recogniser
e code is included in the le cjamendo_1py
e script cjamendo_2py allows to specify the number of tests and multiple genres at once
e result shows that the isRock recogniser is not able to distinguish Rock from other genres
$ python jamendo_1py
$ python jamendo_2py 30 rock jazz country rnb
=raquo The ratio of rock songs is 058
12
Lessons learnt
Music data can easily be retrieved from the web
ousands of songs can be downloaded for free
Songs in Jamendo already have a genre label attached so you do not have to decide for one
Working with a web API simplies the process
Dierent musical objects are available (songs artists albums playlists users) to work on
13
2COMPARING
LYRICS BY GENRE
14
The relevance of lyrics
Recent interest for lyrics-based analysis
1 Knees Schedl Widmer Multiple Lyrics Alignment Automatic Retrieval of Song Lyrics 2005
2 Geleijnse Korst Ecient Lyrics Extraction from the web 2006
3 Kleedorfer Knees Pohle Oh Oh Oh Whoah Towards Automatic Topic Detection in Song Lyrics 2008
4 Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Lyrics were retrieved without using any web API
15
Lyrics$y provides a web API to retrieve lyrics
An online song lyrics database
lyricsycomsearchviewphp1524965aadampview=578812
lyricsycomapiapiphpi=KEYampa=Rihannaampt=Umbrella
16
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ echo $lyricsfly_key = PASTE YOUR KEY HERE gt lyricsfly_keyrb
17
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ irbrequire nethttprequire rexmldocumentrequire lyricsfly_keyurl = httplyricsflycomapiapiphpa=Rihannaampt=Umbrellaampi=$lyricsfly_keyresult = NetHTTPget_response(URIparse(url))response = REXMLDocumentnew(resultbody)elements[tx]puts responsetext
18
Retrieving multiple lyrics
e code is included in the le clyricsy_1py
e script clyricsy_2rb allows to specify the artist name and track title
$ ruby lyricsfly_1rb =raquo You have my heart[br] And well never be
$ ruby lyricsfly_2rb John Lennon Imagine
=raquo Imagine theres no Heaven
Its easy if you try
No Hell below us
19
Lyrics-based analysis
Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Textual features of lyrics are related to the genre
Hip-hop lyrics have more lsquorsquo than Country ones
Evaluated on 29 Hip-hop and 41 Country songs
Does this hold with larger data sets
20
Repeating the experiment
music web API 1
lsquoCountryrsquo and lsquoHip-hoprsquo
List songs by genre
music web API 2
List lyrics by genre Count lsquorsquo by genre
21
Lastfm has 4M songs classied by tagsgenres
Retrieving songs by genre
lastfmmusic+tagcountry lastfmapishowservice=285
22
Lastfm has 4M songs classied by tagsgenres
wsaudioscrobblercom20method=taggettoptracksamp
tag=discoamp api_key=KEY
Retrieving songs by genre
lastfmmusic+tagcountry
23
e code is included in the le clyricsy_3rb
require nethttprequire rexmldocumentrequire Filedirname(__FILE__)lyricsfly_keyrequire Filedirname(__FILE__)lastfm_key
def get_lyrics(artist_and_title) artisttitle = artist_and_titlecollect|arg| arggsub([^a-zA-Z0-9]25)
url = httplyricsflycomapiapiphp url += a=artistampt=titleampi=$lyricsfly_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody)elements[tx] responsetextgsub([br] ) unless responsenilend
Combining two music web APIs
24
Finally $ ruby lyricsfly_3rb country hip-hop
def get_artists_and_titles(genre) url = httpwsaudioscrobblercom20method= url += taggettoptracksamptag=genreampapi_key=$lastfm_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody) responseelementscollect(track) do |track| [ trackelements[artist]elements[name]text trackelements[name]text ] end unless responsenilend
ARGVeach do |genre| tracks = get_artists_and_titles(genre) lyrics = trackscollect|track| get_lyrics(track)compact qm = lyricsinject(00) |qm lyric| qm + lyriccount() p genre avg question marks 2f (qmlyricslength)end
Combining two music web APIs
25
Lessons learnt
Hip-hop lyrics have more ldquordquo than Country ones
Any programming language with libraries to retrieve pages and parse XML can do the work
Data from dierent web APIs can be aggregated
A mash-up application can uncover hidden musical relationships among dierent domains
26
A more advanced mash-up
ismir2009beneldsnetgmapradio
27
From instance to concept
ere is no limit to the chain of API calls
To connect even more resources unique identiers work better than ambiguous names
Many web sites identify musical objects through a specic set of Musicbrainz IDs which allow to easily match the same item in multiple places
28
e Linking Open Data project is a prominent attempt at expressing and connecting objects of dierent domains using semantic web technology
Music and web ontologies
linkeddataorg musicontologycom
29
3REVEALING
TRENDS
30
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
You will write code for real MIR applications
exploring multiple languages and web sites
Itrsquos a hands-on tutorial
1 Evaluating hypotheses
2 Comparing lyrics by genre
3 Revealing trends
4 Performing audio analysis
5 Capturing social data
6 Collecting feedback
3
Source code archive
All the code examples are included in the le ismir2009beneldsnettutorialzip
Unzip the archive and open a shell in its folder en check that Python and Ruby are installed
Or download them frompythonorg and ruby-langorg
$ ruby --version$ python --version
4
1EVALUATING
HYPOTHESES
5
The evaluation process
Say you have built theldquoultimate genre recogniserrdquo
How would you evaluate its precision rate
1 Build a local collection of varied songs
2 Assign them with a genre label
3 Run the algorithm and check its output
genre recogniser
song genre
A cumbersome boring process
6
The traditional approach
Evaluate with a few manually labelled examples
e ldquoultimaterdquo recogniser or just a coincidence
$ cd ltPACKAGE PATHgtc
$ python isrockpy mrockmp3
$ python isrockpy mmetalmp3
$ python isrockpy mvocalmp3
$ python isrockpy mexperimentalmp3
=raquo True
=raquo True
=raquo False
=raquo False
7
The web-based approach
e web contains thousands of genre-classied songs that can be legally downloaded for free
Jamendo only includes 170K songs by 14K artists
8
A web API allows to retrieve data in a compact format from a site by means of simple queries
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
From browser to web API
jamendocomenalbums
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
9
From browser to web API
Documentation at developerjamendocom
API query to retrieve 50 random Rock songs apijamendocomget2streamtrackplaintag_idstr=rockampn=50amporder=random_desc
10
Creating a Python script
Verify the genre recogniser on Jamendo tracks
$ pythonfrom urllib import urlopenfrom isrock import isRockquery = httpapijamendocomget2streamtrackplainn=50amptag_idstr=rockamporder=random_descresult = urlopen(query)read()songs = resultsplit()rock = [isRock(song) for song in songs]print The ratio of rock songs is 2f (float(rockcount(True))len(songs))
11
Evaluating the genre recogniser
e code is included in the le cjamendo_1py
e script cjamendo_2py allows to specify the number of tests and multiple genres at once
e result shows that the isRock recogniser is not able to distinguish Rock from other genres
$ python jamendo_1py
$ python jamendo_2py 30 rock jazz country rnb
=raquo The ratio of rock songs is 058
12
Lessons learnt
Music data can easily be retrieved from the web
ousands of songs can be downloaded for free
Songs in Jamendo already have a genre label attached so you do not have to decide for one
Working with a web API simplies the process
Dierent musical objects are available (songs artists albums playlists users) to work on
13
2COMPARING
LYRICS BY GENRE
14
The relevance of lyrics
Recent interest for lyrics-based analysis
1 Knees Schedl Widmer Multiple Lyrics Alignment Automatic Retrieval of Song Lyrics 2005
2 Geleijnse Korst Ecient Lyrics Extraction from the web 2006
3 Kleedorfer Knees Pohle Oh Oh Oh Whoah Towards Automatic Topic Detection in Song Lyrics 2008
4 Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Lyrics were retrieved without using any web API
15
Lyrics$y provides a web API to retrieve lyrics
An online song lyrics database
lyricsycomsearchviewphp1524965aadampview=578812
lyricsycomapiapiphpi=KEYampa=Rihannaampt=Umbrella
16
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ echo $lyricsfly_key = PASTE YOUR KEY HERE gt lyricsfly_keyrb
17
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ irbrequire nethttprequire rexmldocumentrequire lyricsfly_keyurl = httplyricsflycomapiapiphpa=Rihannaampt=Umbrellaampi=$lyricsfly_keyresult = NetHTTPget_response(URIparse(url))response = REXMLDocumentnew(resultbody)elements[tx]puts responsetext
18
Retrieving multiple lyrics
e code is included in the le clyricsy_1py
e script clyricsy_2rb allows to specify the artist name and track title
$ ruby lyricsfly_1rb =raquo You have my heart[br] And well never be
$ ruby lyricsfly_2rb John Lennon Imagine
=raquo Imagine theres no Heaven
Its easy if you try
No Hell below us
19
Lyrics-based analysis
Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Textual features of lyrics are related to the genre
Hip-hop lyrics have more lsquorsquo than Country ones
Evaluated on 29 Hip-hop and 41 Country songs
Does this hold with larger data sets
20
Repeating the experiment
music web API 1
lsquoCountryrsquo and lsquoHip-hoprsquo
List songs by genre
music web API 2
List lyrics by genre Count lsquorsquo by genre
21
Lastfm has 4M songs classied by tagsgenres
Retrieving songs by genre
lastfmmusic+tagcountry lastfmapishowservice=285
22
Lastfm has 4M songs classied by tagsgenres
wsaudioscrobblercom20method=taggettoptracksamp
tag=discoamp api_key=KEY
Retrieving songs by genre
lastfmmusic+tagcountry
23
e code is included in the le clyricsy_3rb
require nethttprequire rexmldocumentrequire Filedirname(__FILE__)lyricsfly_keyrequire Filedirname(__FILE__)lastfm_key
def get_lyrics(artist_and_title) artisttitle = artist_and_titlecollect|arg| arggsub([^a-zA-Z0-9]25)
url = httplyricsflycomapiapiphp url += a=artistampt=titleampi=$lyricsfly_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody)elements[tx] responsetextgsub([br] ) unless responsenilend
Combining two music web APIs
24
Finally $ ruby lyricsfly_3rb country hip-hop
def get_artists_and_titles(genre) url = httpwsaudioscrobblercom20method= url += taggettoptracksamptag=genreampapi_key=$lastfm_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody) responseelementscollect(track) do |track| [ trackelements[artist]elements[name]text trackelements[name]text ] end unless responsenilend
ARGVeach do |genre| tracks = get_artists_and_titles(genre) lyrics = trackscollect|track| get_lyrics(track)compact qm = lyricsinject(00) |qm lyric| qm + lyriccount() p genre avg question marks 2f (qmlyricslength)end
Combining two music web APIs
25
Lessons learnt
Hip-hop lyrics have more ldquordquo than Country ones
Any programming language with libraries to retrieve pages and parse XML can do the work
Data from dierent web APIs can be aggregated
A mash-up application can uncover hidden musical relationships among dierent domains
26
A more advanced mash-up
ismir2009beneldsnetgmapradio
27
From instance to concept
ere is no limit to the chain of API calls
To connect even more resources unique identiers work better than ambiguous names
Many web sites identify musical objects through a specic set of Musicbrainz IDs which allow to easily match the same item in multiple places
28
e Linking Open Data project is a prominent attempt at expressing and connecting objects of dierent domains using semantic web technology
Music and web ontologies
linkeddataorg musicontologycom
29
3REVEALING
TRENDS
30
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Source code archive
All the code examples are included in the le ismir2009beneldsnettutorialzip
Unzip the archive and open a shell in its folder en check that Python and Ruby are installed
Or download them frompythonorg and ruby-langorg
$ ruby --version$ python --version
4
1EVALUATING
HYPOTHESES
5
The evaluation process
Say you have built theldquoultimate genre recogniserrdquo
How would you evaluate its precision rate
1 Build a local collection of varied songs
2 Assign them with a genre label
3 Run the algorithm and check its output
genre recogniser
song genre
A cumbersome boring process
6
The traditional approach
Evaluate with a few manually labelled examples
e ldquoultimaterdquo recogniser or just a coincidence
$ cd ltPACKAGE PATHgtc
$ python isrockpy mrockmp3
$ python isrockpy mmetalmp3
$ python isrockpy mvocalmp3
$ python isrockpy mexperimentalmp3
=raquo True
=raquo True
=raquo False
=raquo False
7
The web-based approach
e web contains thousands of genre-classied songs that can be legally downloaded for free
Jamendo only includes 170K songs by 14K artists
8
A web API allows to retrieve data in a compact format from a site by means of simple queries
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
From browser to web API
jamendocomenalbums
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
9
From browser to web API
Documentation at developerjamendocom
API query to retrieve 50 random Rock songs apijamendocomget2streamtrackplaintag_idstr=rockampn=50amporder=random_desc
10
Creating a Python script
Verify the genre recogniser on Jamendo tracks
$ pythonfrom urllib import urlopenfrom isrock import isRockquery = httpapijamendocomget2streamtrackplainn=50amptag_idstr=rockamporder=random_descresult = urlopen(query)read()songs = resultsplit()rock = [isRock(song) for song in songs]print The ratio of rock songs is 2f (float(rockcount(True))len(songs))
11
Evaluating the genre recogniser
e code is included in the le cjamendo_1py
e script cjamendo_2py allows to specify the number of tests and multiple genres at once
e result shows that the isRock recogniser is not able to distinguish Rock from other genres
$ python jamendo_1py
$ python jamendo_2py 30 rock jazz country rnb
=raquo The ratio of rock songs is 058
12
Lessons learnt
Music data can easily be retrieved from the web
ousands of songs can be downloaded for free
Songs in Jamendo already have a genre label attached so you do not have to decide for one
Working with a web API simplies the process
Dierent musical objects are available (songs artists albums playlists users) to work on
13
2COMPARING
LYRICS BY GENRE
14
The relevance of lyrics
Recent interest for lyrics-based analysis
1 Knees Schedl Widmer Multiple Lyrics Alignment Automatic Retrieval of Song Lyrics 2005
2 Geleijnse Korst Ecient Lyrics Extraction from the web 2006
3 Kleedorfer Knees Pohle Oh Oh Oh Whoah Towards Automatic Topic Detection in Song Lyrics 2008
4 Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Lyrics were retrieved without using any web API
15
Lyrics$y provides a web API to retrieve lyrics
An online song lyrics database
lyricsycomsearchviewphp1524965aadampview=578812
lyricsycomapiapiphpi=KEYampa=Rihannaampt=Umbrella
16
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ echo $lyricsfly_key = PASTE YOUR KEY HERE gt lyricsfly_keyrb
17
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ irbrequire nethttprequire rexmldocumentrequire lyricsfly_keyurl = httplyricsflycomapiapiphpa=Rihannaampt=Umbrellaampi=$lyricsfly_keyresult = NetHTTPget_response(URIparse(url))response = REXMLDocumentnew(resultbody)elements[tx]puts responsetext
18
Retrieving multiple lyrics
e code is included in the le clyricsy_1py
e script clyricsy_2rb allows to specify the artist name and track title
$ ruby lyricsfly_1rb =raquo You have my heart[br] And well never be
$ ruby lyricsfly_2rb John Lennon Imagine
=raquo Imagine theres no Heaven
Its easy if you try
No Hell below us
19
Lyrics-based analysis
Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Textual features of lyrics are related to the genre
Hip-hop lyrics have more lsquorsquo than Country ones
Evaluated on 29 Hip-hop and 41 Country songs
Does this hold with larger data sets
20
Repeating the experiment
music web API 1
lsquoCountryrsquo and lsquoHip-hoprsquo
List songs by genre
music web API 2
List lyrics by genre Count lsquorsquo by genre
21
Lastfm has 4M songs classied by tagsgenres
Retrieving songs by genre
lastfmmusic+tagcountry lastfmapishowservice=285
22
Lastfm has 4M songs classied by tagsgenres
wsaudioscrobblercom20method=taggettoptracksamp
tag=discoamp api_key=KEY
Retrieving songs by genre
lastfmmusic+tagcountry
23
e code is included in the le clyricsy_3rb
require nethttprequire rexmldocumentrequire Filedirname(__FILE__)lyricsfly_keyrequire Filedirname(__FILE__)lastfm_key
def get_lyrics(artist_and_title) artisttitle = artist_and_titlecollect|arg| arggsub([^a-zA-Z0-9]25)
url = httplyricsflycomapiapiphp url += a=artistampt=titleampi=$lyricsfly_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody)elements[tx] responsetextgsub([br] ) unless responsenilend
Combining two music web APIs
24
Finally $ ruby lyricsfly_3rb country hip-hop
def get_artists_and_titles(genre) url = httpwsaudioscrobblercom20method= url += taggettoptracksamptag=genreampapi_key=$lastfm_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody) responseelementscollect(track) do |track| [ trackelements[artist]elements[name]text trackelements[name]text ] end unless responsenilend
ARGVeach do |genre| tracks = get_artists_and_titles(genre) lyrics = trackscollect|track| get_lyrics(track)compact qm = lyricsinject(00) |qm lyric| qm + lyriccount() p genre avg question marks 2f (qmlyricslength)end
Combining two music web APIs
25
Lessons learnt
Hip-hop lyrics have more ldquordquo than Country ones
Any programming language with libraries to retrieve pages and parse XML can do the work
Data from dierent web APIs can be aggregated
A mash-up application can uncover hidden musical relationships among dierent domains
26
A more advanced mash-up
ismir2009beneldsnetgmapradio
27
From instance to concept
ere is no limit to the chain of API calls
To connect even more resources unique identiers work better than ambiguous names
Many web sites identify musical objects through a specic set of Musicbrainz IDs which allow to easily match the same item in multiple places
28
e Linking Open Data project is a prominent attempt at expressing and connecting objects of dierent domains using semantic web technology
Music and web ontologies
linkeddataorg musicontologycom
29
3REVEALING
TRENDS
30
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
1EVALUATING
HYPOTHESES
5
The evaluation process
Say you have built theldquoultimate genre recogniserrdquo
How would you evaluate its precision rate
1 Build a local collection of varied songs
2 Assign them with a genre label
3 Run the algorithm and check its output
genre recogniser
song genre
A cumbersome boring process
6
The traditional approach
Evaluate with a few manually labelled examples
e ldquoultimaterdquo recogniser or just a coincidence
$ cd ltPACKAGE PATHgtc
$ python isrockpy mrockmp3
$ python isrockpy mmetalmp3
$ python isrockpy mvocalmp3
$ python isrockpy mexperimentalmp3
=raquo True
=raquo True
=raquo False
=raquo False
7
The web-based approach
e web contains thousands of genre-classied songs that can be legally downloaded for free
Jamendo only includes 170K songs by 14K artists
8
A web API allows to retrieve data in a compact format from a site by means of simple queries
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
From browser to web API
jamendocomenalbums
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
9
From browser to web API
Documentation at developerjamendocom
API query to retrieve 50 random Rock songs apijamendocomget2streamtrackplaintag_idstr=rockampn=50amporder=random_desc
10
Creating a Python script
Verify the genre recogniser on Jamendo tracks
$ pythonfrom urllib import urlopenfrom isrock import isRockquery = httpapijamendocomget2streamtrackplainn=50amptag_idstr=rockamporder=random_descresult = urlopen(query)read()songs = resultsplit()rock = [isRock(song) for song in songs]print The ratio of rock songs is 2f (float(rockcount(True))len(songs))
11
Evaluating the genre recogniser
e code is included in the le cjamendo_1py
e script cjamendo_2py allows to specify the number of tests and multiple genres at once
e result shows that the isRock recogniser is not able to distinguish Rock from other genres
$ python jamendo_1py
$ python jamendo_2py 30 rock jazz country rnb
=raquo The ratio of rock songs is 058
12
Lessons learnt
Music data can easily be retrieved from the web
ousands of songs can be downloaded for free
Songs in Jamendo already have a genre label attached so you do not have to decide for one
Working with a web API simplies the process
Dierent musical objects are available (songs artists albums playlists users) to work on
13
2COMPARING
LYRICS BY GENRE
14
The relevance of lyrics
Recent interest for lyrics-based analysis
1 Knees Schedl Widmer Multiple Lyrics Alignment Automatic Retrieval of Song Lyrics 2005
2 Geleijnse Korst Ecient Lyrics Extraction from the web 2006
3 Kleedorfer Knees Pohle Oh Oh Oh Whoah Towards Automatic Topic Detection in Song Lyrics 2008
4 Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Lyrics were retrieved without using any web API
15
Lyrics$y provides a web API to retrieve lyrics
An online song lyrics database
lyricsycomsearchviewphp1524965aadampview=578812
lyricsycomapiapiphpi=KEYampa=Rihannaampt=Umbrella
16
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ echo $lyricsfly_key = PASTE YOUR KEY HERE gt lyricsfly_keyrb
17
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ irbrequire nethttprequire rexmldocumentrequire lyricsfly_keyurl = httplyricsflycomapiapiphpa=Rihannaampt=Umbrellaampi=$lyricsfly_keyresult = NetHTTPget_response(URIparse(url))response = REXMLDocumentnew(resultbody)elements[tx]puts responsetext
18
Retrieving multiple lyrics
e code is included in the le clyricsy_1py
e script clyricsy_2rb allows to specify the artist name and track title
$ ruby lyricsfly_1rb =raquo You have my heart[br] And well never be
$ ruby lyricsfly_2rb John Lennon Imagine
=raquo Imagine theres no Heaven
Its easy if you try
No Hell below us
19
Lyrics-based analysis
Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Textual features of lyrics are related to the genre
Hip-hop lyrics have more lsquorsquo than Country ones
Evaluated on 29 Hip-hop and 41 Country songs
Does this hold with larger data sets
20
Repeating the experiment
music web API 1
lsquoCountryrsquo and lsquoHip-hoprsquo
List songs by genre
music web API 2
List lyrics by genre Count lsquorsquo by genre
21
Lastfm has 4M songs classied by tagsgenres
Retrieving songs by genre
lastfmmusic+tagcountry lastfmapishowservice=285
22
Lastfm has 4M songs classied by tagsgenres
wsaudioscrobblercom20method=taggettoptracksamp
tag=discoamp api_key=KEY
Retrieving songs by genre
lastfmmusic+tagcountry
23
e code is included in the le clyricsy_3rb
require nethttprequire rexmldocumentrequire Filedirname(__FILE__)lyricsfly_keyrequire Filedirname(__FILE__)lastfm_key
def get_lyrics(artist_and_title) artisttitle = artist_and_titlecollect|arg| arggsub([^a-zA-Z0-9]25)
url = httplyricsflycomapiapiphp url += a=artistampt=titleampi=$lyricsfly_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody)elements[tx] responsetextgsub([br] ) unless responsenilend
Combining two music web APIs
24
Finally $ ruby lyricsfly_3rb country hip-hop
def get_artists_and_titles(genre) url = httpwsaudioscrobblercom20method= url += taggettoptracksamptag=genreampapi_key=$lastfm_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody) responseelementscollect(track) do |track| [ trackelements[artist]elements[name]text trackelements[name]text ] end unless responsenilend
ARGVeach do |genre| tracks = get_artists_and_titles(genre) lyrics = trackscollect|track| get_lyrics(track)compact qm = lyricsinject(00) |qm lyric| qm + lyriccount() p genre avg question marks 2f (qmlyricslength)end
Combining two music web APIs
25
Lessons learnt
Hip-hop lyrics have more ldquordquo than Country ones
Any programming language with libraries to retrieve pages and parse XML can do the work
Data from dierent web APIs can be aggregated
A mash-up application can uncover hidden musical relationships among dierent domains
26
A more advanced mash-up
ismir2009beneldsnetgmapradio
27
From instance to concept
ere is no limit to the chain of API calls
To connect even more resources unique identiers work better than ambiguous names
Many web sites identify musical objects through a specic set of Musicbrainz IDs which allow to easily match the same item in multiple places
28
e Linking Open Data project is a prominent attempt at expressing and connecting objects of dierent domains using semantic web technology
Music and web ontologies
linkeddataorg musicontologycom
29
3REVEALING
TRENDS
30
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
The evaluation process
Say you have built theldquoultimate genre recogniserrdquo
How would you evaluate its precision rate
1 Build a local collection of varied songs
2 Assign them with a genre label
3 Run the algorithm and check its output
genre recogniser
song genre
A cumbersome boring process
6
The traditional approach
Evaluate with a few manually labelled examples
e ldquoultimaterdquo recogniser or just a coincidence
$ cd ltPACKAGE PATHgtc
$ python isrockpy mrockmp3
$ python isrockpy mmetalmp3
$ python isrockpy mvocalmp3
$ python isrockpy mexperimentalmp3
=raquo True
=raquo True
=raquo False
=raquo False
7
The web-based approach
e web contains thousands of genre-classied songs that can be legally downloaded for free
Jamendo only includes 170K songs by 14K artists
8
A web API allows to retrieve data in a compact format from a site by means of simple queries
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
From browser to web API
jamendocomenalbums
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
9
From browser to web API
Documentation at developerjamendocom
API query to retrieve 50 random Rock songs apijamendocomget2streamtrackplaintag_idstr=rockampn=50amporder=random_desc
10
Creating a Python script
Verify the genre recogniser on Jamendo tracks
$ pythonfrom urllib import urlopenfrom isrock import isRockquery = httpapijamendocomget2streamtrackplainn=50amptag_idstr=rockamporder=random_descresult = urlopen(query)read()songs = resultsplit()rock = [isRock(song) for song in songs]print The ratio of rock songs is 2f (float(rockcount(True))len(songs))
11
Evaluating the genre recogniser
e code is included in the le cjamendo_1py
e script cjamendo_2py allows to specify the number of tests and multiple genres at once
e result shows that the isRock recogniser is not able to distinguish Rock from other genres
$ python jamendo_1py
$ python jamendo_2py 30 rock jazz country rnb
=raquo The ratio of rock songs is 058
12
Lessons learnt
Music data can easily be retrieved from the web
ousands of songs can be downloaded for free
Songs in Jamendo already have a genre label attached so you do not have to decide for one
Working with a web API simplies the process
Dierent musical objects are available (songs artists albums playlists users) to work on
13
2COMPARING
LYRICS BY GENRE
14
The relevance of lyrics
Recent interest for lyrics-based analysis
1 Knees Schedl Widmer Multiple Lyrics Alignment Automatic Retrieval of Song Lyrics 2005
2 Geleijnse Korst Ecient Lyrics Extraction from the web 2006
3 Kleedorfer Knees Pohle Oh Oh Oh Whoah Towards Automatic Topic Detection in Song Lyrics 2008
4 Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Lyrics were retrieved without using any web API
15
Lyrics$y provides a web API to retrieve lyrics
An online song lyrics database
lyricsycomsearchviewphp1524965aadampview=578812
lyricsycomapiapiphpi=KEYampa=Rihannaampt=Umbrella
16
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ echo $lyricsfly_key = PASTE YOUR KEY HERE gt lyricsfly_keyrb
17
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ irbrequire nethttprequire rexmldocumentrequire lyricsfly_keyurl = httplyricsflycomapiapiphpa=Rihannaampt=Umbrellaampi=$lyricsfly_keyresult = NetHTTPget_response(URIparse(url))response = REXMLDocumentnew(resultbody)elements[tx]puts responsetext
18
Retrieving multiple lyrics
e code is included in the le clyricsy_1py
e script clyricsy_2rb allows to specify the artist name and track title
$ ruby lyricsfly_1rb =raquo You have my heart[br] And well never be
$ ruby lyricsfly_2rb John Lennon Imagine
=raquo Imagine theres no Heaven
Its easy if you try
No Hell below us
19
Lyrics-based analysis
Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Textual features of lyrics are related to the genre
Hip-hop lyrics have more lsquorsquo than Country ones
Evaluated on 29 Hip-hop and 41 Country songs
Does this hold with larger data sets
20
Repeating the experiment
music web API 1
lsquoCountryrsquo and lsquoHip-hoprsquo
List songs by genre
music web API 2
List lyrics by genre Count lsquorsquo by genre
21
Lastfm has 4M songs classied by tagsgenres
Retrieving songs by genre
lastfmmusic+tagcountry lastfmapishowservice=285
22
Lastfm has 4M songs classied by tagsgenres
wsaudioscrobblercom20method=taggettoptracksamp
tag=discoamp api_key=KEY
Retrieving songs by genre
lastfmmusic+tagcountry
23
e code is included in the le clyricsy_3rb
require nethttprequire rexmldocumentrequire Filedirname(__FILE__)lyricsfly_keyrequire Filedirname(__FILE__)lastfm_key
def get_lyrics(artist_and_title) artisttitle = artist_and_titlecollect|arg| arggsub([^a-zA-Z0-9]25)
url = httplyricsflycomapiapiphp url += a=artistampt=titleampi=$lyricsfly_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody)elements[tx] responsetextgsub([br] ) unless responsenilend
Combining two music web APIs
24
Finally $ ruby lyricsfly_3rb country hip-hop
def get_artists_and_titles(genre) url = httpwsaudioscrobblercom20method= url += taggettoptracksamptag=genreampapi_key=$lastfm_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody) responseelementscollect(track) do |track| [ trackelements[artist]elements[name]text trackelements[name]text ] end unless responsenilend
ARGVeach do |genre| tracks = get_artists_and_titles(genre) lyrics = trackscollect|track| get_lyrics(track)compact qm = lyricsinject(00) |qm lyric| qm + lyriccount() p genre avg question marks 2f (qmlyricslength)end
Combining two music web APIs
25
Lessons learnt
Hip-hop lyrics have more ldquordquo than Country ones
Any programming language with libraries to retrieve pages and parse XML can do the work
Data from dierent web APIs can be aggregated
A mash-up application can uncover hidden musical relationships among dierent domains
26
A more advanced mash-up
ismir2009beneldsnetgmapradio
27
From instance to concept
ere is no limit to the chain of API calls
To connect even more resources unique identiers work better than ambiguous names
Many web sites identify musical objects through a specic set of Musicbrainz IDs which allow to easily match the same item in multiple places
28
e Linking Open Data project is a prominent attempt at expressing and connecting objects of dierent domains using semantic web technology
Music and web ontologies
linkeddataorg musicontologycom
29
3REVEALING
TRENDS
30
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
The traditional approach
Evaluate with a few manually labelled examples
e ldquoultimaterdquo recogniser or just a coincidence
$ cd ltPACKAGE PATHgtc
$ python isrockpy mrockmp3
$ python isrockpy mmetalmp3
$ python isrockpy mvocalmp3
$ python isrockpy mexperimentalmp3
=raquo True
=raquo True
=raquo False
=raquo False
7
The web-based approach
e web contains thousands of genre-classied songs that can be legally downloaded for free
Jamendo only includes 170K songs by 14K artists
8
A web API allows to retrieve data in a compact format from a site by means of simple queries
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
From browser to web API
jamendocomenalbums
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
9
From browser to web API
Documentation at developerjamendocom
API query to retrieve 50 random Rock songs apijamendocomget2streamtrackplaintag_idstr=rockampn=50amporder=random_desc
10
Creating a Python script
Verify the genre recogniser on Jamendo tracks
$ pythonfrom urllib import urlopenfrom isrock import isRockquery = httpapijamendocomget2streamtrackplainn=50amptag_idstr=rockamporder=random_descresult = urlopen(query)read()songs = resultsplit()rock = [isRock(song) for song in songs]print The ratio of rock songs is 2f (float(rockcount(True))len(songs))
11
Evaluating the genre recogniser
e code is included in the le cjamendo_1py
e script cjamendo_2py allows to specify the number of tests and multiple genres at once
e result shows that the isRock recogniser is not able to distinguish Rock from other genres
$ python jamendo_1py
$ python jamendo_2py 30 rock jazz country rnb
=raquo The ratio of rock songs is 058
12
Lessons learnt
Music data can easily be retrieved from the web
ousands of songs can be downloaded for free
Songs in Jamendo already have a genre label attached so you do not have to decide for one
Working with a web API simplies the process
Dierent musical objects are available (songs artists albums playlists users) to work on
13
2COMPARING
LYRICS BY GENRE
14
The relevance of lyrics
Recent interest for lyrics-based analysis
1 Knees Schedl Widmer Multiple Lyrics Alignment Automatic Retrieval of Song Lyrics 2005
2 Geleijnse Korst Ecient Lyrics Extraction from the web 2006
3 Kleedorfer Knees Pohle Oh Oh Oh Whoah Towards Automatic Topic Detection in Song Lyrics 2008
4 Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Lyrics were retrieved without using any web API
15
Lyrics$y provides a web API to retrieve lyrics
An online song lyrics database
lyricsycomsearchviewphp1524965aadampview=578812
lyricsycomapiapiphpi=KEYampa=Rihannaampt=Umbrella
16
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ echo $lyricsfly_key = PASTE YOUR KEY HERE gt lyricsfly_keyrb
17
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ irbrequire nethttprequire rexmldocumentrequire lyricsfly_keyurl = httplyricsflycomapiapiphpa=Rihannaampt=Umbrellaampi=$lyricsfly_keyresult = NetHTTPget_response(URIparse(url))response = REXMLDocumentnew(resultbody)elements[tx]puts responsetext
18
Retrieving multiple lyrics
e code is included in the le clyricsy_1py
e script clyricsy_2rb allows to specify the artist name and track title
$ ruby lyricsfly_1rb =raquo You have my heart[br] And well never be
$ ruby lyricsfly_2rb John Lennon Imagine
=raquo Imagine theres no Heaven
Its easy if you try
No Hell below us
19
Lyrics-based analysis
Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Textual features of lyrics are related to the genre
Hip-hop lyrics have more lsquorsquo than Country ones
Evaluated on 29 Hip-hop and 41 Country songs
Does this hold with larger data sets
20
Repeating the experiment
music web API 1
lsquoCountryrsquo and lsquoHip-hoprsquo
List songs by genre
music web API 2
List lyrics by genre Count lsquorsquo by genre
21
Lastfm has 4M songs classied by tagsgenres
Retrieving songs by genre
lastfmmusic+tagcountry lastfmapishowservice=285
22
Lastfm has 4M songs classied by tagsgenres
wsaudioscrobblercom20method=taggettoptracksamp
tag=discoamp api_key=KEY
Retrieving songs by genre
lastfmmusic+tagcountry
23
e code is included in the le clyricsy_3rb
require nethttprequire rexmldocumentrequire Filedirname(__FILE__)lyricsfly_keyrequire Filedirname(__FILE__)lastfm_key
def get_lyrics(artist_and_title) artisttitle = artist_and_titlecollect|arg| arggsub([^a-zA-Z0-9]25)
url = httplyricsflycomapiapiphp url += a=artistampt=titleampi=$lyricsfly_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody)elements[tx] responsetextgsub([br] ) unless responsenilend
Combining two music web APIs
24
Finally $ ruby lyricsfly_3rb country hip-hop
def get_artists_and_titles(genre) url = httpwsaudioscrobblercom20method= url += taggettoptracksamptag=genreampapi_key=$lastfm_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody) responseelementscollect(track) do |track| [ trackelements[artist]elements[name]text trackelements[name]text ] end unless responsenilend
ARGVeach do |genre| tracks = get_artists_and_titles(genre) lyrics = trackscollect|track| get_lyrics(track)compact qm = lyricsinject(00) |qm lyric| qm + lyriccount() p genre avg question marks 2f (qmlyricslength)end
Combining two music web APIs
25
Lessons learnt
Hip-hop lyrics have more ldquordquo than Country ones
Any programming language with libraries to retrieve pages and parse XML can do the work
Data from dierent web APIs can be aggregated
A mash-up application can uncover hidden musical relationships among dierent domains
26
A more advanced mash-up
ismir2009beneldsnetgmapradio
27
From instance to concept
ere is no limit to the chain of API calls
To connect even more resources unique identiers work better than ambiguous names
Many web sites identify musical objects through a specic set of Musicbrainz IDs which allow to easily match the same item in multiple places
28
e Linking Open Data project is a prominent attempt at expressing and connecting objects of dierent domains using semantic web technology
Music and web ontologies
linkeddataorg musicontologycom
29
3REVEALING
TRENDS
30
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
The web-based approach
e web contains thousands of genre-classied songs that can be legally downloaded for free
Jamendo only includes 170K songs by 14K artists
8
A web API allows to retrieve data in a compact format from a site by means of simple queries
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
From browser to web API
jamendocomenalbums
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
9
From browser to web API
Documentation at developerjamendocom
API query to retrieve 50 random Rock songs apijamendocomget2streamtrackplaintag_idstr=rockampn=50amporder=random_desc
10
Creating a Python script
Verify the genre recogniser on Jamendo tracks
$ pythonfrom urllib import urlopenfrom isrock import isRockquery = httpapijamendocomget2streamtrackplainn=50amptag_idstr=rockamporder=random_descresult = urlopen(query)read()songs = resultsplit()rock = [isRock(song) for song in songs]print The ratio of rock songs is 2f (float(rockcount(True))len(songs))
11
Evaluating the genre recogniser
e code is included in the le cjamendo_1py
e script cjamendo_2py allows to specify the number of tests and multiple genres at once
e result shows that the isRock recogniser is not able to distinguish Rock from other genres
$ python jamendo_1py
$ python jamendo_2py 30 rock jazz country rnb
=raquo The ratio of rock songs is 058
12
Lessons learnt
Music data can easily be retrieved from the web
ousands of songs can be downloaded for free
Songs in Jamendo already have a genre label attached so you do not have to decide for one
Working with a web API simplies the process
Dierent musical objects are available (songs artists albums playlists users) to work on
13
2COMPARING
LYRICS BY GENRE
14
The relevance of lyrics
Recent interest for lyrics-based analysis
1 Knees Schedl Widmer Multiple Lyrics Alignment Automatic Retrieval of Song Lyrics 2005
2 Geleijnse Korst Ecient Lyrics Extraction from the web 2006
3 Kleedorfer Knees Pohle Oh Oh Oh Whoah Towards Automatic Topic Detection in Song Lyrics 2008
4 Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Lyrics were retrieved without using any web API
15
Lyrics$y provides a web API to retrieve lyrics
An online song lyrics database
lyricsycomsearchviewphp1524965aadampview=578812
lyricsycomapiapiphpi=KEYampa=Rihannaampt=Umbrella
16
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ echo $lyricsfly_key = PASTE YOUR KEY HERE gt lyricsfly_keyrb
17
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ irbrequire nethttprequire rexmldocumentrequire lyricsfly_keyurl = httplyricsflycomapiapiphpa=Rihannaampt=Umbrellaampi=$lyricsfly_keyresult = NetHTTPget_response(URIparse(url))response = REXMLDocumentnew(resultbody)elements[tx]puts responsetext
18
Retrieving multiple lyrics
e code is included in the le clyricsy_1py
e script clyricsy_2rb allows to specify the artist name and track title
$ ruby lyricsfly_1rb =raquo You have my heart[br] And well never be
$ ruby lyricsfly_2rb John Lennon Imagine
=raquo Imagine theres no Heaven
Its easy if you try
No Hell below us
19
Lyrics-based analysis
Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Textual features of lyrics are related to the genre
Hip-hop lyrics have more lsquorsquo than Country ones
Evaluated on 29 Hip-hop and 41 Country songs
Does this hold with larger data sets
20
Repeating the experiment
music web API 1
lsquoCountryrsquo and lsquoHip-hoprsquo
List songs by genre
music web API 2
List lyrics by genre Count lsquorsquo by genre
21
Lastfm has 4M songs classied by tagsgenres
Retrieving songs by genre
lastfmmusic+tagcountry lastfmapishowservice=285
22
Lastfm has 4M songs classied by tagsgenres
wsaudioscrobblercom20method=taggettoptracksamp
tag=discoamp api_key=KEY
Retrieving songs by genre
lastfmmusic+tagcountry
23
e code is included in the le clyricsy_3rb
require nethttprequire rexmldocumentrequire Filedirname(__FILE__)lyricsfly_keyrequire Filedirname(__FILE__)lastfm_key
def get_lyrics(artist_and_title) artisttitle = artist_and_titlecollect|arg| arggsub([^a-zA-Z0-9]25)
url = httplyricsflycomapiapiphp url += a=artistampt=titleampi=$lyricsfly_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody)elements[tx] responsetextgsub([br] ) unless responsenilend
Combining two music web APIs
24
Finally $ ruby lyricsfly_3rb country hip-hop
def get_artists_and_titles(genre) url = httpwsaudioscrobblercom20method= url += taggettoptracksamptag=genreampapi_key=$lastfm_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody) responseelementscollect(track) do |track| [ trackelements[artist]elements[name]text trackelements[name]text ] end unless responsenilend
ARGVeach do |genre| tracks = get_artists_and_titles(genre) lyrics = trackscollect|track| get_lyrics(track)compact qm = lyricsinject(00) |qm lyric| qm + lyriccount() p genre avg question marks 2f (qmlyricslength)end
Combining two music web APIs
25
Lessons learnt
Hip-hop lyrics have more ldquordquo than Country ones
Any programming language with libraries to retrieve pages and parse XML can do the work
Data from dierent web APIs can be aggregated
A mash-up application can uncover hidden musical relationships among dierent domains
26
A more advanced mash-up
ismir2009beneldsnetgmapradio
27
From instance to concept
ere is no limit to the chain of API calls
To connect even more resources unique identiers work better than ambiguous names
Many web sites identify musical objects through a specic set of Musicbrainz IDs which allow to easily match the same item in multiple places
28
e Linking Open Data project is a prominent attempt at expressing and connecting objects of dierent domains using semantic web technology
Music and web ontologies
linkeddataorg musicontologycom
29
3REVEALING
TRENDS
30
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
A web API allows to retrieve data in a compact format from a site by means of simple queries
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
From browser to web API
jamendocomenalbums
apijamendocomget2name+artist_namealbumplain
order=ratingmonth_desc
9
From browser to web API
Documentation at developerjamendocom
API query to retrieve 50 random Rock songs apijamendocomget2streamtrackplaintag_idstr=rockampn=50amporder=random_desc
10
Creating a Python script
Verify the genre recogniser on Jamendo tracks
$ pythonfrom urllib import urlopenfrom isrock import isRockquery = httpapijamendocomget2streamtrackplainn=50amptag_idstr=rockamporder=random_descresult = urlopen(query)read()songs = resultsplit()rock = [isRock(song) for song in songs]print The ratio of rock songs is 2f (float(rockcount(True))len(songs))
11
Evaluating the genre recogniser
e code is included in the le cjamendo_1py
e script cjamendo_2py allows to specify the number of tests and multiple genres at once
e result shows that the isRock recogniser is not able to distinguish Rock from other genres
$ python jamendo_1py
$ python jamendo_2py 30 rock jazz country rnb
=raquo The ratio of rock songs is 058
12
Lessons learnt
Music data can easily be retrieved from the web
ousands of songs can be downloaded for free
Songs in Jamendo already have a genre label attached so you do not have to decide for one
Working with a web API simplies the process
Dierent musical objects are available (songs artists albums playlists users) to work on
13
2COMPARING
LYRICS BY GENRE
14
The relevance of lyrics
Recent interest for lyrics-based analysis
1 Knees Schedl Widmer Multiple Lyrics Alignment Automatic Retrieval of Song Lyrics 2005
2 Geleijnse Korst Ecient Lyrics Extraction from the web 2006
3 Kleedorfer Knees Pohle Oh Oh Oh Whoah Towards Automatic Topic Detection in Song Lyrics 2008
4 Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Lyrics were retrieved without using any web API
15
Lyrics$y provides a web API to retrieve lyrics
An online song lyrics database
lyricsycomsearchviewphp1524965aadampview=578812
lyricsycomapiapiphpi=KEYampa=Rihannaampt=Umbrella
16
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ echo $lyricsfly_key = PASTE YOUR KEY HERE gt lyricsfly_keyrb
17
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ irbrequire nethttprequire rexmldocumentrequire lyricsfly_keyurl = httplyricsflycomapiapiphpa=Rihannaampt=Umbrellaampi=$lyricsfly_keyresult = NetHTTPget_response(URIparse(url))response = REXMLDocumentnew(resultbody)elements[tx]puts responsetext
18
Retrieving multiple lyrics
e code is included in the le clyricsy_1py
e script clyricsy_2rb allows to specify the artist name and track title
$ ruby lyricsfly_1rb =raquo You have my heart[br] And well never be
$ ruby lyricsfly_2rb John Lennon Imagine
=raquo Imagine theres no Heaven
Its easy if you try
No Hell below us
19
Lyrics-based analysis
Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Textual features of lyrics are related to the genre
Hip-hop lyrics have more lsquorsquo than Country ones
Evaluated on 29 Hip-hop and 41 Country songs
Does this hold with larger data sets
20
Repeating the experiment
music web API 1
lsquoCountryrsquo and lsquoHip-hoprsquo
List songs by genre
music web API 2
List lyrics by genre Count lsquorsquo by genre
21
Lastfm has 4M songs classied by tagsgenres
Retrieving songs by genre
lastfmmusic+tagcountry lastfmapishowservice=285
22
Lastfm has 4M songs classied by tagsgenres
wsaudioscrobblercom20method=taggettoptracksamp
tag=discoamp api_key=KEY
Retrieving songs by genre
lastfmmusic+tagcountry
23
e code is included in the le clyricsy_3rb
require nethttprequire rexmldocumentrequire Filedirname(__FILE__)lyricsfly_keyrequire Filedirname(__FILE__)lastfm_key
def get_lyrics(artist_and_title) artisttitle = artist_and_titlecollect|arg| arggsub([^a-zA-Z0-9]25)
url = httplyricsflycomapiapiphp url += a=artistampt=titleampi=$lyricsfly_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody)elements[tx] responsetextgsub([br] ) unless responsenilend
Combining two music web APIs
24
Finally $ ruby lyricsfly_3rb country hip-hop
def get_artists_and_titles(genre) url = httpwsaudioscrobblercom20method= url += taggettoptracksamptag=genreampapi_key=$lastfm_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody) responseelementscollect(track) do |track| [ trackelements[artist]elements[name]text trackelements[name]text ] end unless responsenilend
ARGVeach do |genre| tracks = get_artists_and_titles(genre) lyrics = trackscollect|track| get_lyrics(track)compact qm = lyricsinject(00) |qm lyric| qm + lyriccount() p genre avg question marks 2f (qmlyricslength)end
Combining two music web APIs
25
Lessons learnt
Hip-hop lyrics have more ldquordquo than Country ones
Any programming language with libraries to retrieve pages and parse XML can do the work
Data from dierent web APIs can be aggregated
A mash-up application can uncover hidden musical relationships among dierent domains
26
A more advanced mash-up
ismir2009beneldsnetgmapradio
27
From instance to concept
ere is no limit to the chain of API calls
To connect even more resources unique identiers work better than ambiguous names
Many web sites identify musical objects through a specic set of Musicbrainz IDs which allow to easily match the same item in multiple places
28
e Linking Open Data project is a prominent attempt at expressing and connecting objects of dierent domains using semantic web technology
Music and web ontologies
linkeddataorg musicontologycom
29
3REVEALING
TRENDS
30
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
From browser to web API
Documentation at developerjamendocom
API query to retrieve 50 random Rock songs apijamendocomget2streamtrackplaintag_idstr=rockampn=50amporder=random_desc
10
Creating a Python script
Verify the genre recogniser on Jamendo tracks
$ pythonfrom urllib import urlopenfrom isrock import isRockquery = httpapijamendocomget2streamtrackplainn=50amptag_idstr=rockamporder=random_descresult = urlopen(query)read()songs = resultsplit()rock = [isRock(song) for song in songs]print The ratio of rock songs is 2f (float(rockcount(True))len(songs))
11
Evaluating the genre recogniser
e code is included in the le cjamendo_1py
e script cjamendo_2py allows to specify the number of tests and multiple genres at once
e result shows that the isRock recogniser is not able to distinguish Rock from other genres
$ python jamendo_1py
$ python jamendo_2py 30 rock jazz country rnb
=raquo The ratio of rock songs is 058
12
Lessons learnt
Music data can easily be retrieved from the web
ousands of songs can be downloaded for free
Songs in Jamendo already have a genre label attached so you do not have to decide for one
Working with a web API simplies the process
Dierent musical objects are available (songs artists albums playlists users) to work on
13
2COMPARING
LYRICS BY GENRE
14
The relevance of lyrics
Recent interest for lyrics-based analysis
1 Knees Schedl Widmer Multiple Lyrics Alignment Automatic Retrieval of Song Lyrics 2005
2 Geleijnse Korst Ecient Lyrics Extraction from the web 2006
3 Kleedorfer Knees Pohle Oh Oh Oh Whoah Towards Automatic Topic Detection in Song Lyrics 2008
4 Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Lyrics were retrieved without using any web API
15
Lyrics$y provides a web API to retrieve lyrics
An online song lyrics database
lyricsycomsearchviewphp1524965aadampview=578812
lyricsycomapiapiphpi=KEYampa=Rihannaampt=Umbrella
16
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ echo $lyricsfly_key = PASTE YOUR KEY HERE gt lyricsfly_keyrb
17
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ irbrequire nethttprequire rexmldocumentrequire lyricsfly_keyurl = httplyricsflycomapiapiphpa=Rihannaampt=Umbrellaampi=$lyricsfly_keyresult = NetHTTPget_response(URIparse(url))response = REXMLDocumentnew(resultbody)elements[tx]puts responsetext
18
Retrieving multiple lyrics
e code is included in the le clyricsy_1py
e script clyricsy_2rb allows to specify the artist name and track title
$ ruby lyricsfly_1rb =raquo You have my heart[br] And well never be
$ ruby lyricsfly_2rb John Lennon Imagine
=raquo Imagine theres no Heaven
Its easy if you try
No Hell below us
19
Lyrics-based analysis
Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Textual features of lyrics are related to the genre
Hip-hop lyrics have more lsquorsquo than Country ones
Evaluated on 29 Hip-hop and 41 Country songs
Does this hold with larger data sets
20
Repeating the experiment
music web API 1
lsquoCountryrsquo and lsquoHip-hoprsquo
List songs by genre
music web API 2
List lyrics by genre Count lsquorsquo by genre
21
Lastfm has 4M songs classied by tagsgenres
Retrieving songs by genre
lastfmmusic+tagcountry lastfmapishowservice=285
22
Lastfm has 4M songs classied by tagsgenres
wsaudioscrobblercom20method=taggettoptracksamp
tag=discoamp api_key=KEY
Retrieving songs by genre
lastfmmusic+tagcountry
23
e code is included in the le clyricsy_3rb
require nethttprequire rexmldocumentrequire Filedirname(__FILE__)lyricsfly_keyrequire Filedirname(__FILE__)lastfm_key
def get_lyrics(artist_and_title) artisttitle = artist_and_titlecollect|arg| arggsub([^a-zA-Z0-9]25)
url = httplyricsflycomapiapiphp url += a=artistampt=titleampi=$lyricsfly_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody)elements[tx] responsetextgsub([br] ) unless responsenilend
Combining two music web APIs
24
Finally $ ruby lyricsfly_3rb country hip-hop
def get_artists_and_titles(genre) url = httpwsaudioscrobblercom20method= url += taggettoptracksamptag=genreampapi_key=$lastfm_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody) responseelementscollect(track) do |track| [ trackelements[artist]elements[name]text trackelements[name]text ] end unless responsenilend
ARGVeach do |genre| tracks = get_artists_and_titles(genre) lyrics = trackscollect|track| get_lyrics(track)compact qm = lyricsinject(00) |qm lyric| qm + lyriccount() p genre avg question marks 2f (qmlyricslength)end
Combining two music web APIs
25
Lessons learnt
Hip-hop lyrics have more ldquordquo than Country ones
Any programming language with libraries to retrieve pages and parse XML can do the work
Data from dierent web APIs can be aggregated
A mash-up application can uncover hidden musical relationships among dierent domains
26
A more advanced mash-up
ismir2009beneldsnetgmapradio
27
From instance to concept
ere is no limit to the chain of API calls
To connect even more resources unique identiers work better than ambiguous names
Many web sites identify musical objects through a specic set of Musicbrainz IDs which allow to easily match the same item in multiple places
28
e Linking Open Data project is a prominent attempt at expressing and connecting objects of dierent domains using semantic web technology
Music and web ontologies
linkeddataorg musicontologycom
29
3REVEALING
TRENDS
30
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Creating a Python script
Verify the genre recogniser on Jamendo tracks
$ pythonfrom urllib import urlopenfrom isrock import isRockquery = httpapijamendocomget2streamtrackplainn=50amptag_idstr=rockamporder=random_descresult = urlopen(query)read()songs = resultsplit()rock = [isRock(song) for song in songs]print The ratio of rock songs is 2f (float(rockcount(True))len(songs))
11
Evaluating the genre recogniser
e code is included in the le cjamendo_1py
e script cjamendo_2py allows to specify the number of tests and multiple genres at once
e result shows that the isRock recogniser is not able to distinguish Rock from other genres
$ python jamendo_1py
$ python jamendo_2py 30 rock jazz country rnb
=raquo The ratio of rock songs is 058
12
Lessons learnt
Music data can easily be retrieved from the web
ousands of songs can be downloaded for free
Songs in Jamendo already have a genre label attached so you do not have to decide for one
Working with a web API simplies the process
Dierent musical objects are available (songs artists albums playlists users) to work on
13
2COMPARING
LYRICS BY GENRE
14
The relevance of lyrics
Recent interest for lyrics-based analysis
1 Knees Schedl Widmer Multiple Lyrics Alignment Automatic Retrieval of Song Lyrics 2005
2 Geleijnse Korst Ecient Lyrics Extraction from the web 2006
3 Kleedorfer Knees Pohle Oh Oh Oh Whoah Towards Automatic Topic Detection in Song Lyrics 2008
4 Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Lyrics were retrieved without using any web API
15
Lyrics$y provides a web API to retrieve lyrics
An online song lyrics database
lyricsycomsearchviewphp1524965aadampview=578812
lyricsycomapiapiphpi=KEYampa=Rihannaampt=Umbrella
16
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ echo $lyricsfly_key = PASTE YOUR KEY HERE gt lyricsfly_keyrb
17
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ irbrequire nethttprequire rexmldocumentrequire lyricsfly_keyurl = httplyricsflycomapiapiphpa=Rihannaampt=Umbrellaampi=$lyricsfly_keyresult = NetHTTPget_response(URIparse(url))response = REXMLDocumentnew(resultbody)elements[tx]puts responsetext
18
Retrieving multiple lyrics
e code is included in the le clyricsy_1py
e script clyricsy_2rb allows to specify the artist name and track title
$ ruby lyricsfly_1rb =raquo You have my heart[br] And well never be
$ ruby lyricsfly_2rb John Lennon Imagine
=raquo Imagine theres no Heaven
Its easy if you try
No Hell below us
19
Lyrics-based analysis
Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Textual features of lyrics are related to the genre
Hip-hop lyrics have more lsquorsquo than Country ones
Evaluated on 29 Hip-hop and 41 Country songs
Does this hold with larger data sets
20
Repeating the experiment
music web API 1
lsquoCountryrsquo and lsquoHip-hoprsquo
List songs by genre
music web API 2
List lyrics by genre Count lsquorsquo by genre
21
Lastfm has 4M songs classied by tagsgenres
Retrieving songs by genre
lastfmmusic+tagcountry lastfmapishowservice=285
22
Lastfm has 4M songs classied by tagsgenres
wsaudioscrobblercom20method=taggettoptracksamp
tag=discoamp api_key=KEY
Retrieving songs by genre
lastfmmusic+tagcountry
23
e code is included in the le clyricsy_3rb
require nethttprequire rexmldocumentrequire Filedirname(__FILE__)lyricsfly_keyrequire Filedirname(__FILE__)lastfm_key
def get_lyrics(artist_and_title) artisttitle = artist_and_titlecollect|arg| arggsub([^a-zA-Z0-9]25)
url = httplyricsflycomapiapiphp url += a=artistampt=titleampi=$lyricsfly_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody)elements[tx] responsetextgsub([br] ) unless responsenilend
Combining two music web APIs
24
Finally $ ruby lyricsfly_3rb country hip-hop
def get_artists_and_titles(genre) url = httpwsaudioscrobblercom20method= url += taggettoptracksamptag=genreampapi_key=$lastfm_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody) responseelementscollect(track) do |track| [ trackelements[artist]elements[name]text trackelements[name]text ] end unless responsenilend
ARGVeach do |genre| tracks = get_artists_and_titles(genre) lyrics = trackscollect|track| get_lyrics(track)compact qm = lyricsinject(00) |qm lyric| qm + lyriccount() p genre avg question marks 2f (qmlyricslength)end
Combining two music web APIs
25
Lessons learnt
Hip-hop lyrics have more ldquordquo than Country ones
Any programming language with libraries to retrieve pages and parse XML can do the work
Data from dierent web APIs can be aggregated
A mash-up application can uncover hidden musical relationships among dierent domains
26
A more advanced mash-up
ismir2009beneldsnetgmapradio
27
From instance to concept
ere is no limit to the chain of API calls
To connect even more resources unique identiers work better than ambiguous names
Many web sites identify musical objects through a specic set of Musicbrainz IDs which allow to easily match the same item in multiple places
28
e Linking Open Data project is a prominent attempt at expressing and connecting objects of dierent domains using semantic web technology
Music and web ontologies
linkeddataorg musicontologycom
29
3REVEALING
TRENDS
30
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Evaluating the genre recogniser
e code is included in the le cjamendo_1py
e script cjamendo_2py allows to specify the number of tests and multiple genres at once
e result shows that the isRock recogniser is not able to distinguish Rock from other genres
$ python jamendo_1py
$ python jamendo_2py 30 rock jazz country rnb
=raquo The ratio of rock songs is 058
12
Lessons learnt
Music data can easily be retrieved from the web
ousands of songs can be downloaded for free
Songs in Jamendo already have a genre label attached so you do not have to decide for one
Working with a web API simplies the process
Dierent musical objects are available (songs artists albums playlists users) to work on
13
2COMPARING
LYRICS BY GENRE
14
The relevance of lyrics
Recent interest for lyrics-based analysis
1 Knees Schedl Widmer Multiple Lyrics Alignment Automatic Retrieval of Song Lyrics 2005
2 Geleijnse Korst Ecient Lyrics Extraction from the web 2006
3 Kleedorfer Knees Pohle Oh Oh Oh Whoah Towards Automatic Topic Detection in Song Lyrics 2008
4 Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Lyrics were retrieved without using any web API
15
Lyrics$y provides a web API to retrieve lyrics
An online song lyrics database
lyricsycomsearchviewphp1524965aadampview=578812
lyricsycomapiapiphpi=KEYampa=Rihannaampt=Umbrella
16
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ echo $lyricsfly_key = PASTE YOUR KEY HERE gt lyricsfly_keyrb
17
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ irbrequire nethttprequire rexmldocumentrequire lyricsfly_keyurl = httplyricsflycomapiapiphpa=Rihannaampt=Umbrellaampi=$lyricsfly_keyresult = NetHTTPget_response(URIparse(url))response = REXMLDocumentnew(resultbody)elements[tx]puts responsetext
18
Retrieving multiple lyrics
e code is included in the le clyricsy_1py
e script clyricsy_2rb allows to specify the artist name and track title
$ ruby lyricsfly_1rb =raquo You have my heart[br] And well never be
$ ruby lyricsfly_2rb John Lennon Imagine
=raquo Imagine theres no Heaven
Its easy if you try
No Hell below us
19
Lyrics-based analysis
Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Textual features of lyrics are related to the genre
Hip-hop lyrics have more lsquorsquo than Country ones
Evaluated on 29 Hip-hop and 41 Country songs
Does this hold with larger data sets
20
Repeating the experiment
music web API 1
lsquoCountryrsquo and lsquoHip-hoprsquo
List songs by genre
music web API 2
List lyrics by genre Count lsquorsquo by genre
21
Lastfm has 4M songs classied by tagsgenres
Retrieving songs by genre
lastfmmusic+tagcountry lastfmapishowservice=285
22
Lastfm has 4M songs classied by tagsgenres
wsaudioscrobblercom20method=taggettoptracksamp
tag=discoamp api_key=KEY
Retrieving songs by genre
lastfmmusic+tagcountry
23
e code is included in the le clyricsy_3rb
require nethttprequire rexmldocumentrequire Filedirname(__FILE__)lyricsfly_keyrequire Filedirname(__FILE__)lastfm_key
def get_lyrics(artist_and_title) artisttitle = artist_and_titlecollect|arg| arggsub([^a-zA-Z0-9]25)
url = httplyricsflycomapiapiphp url += a=artistampt=titleampi=$lyricsfly_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody)elements[tx] responsetextgsub([br] ) unless responsenilend
Combining two music web APIs
24
Finally $ ruby lyricsfly_3rb country hip-hop
def get_artists_and_titles(genre) url = httpwsaudioscrobblercom20method= url += taggettoptracksamptag=genreampapi_key=$lastfm_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody) responseelementscollect(track) do |track| [ trackelements[artist]elements[name]text trackelements[name]text ] end unless responsenilend
ARGVeach do |genre| tracks = get_artists_and_titles(genre) lyrics = trackscollect|track| get_lyrics(track)compact qm = lyricsinject(00) |qm lyric| qm + lyriccount() p genre avg question marks 2f (qmlyricslength)end
Combining two music web APIs
25
Lessons learnt
Hip-hop lyrics have more ldquordquo than Country ones
Any programming language with libraries to retrieve pages and parse XML can do the work
Data from dierent web APIs can be aggregated
A mash-up application can uncover hidden musical relationships among dierent domains
26
A more advanced mash-up
ismir2009beneldsnetgmapradio
27
From instance to concept
ere is no limit to the chain of API calls
To connect even more resources unique identiers work better than ambiguous names
Many web sites identify musical objects through a specic set of Musicbrainz IDs which allow to easily match the same item in multiple places
28
e Linking Open Data project is a prominent attempt at expressing and connecting objects of dierent domains using semantic web technology
Music and web ontologies
linkeddataorg musicontologycom
29
3REVEALING
TRENDS
30
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Lessons learnt
Music data can easily be retrieved from the web
ousands of songs can be downloaded for free
Songs in Jamendo already have a genre label attached so you do not have to decide for one
Working with a web API simplies the process
Dierent musical objects are available (songs artists albums playlists users) to work on
13
2COMPARING
LYRICS BY GENRE
14
The relevance of lyrics
Recent interest for lyrics-based analysis
1 Knees Schedl Widmer Multiple Lyrics Alignment Automatic Retrieval of Song Lyrics 2005
2 Geleijnse Korst Ecient Lyrics Extraction from the web 2006
3 Kleedorfer Knees Pohle Oh Oh Oh Whoah Towards Automatic Topic Detection in Song Lyrics 2008
4 Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Lyrics were retrieved without using any web API
15
Lyrics$y provides a web API to retrieve lyrics
An online song lyrics database
lyricsycomsearchviewphp1524965aadampview=578812
lyricsycomapiapiphpi=KEYampa=Rihannaampt=Umbrella
16
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ echo $lyricsfly_key = PASTE YOUR KEY HERE gt lyricsfly_keyrb
17
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ irbrequire nethttprequire rexmldocumentrequire lyricsfly_keyurl = httplyricsflycomapiapiphpa=Rihannaampt=Umbrellaampi=$lyricsfly_keyresult = NetHTTPget_response(URIparse(url))response = REXMLDocumentnew(resultbody)elements[tx]puts responsetext
18
Retrieving multiple lyrics
e code is included in the le clyricsy_1py
e script clyricsy_2rb allows to specify the artist name and track title
$ ruby lyricsfly_1rb =raquo You have my heart[br] And well never be
$ ruby lyricsfly_2rb John Lennon Imagine
=raquo Imagine theres no Heaven
Its easy if you try
No Hell below us
19
Lyrics-based analysis
Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Textual features of lyrics are related to the genre
Hip-hop lyrics have more lsquorsquo than Country ones
Evaluated on 29 Hip-hop and 41 Country songs
Does this hold with larger data sets
20
Repeating the experiment
music web API 1
lsquoCountryrsquo and lsquoHip-hoprsquo
List songs by genre
music web API 2
List lyrics by genre Count lsquorsquo by genre
21
Lastfm has 4M songs classied by tagsgenres
Retrieving songs by genre
lastfmmusic+tagcountry lastfmapishowservice=285
22
Lastfm has 4M songs classied by tagsgenres
wsaudioscrobblercom20method=taggettoptracksamp
tag=discoamp api_key=KEY
Retrieving songs by genre
lastfmmusic+tagcountry
23
e code is included in the le clyricsy_3rb
require nethttprequire rexmldocumentrequire Filedirname(__FILE__)lyricsfly_keyrequire Filedirname(__FILE__)lastfm_key
def get_lyrics(artist_and_title) artisttitle = artist_and_titlecollect|arg| arggsub([^a-zA-Z0-9]25)
url = httplyricsflycomapiapiphp url += a=artistampt=titleampi=$lyricsfly_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody)elements[tx] responsetextgsub([br] ) unless responsenilend
Combining two music web APIs
24
Finally $ ruby lyricsfly_3rb country hip-hop
def get_artists_and_titles(genre) url = httpwsaudioscrobblercom20method= url += taggettoptracksamptag=genreampapi_key=$lastfm_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody) responseelementscollect(track) do |track| [ trackelements[artist]elements[name]text trackelements[name]text ] end unless responsenilend
ARGVeach do |genre| tracks = get_artists_and_titles(genre) lyrics = trackscollect|track| get_lyrics(track)compact qm = lyricsinject(00) |qm lyric| qm + lyriccount() p genre avg question marks 2f (qmlyricslength)end
Combining two music web APIs
25
Lessons learnt
Hip-hop lyrics have more ldquordquo than Country ones
Any programming language with libraries to retrieve pages and parse XML can do the work
Data from dierent web APIs can be aggregated
A mash-up application can uncover hidden musical relationships among dierent domains
26
A more advanced mash-up
ismir2009beneldsnetgmapradio
27
From instance to concept
ere is no limit to the chain of API calls
To connect even more resources unique identiers work better than ambiguous names
Many web sites identify musical objects through a specic set of Musicbrainz IDs which allow to easily match the same item in multiple places
28
e Linking Open Data project is a prominent attempt at expressing and connecting objects of dierent domains using semantic web technology
Music and web ontologies
linkeddataorg musicontologycom
29
3REVEALING
TRENDS
30
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
2COMPARING
LYRICS BY GENRE
14
The relevance of lyrics
Recent interest for lyrics-based analysis
1 Knees Schedl Widmer Multiple Lyrics Alignment Automatic Retrieval of Song Lyrics 2005
2 Geleijnse Korst Ecient Lyrics Extraction from the web 2006
3 Kleedorfer Knees Pohle Oh Oh Oh Whoah Towards Automatic Topic Detection in Song Lyrics 2008
4 Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Lyrics were retrieved without using any web API
15
Lyrics$y provides a web API to retrieve lyrics
An online song lyrics database
lyricsycomsearchviewphp1524965aadampview=578812
lyricsycomapiapiphpi=KEYampa=Rihannaampt=Umbrella
16
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ echo $lyricsfly_key = PASTE YOUR KEY HERE gt lyricsfly_keyrb
17
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ irbrequire nethttprequire rexmldocumentrequire lyricsfly_keyurl = httplyricsflycomapiapiphpa=Rihannaampt=Umbrellaampi=$lyricsfly_keyresult = NetHTTPget_response(URIparse(url))response = REXMLDocumentnew(resultbody)elements[tx]puts responsetext
18
Retrieving multiple lyrics
e code is included in the le clyricsy_1py
e script clyricsy_2rb allows to specify the artist name and track title
$ ruby lyricsfly_1rb =raquo You have my heart[br] And well never be
$ ruby lyricsfly_2rb John Lennon Imagine
=raquo Imagine theres no Heaven
Its easy if you try
No Hell below us
19
Lyrics-based analysis
Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Textual features of lyrics are related to the genre
Hip-hop lyrics have more lsquorsquo than Country ones
Evaluated on 29 Hip-hop and 41 Country songs
Does this hold with larger data sets
20
Repeating the experiment
music web API 1
lsquoCountryrsquo and lsquoHip-hoprsquo
List songs by genre
music web API 2
List lyrics by genre Count lsquorsquo by genre
21
Lastfm has 4M songs classied by tagsgenres
Retrieving songs by genre
lastfmmusic+tagcountry lastfmapishowservice=285
22
Lastfm has 4M songs classied by tagsgenres
wsaudioscrobblercom20method=taggettoptracksamp
tag=discoamp api_key=KEY
Retrieving songs by genre
lastfmmusic+tagcountry
23
e code is included in the le clyricsy_3rb
require nethttprequire rexmldocumentrequire Filedirname(__FILE__)lyricsfly_keyrequire Filedirname(__FILE__)lastfm_key
def get_lyrics(artist_and_title) artisttitle = artist_and_titlecollect|arg| arggsub([^a-zA-Z0-9]25)
url = httplyricsflycomapiapiphp url += a=artistampt=titleampi=$lyricsfly_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody)elements[tx] responsetextgsub([br] ) unless responsenilend
Combining two music web APIs
24
Finally $ ruby lyricsfly_3rb country hip-hop
def get_artists_and_titles(genre) url = httpwsaudioscrobblercom20method= url += taggettoptracksamptag=genreampapi_key=$lastfm_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody) responseelementscollect(track) do |track| [ trackelements[artist]elements[name]text trackelements[name]text ] end unless responsenilend
ARGVeach do |genre| tracks = get_artists_and_titles(genre) lyrics = trackscollect|track| get_lyrics(track)compact qm = lyricsinject(00) |qm lyric| qm + lyriccount() p genre avg question marks 2f (qmlyricslength)end
Combining two music web APIs
25
Lessons learnt
Hip-hop lyrics have more ldquordquo than Country ones
Any programming language with libraries to retrieve pages and parse XML can do the work
Data from dierent web APIs can be aggregated
A mash-up application can uncover hidden musical relationships among dierent domains
26
A more advanced mash-up
ismir2009beneldsnetgmapradio
27
From instance to concept
ere is no limit to the chain of API calls
To connect even more resources unique identiers work better than ambiguous names
Many web sites identify musical objects through a specic set of Musicbrainz IDs which allow to easily match the same item in multiple places
28
e Linking Open Data project is a prominent attempt at expressing and connecting objects of dierent domains using semantic web technology
Music and web ontologies
linkeddataorg musicontologycom
29
3REVEALING
TRENDS
30
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
The relevance of lyrics
Recent interest for lyrics-based analysis
1 Knees Schedl Widmer Multiple Lyrics Alignment Automatic Retrieval of Song Lyrics 2005
2 Geleijnse Korst Ecient Lyrics Extraction from the web 2006
3 Kleedorfer Knees Pohle Oh Oh Oh Whoah Towards Automatic Topic Detection in Song Lyrics 2008
4 Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Lyrics were retrieved without using any web API
15
Lyrics$y provides a web API to retrieve lyrics
An online song lyrics database
lyricsycomsearchviewphp1524965aadampview=578812
lyricsycomapiapiphpi=KEYampa=Rihannaampt=Umbrella
16
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ echo $lyricsfly_key = PASTE YOUR KEY HERE gt lyricsfly_keyrb
17
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ irbrequire nethttprequire rexmldocumentrequire lyricsfly_keyurl = httplyricsflycomapiapiphpa=Rihannaampt=Umbrellaampi=$lyricsfly_keyresult = NetHTTPget_response(URIparse(url))response = REXMLDocumentnew(resultbody)elements[tx]puts responsetext
18
Retrieving multiple lyrics
e code is included in the le clyricsy_1py
e script clyricsy_2rb allows to specify the artist name and track title
$ ruby lyricsfly_1rb =raquo You have my heart[br] And well never be
$ ruby lyricsfly_2rb John Lennon Imagine
=raquo Imagine theres no Heaven
Its easy if you try
No Hell below us
19
Lyrics-based analysis
Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Textual features of lyrics are related to the genre
Hip-hop lyrics have more lsquorsquo than Country ones
Evaluated on 29 Hip-hop and 41 Country songs
Does this hold with larger data sets
20
Repeating the experiment
music web API 1
lsquoCountryrsquo and lsquoHip-hoprsquo
List songs by genre
music web API 2
List lyrics by genre Count lsquorsquo by genre
21
Lastfm has 4M songs classied by tagsgenres
Retrieving songs by genre
lastfmmusic+tagcountry lastfmapishowservice=285
22
Lastfm has 4M songs classied by tagsgenres
wsaudioscrobblercom20method=taggettoptracksamp
tag=discoamp api_key=KEY
Retrieving songs by genre
lastfmmusic+tagcountry
23
e code is included in the le clyricsy_3rb
require nethttprequire rexmldocumentrequire Filedirname(__FILE__)lyricsfly_keyrequire Filedirname(__FILE__)lastfm_key
def get_lyrics(artist_and_title) artisttitle = artist_and_titlecollect|arg| arggsub([^a-zA-Z0-9]25)
url = httplyricsflycomapiapiphp url += a=artistampt=titleampi=$lyricsfly_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody)elements[tx] responsetextgsub([br] ) unless responsenilend
Combining two music web APIs
24
Finally $ ruby lyricsfly_3rb country hip-hop
def get_artists_and_titles(genre) url = httpwsaudioscrobblercom20method= url += taggettoptracksamptag=genreampapi_key=$lastfm_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody) responseelementscollect(track) do |track| [ trackelements[artist]elements[name]text trackelements[name]text ] end unless responsenilend
ARGVeach do |genre| tracks = get_artists_and_titles(genre) lyrics = trackscollect|track| get_lyrics(track)compact qm = lyricsinject(00) |qm lyric| qm + lyriccount() p genre avg question marks 2f (qmlyricslength)end
Combining two music web APIs
25
Lessons learnt
Hip-hop lyrics have more ldquordquo than Country ones
Any programming language with libraries to retrieve pages and parse XML can do the work
Data from dierent web APIs can be aggregated
A mash-up application can uncover hidden musical relationships among dierent domains
26
A more advanced mash-up
ismir2009beneldsnetgmapradio
27
From instance to concept
ere is no limit to the chain of API calls
To connect even more resources unique identiers work better than ambiguous names
Many web sites identify musical objects through a specic set of Musicbrainz IDs which allow to easily match the same item in multiple places
28
e Linking Open Data project is a prominent attempt at expressing and connecting objects of dierent domains using semantic web technology
Music and web ontologies
linkeddataorg musicontologycom
29
3REVEALING
TRENDS
30
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Lyrics$y provides a web API to retrieve lyrics
An online song lyrics database
lyricsycomsearchviewphp1524965aadampview=578812
lyricsycomapiapiphpi=KEYampa=Rihannaampt=Umbrella
16
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ echo $lyricsfly_key = PASTE YOUR KEY HERE gt lyricsfly_keyrb
17
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ irbrequire nethttprequire rexmldocumentrequire lyricsfly_keyurl = httplyricsflycomapiapiphpa=Rihannaampt=Umbrellaampi=$lyricsfly_keyresult = NetHTTPget_response(URIparse(url))response = REXMLDocumentnew(resultbody)elements[tx]puts responsetext
18
Retrieving multiple lyrics
e code is included in the le clyricsy_1py
e script clyricsy_2rb allows to specify the artist name and track title
$ ruby lyricsfly_1rb =raquo You have my heart[br] And well never be
$ ruby lyricsfly_2rb John Lennon Imagine
=raquo Imagine theres no Heaven
Its easy if you try
No Hell below us
19
Lyrics-based analysis
Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Textual features of lyrics are related to the genre
Hip-hop lyrics have more lsquorsquo than Country ones
Evaluated on 29 Hip-hop and 41 Country songs
Does this hold with larger data sets
20
Repeating the experiment
music web API 1
lsquoCountryrsquo and lsquoHip-hoprsquo
List songs by genre
music web API 2
List lyrics by genre Count lsquorsquo by genre
21
Lastfm has 4M songs classied by tagsgenres
Retrieving songs by genre
lastfmmusic+tagcountry lastfmapishowservice=285
22
Lastfm has 4M songs classied by tagsgenres
wsaudioscrobblercom20method=taggettoptracksamp
tag=discoamp api_key=KEY
Retrieving songs by genre
lastfmmusic+tagcountry
23
e code is included in the le clyricsy_3rb
require nethttprequire rexmldocumentrequire Filedirname(__FILE__)lyricsfly_keyrequire Filedirname(__FILE__)lastfm_key
def get_lyrics(artist_and_title) artisttitle = artist_and_titlecollect|arg| arggsub([^a-zA-Z0-9]25)
url = httplyricsflycomapiapiphp url += a=artistampt=titleampi=$lyricsfly_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody)elements[tx] responsetextgsub([br] ) unless responsenilend
Combining two music web APIs
24
Finally $ ruby lyricsfly_3rb country hip-hop
def get_artists_and_titles(genre) url = httpwsaudioscrobblercom20method= url += taggettoptracksamptag=genreampapi_key=$lastfm_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody) responseelementscollect(track) do |track| [ trackelements[artist]elements[name]text trackelements[name]text ] end unless responsenilend
ARGVeach do |genre| tracks = get_artists_and_titles(genre) lyrics = trackscollect|track| get_lyrics(track)compact qm = lyricsinject(00) |qm lyric| qm + lyriccount() p genre avg question marks 2f (qmlyricslength)end
Combining two music web APIs
25
Lessons learnt
Hip-hop lyrics have more ldquordquo than Country ones
Any programming language with libraries to retrieve pages and parse XML can do the work
Data from dierent web APIs can be aggregated
A mash-up application can uncover hidden musical relationships among dierent domains
26
A more advanced mash-up
ismir2009beneldsnetgmapradio
27
From instance to concept
ere is no limit to the chain of API calls
To connect even more resources unique identiers work better than ambiguous names
Many web sites identify musical objects through a specic set of Musicbrainz IDs which allow to easily match the same item in multiple places
28
e Linking Open Data project is a prominent attempt at expressing and connecting objects of dierent domains using semantic web technology
Music and web ontologies
linkeddataorg musicontologycom
29
3REVEALING
TRENDS
30
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ echo $lyricsfly_key = PASTE YOUR KEY HERE gt lyricsfly_keyrb
17
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ irbrequire nethttprequire rexmldocumentrequire lyricsfly_keyurl = httplyricsflycomapiapiphpa=Rihannaampt=Umbrellaampi=$lyricsfly_keyresult = NetHTTPget_response(URIparse(url))response = REXMLDocumentnew(resultbody)elements[tx]puts responsetext
18
Retrieving multiple lyrics
e code is included in the le clyricsy_1py
e script clyricsy_2rb allows to specify the artist name and track title
$ ruby lyricsfly_1rb =raquo You have my heart[br] And well never be
$ ruby lyricsfly_2rb John Lennon Imagine
=raquo Imagine theres no Heaven
Its easy if you try
No Hell below us
19
Lyrics-based analysis
Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Textual features of lyrics are related to the genre
Hip-hop lyrics have more lsquorsquo than Country ones
Evaluated on 29 Hip-hop and 41 Country songs
Does this hold with larger data sets
20
Repeating the experiment
music web API 1
lsquoCountryrsquo and lsquoHip-hoprsquo
List songs by genre
music web API 2
List lyrics by genre Count lsquorsquo by genre
21
Lastfm has 4M songs classied by tagsgenres
Retrieving songs by genre
lastfmmusic+tagcountry lastfmapishowservice=285
22
Lastfm has 4M songs classied by tagsgenres
wsaudioscrobblercom20method=taggettoptracksamp
tag=discoamp api_key=KEY
Retrieving songs by genre
lastfmmusic+tagcountry
23
e code is included in the le clyricsy_3rb
require nethttprequire rexmldocumentrequire Filedirname(__FILE__)lyricsfly_keyrequire Filedirname(__FILE__)lastfm_key
def get_lyrics(artist_and_title) artisttitle = artist_and_titlecollect|arg| arggsub([^a-zA-Z0-9]25)
url = httplyricsflycomapiapiphp url += a=artistampt=titleampi=$lyricsfly_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody)elements[tx] responsetextgsub([br] ) unless responsenilend
Combining two music web APIs
24
Finally $ ruby lyricsfly_3rb country hip-hop
def get_artists_and_titles(genre) url = httpwsaudioscrobblercom20method= url += taggettoptracksamptag=genreampapi_key=$lastfm_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody) responseelementscollect(track) do |track| [ trackelements[artist]elements[name]text trackelements[name]text ] end unless responsenilend
ARGVeach do |genre| tracks = get_artists_and_titles(genre) lyrics = trackscollect|track| get_lyrics(track)compact qm = lyricsinject(00) |qm lyric| qm + lyriccount() p genre avg question marks 2f (qmlyricslength)end
Combining two music web APIs
25
Lessons learnt
Hip-hop lyrics have more ldquordquo than Country ones
Any programming language with libraries to retrieve pages and parse XML can do the work
Data from dierent web APIs can be aggregated
A mash-up application can uncover hidden musical relationships among dierent domains
26
A more advanced mash-up
ismir2009beneldsnetgmapradio
27
From instance to concept
ere is no limit to the chain of API calls
To connect even more resources unique identiers work better than ambiguous names
Many web sites identify musical objects through a specic set of Musicbrainz IDs which allow to easily match the same item in multiple places
28
e Linking Open Data project is a prominent attempt at expressing and connecting objects of dierent domains using semantic web technology
Music and web ontologies
linkeddataorg musicontologycom
29
3REVEALING
TRENDS
30
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Creating a Ruby script
To retrieve the lyrics for ldquoUmbrellardquo (Rihanna)
$ irbrequire nethttprequire rexmldocumentrequire lyricsfly_keyurl = httplyricsflycomapiapiphpa=Rihannaampt=Umbrellaampi=$lyricsfly_keyresult = NetHTTPget_response(URIparse(url))response = REXMLDocumentnew(resultbody)elements[tx]puts responsetext
18
Retrieving multiple lyrics
e code is included in the le clyricsy_1py
e script clyricsy_2rb allows to specify the artist name and track title
$ ruby lyricsfly_1rb =raquo You have my heart[br] And well never be
$ ruby lyricsfly_2rb John Lennon Imagine
=raquo Imagine theres no Heaven
Its easy if you try
No Hell below us
19
Lyrics-based analysis
Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Textual features of lyrics are related to the genre
Hip-hop lyrics have more lsquorsquo than Country ones
Evaluated on 29 Hip-hop and 41 Country songs
Does this hold with larger data sets
20
Repeating the experiment
music web API 1
lsquoCountryrsquo and lsquoHip-hoprsquo
List songs by genre
music web API 2
List lyrics by genre Count lsquorsquo by genre
21
Lastfm has 4M songs classied by tagsgenres
Retrieving songs by genre
lastfmmusic+tagcountry lastfmapishowservice=285
22
Lastfm has 4M songs classied by tagsgenres
wsaudioscrobblercom20method=taggettoptracksamp
tag=discoamp api_key=KEY
Retrieving songs by genre
lastfmmusic+tagcountry
23
e code is included in the le clyricsy_3rb
require nethttprequire rexmldocumentrequire Filedirname(__FILE__)lyricsfly_keyrequire Filedirname(__FILE__)lastfm_key
def get_lyrics(artist_and_title) artisttitle = artist_and_titlecollect|arg| arggsub([^a-zA-Z0-9]25)
url = httplyricsflycomapiapiphp url += a=artistampt=titleampi=$lyricsfly_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody)elements[tx] responsetextgsub([br] ) unless responsenilend
Combining two music web APIs
24
Finally $ ruby lyricsfly_3rb country hip-hop
def get_artists_and_titles(genre) url = httpwsaudioscrobblercom20method= url += taggettoptracksamptag=genreampapi_key=$lastfm_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody) responseelementscollect(track) do |track| [ trackelements[artist]elements[name]text trackelements[name]text ] end unless responsenilend
ARGVeach do |genre| tracks = get_artists_and_titles(genre) lyrics = trackscollect|track| get_lyrics(track)compact qm = lyricsinject(00) |qm lyric| qm + lyriccount() p genre avg question marks 2f (qmlyricslength)end
Combining two music web APIs
25
Lessons learnt
Hip-hop lyrics have more ldquordquo than Country ones
Any programming language with libraries to retrieve pages and parse XML can do the work
Data from dierent web APIs can be aggregated
A mash-up application can uncover hidden musical relationships among dierent domains
26
A more advanced mash-up
ismir2009beneldsnetgmapradio
27
From instance to concept
ere is no limit to the chain of API calls
To connect even more resources unique identiers work better than ambiguous names
Many web sites identify musical objects through a specic set of Musicbrainz IDs which allow to easily match the same item in multiple places
28
e Linking Open Data project is a prominent attempt at expressing and connecting objects of dierent domains using semantic web technology
Music and web ontologies
linkeddataorg musicontologycom
29
3REVEALING
TRENDS
30
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Retrieving multiple lyrics
e code is included in the le clyricsy_1py
e script clyricsy_2rb allows to specify the artist name and track title
$ ruby lyricsfly_1rb =raquo You have my heart[br] And well never be
$ ruby lyricsfly_2rb John Lennon Imagine
=raquo Imagine theres no Heaven
Its easy if you try
No Hell below us
19
Lyrics-based analysis
Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Textual features of lyrics are related to the genre
Hip-hop lyrics have more lsquorsquo than Country ones
Evaluated on 29 Hip-hop and 41 Country songs
Does this hold with larger data sets
20
Repeating the experiment
music web API 1
lsquoCountryrsquo and lsquoHip-hoprsquo
List songs by genre
music web API 2
List lyrics by genre Count lsquorsquo by genre
21
Lastfm has 4M songs classied by tagsgenres
Retrieving songs by genre
lastfmmusic+tagcountry lastfmapishowservice=285
22
Lastfm has 4M songs classied by tagsgenres
wsaudioscrobblercom20method=taggettoptracksamp
tag=discoamp api_key=KEY
Retrieving songs by genre
lastfmmusic+tagcountry
23
e code is included in the le clyricsy_3rb
require nethttprequire rexmldocumentrequire Filedirname(__FILE__)lyricsfly_keyrequire Filedirname(__FILE__)lastfm_key
def get_lyrics(artist_and_title) artisttitle = artist_and_titlecollect|arg| arggsub([^a-zA-Z0-9]25)
url = httplyricsflycomapiapiphp url += a=artistampt=titleampi=$lyricsfly_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody)elements[tx] responsetextgsub([br] ) unless responsenilend
Combining two music web APIs
24
Finally $ ruby lyricsfly_3rb country hip-hop
def get_artists_and_titles(genre) url = httpwsaudioscrobblercom20method= url += taggettoptracksamptag=genreampapi_key=$lastfm_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody) responseelementscollect(track) do |track| [ trackelements[artist]elements[name]text trackelements[name]text ] end unless responsenilend
ARGVeach do |genre| tracks = get_artists_and_titles(genre) lyrics = trackscollect|track| get_lyrics(track)compact qm = lyricsinject(00) |qm lyric| qm + lyriccount() p genre avg question marks 2f (qmlyricslength)end
Combining two music web APIs
25
Lessons learnt
Hip-hop lyrics have more ldquordquo than Country ones
Any programming language with libraries to retrieve pages and parse XML can do the work
Data from dierent web APIs can be aggregated
A mash-up application can uncover hidden musical relationships among dierent domains
26
A more advanced mash-up
ismir2009beneldsnetgmapradio
27
From instance to concept
ere is no limit to the chain of API calls
To connect even more resources unique identiers work better than ambiguous names
Many web sites identify musical objects through a specic set of Musicbrainz IDs which allow to easily match the same item in multiple places
28
e Linking Open Data project is a prominent attempt at expressing and connecting objects of dierent domains using semantic web technology
Music and web ontologies
linkeddataorg musicontologycom
29
3REVEALING
TRENDS
30
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Lyrics-based analysis
Mayer Neumayer Rauber Rhyme and Style Features for Musical Genre Categorisation By Song Lyrics 2008
Textual features of lyrics are related to the genre
Hip-hop lyrics have more lsquorsquo than Country ones
Evaluated on 29 Hip-hop and 41 Country songs
Does this hold with larger data sets
20
Repeating the experiment
music web API 1
lsquoCountryrsquo and lsquoHip-hoprsquo
List songs by genre
music web API 2
List lyrics by genre Count lsquorsquo by genre
21
Lastfm has 4M songs classied by tagsgenres
Retrieving songs by genre
lastfmmusic+tagcountry lastfmapishowservice=285
22
Lastfm has 4M songs classied by tagsgenres
wsaudioscrobblercom20method=taggettoptracksamp
tag=discoamp api_key=KEY
Retrieving songs by genre
lastfmmusic+tagcountry
23
e code is included in the le clyricsy_3rb
require nethttprequire rexmldocumentrequire Filedirname(__FILE__)lyricsfly_keyrequire Filedirname(__FILE__)lastfm_key
def get_lyrics(artist_and_title) artisttitle = artist_and_titlecollect|arg| arggsub([^a-zA-Z0-9]25)
url = httplyricsflycomapiapiphp url += a=artistampt=titleampi=$lyricsfly_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody)elements[tx] responsetextgsub([br] ) unless responsenilend
Combining two music web APIs
24
Finally $ ruby lyricsfly_3rb country hip-hop
def get_artists_and_titles(genre) url = httpwsaudioscrobblercom20method= url += taggettoptracksamptag=genreampapi_key=$lastfm_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody) responseelementscollect(track) do |track| [ trackelements[artist]elements[name]text trackelements[name]text ] end unless responsenilend
ARGVeach do |genre| tracks = get_artists_and_titles(genre) lyrics = trackscollect|track| get_lyrics(track)compact qm = lyricsinject(00) |qm lyric| qm + lyriccount() p genre avg question marks 2f (qmlyricslength)end
Combining two music web APIs
25
Lessons learnt
Hip-hop lyrics have more ldquordquo than Country ones
Any programming language with libraries to retrieve pages and parse XML can do the work
Data from dierent web APIs can be aggregated
A mash-up application can uncover hidden musical relationships among dierent domains
26
A more advanced mash-up
ismir2009beneldsnetgmapradio
27
From instance to concept
ere is no limit to the chain of API calls
To connect even more resources unique identiers work better than ambiguous names
Many web sites identify musical objects through a specic set of Musicbrainz IDs which allow to easily match the same item in multiple places
28
e Linking Open Data project is a prominent attempt at expressing and connecting objects of dierent domains using semantic web technology
Music and web ontologies
linkeddataorg musicontologycom
29
3REVEALING
TRENDS
30
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Repeating the experiment
music web API 1
lsquoCountryrsquo and lsquoHip-hoprsquo
List songs by genre
music web API 2
List lyrics by genre Count lsquorsquo by genre
21
Lastfm has 4M songs classied by tagsgenres
Retrieving songs by genre
lastfmmusic+tagcountry lastfmapishowservice=285
22
Lastfm has 4M songs classied by tagsgenres
wsaudioscrobblercom20method=taggettoptracksamp
tag=discoamp api_key=KEY
Retrieving songs by genre
lastfmmusic+tagcountry
23
e code is included in the le clyricsy_3rb
require nethttprequire rexmldocumentrequire Filedirname(__FILE__)lyricsfly_keyrequire Filedirname(__FILE__)lastfm_key
def get_lyrics(artist_and_title) artisttitle = artist_and_titlecollect|arg| arggsub([^a-zA-Z0-9]25)
url = httplyricsflycomapiapiphp url += a=artistampt=titleampi=$lyricsfly_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody)elements[tx] responsetextgsub([br] ) unless responsenilend
Combining two music web APIs
24
Finally $ ruby lyricsfly_3rb country hip-hop
def get_artists_and_titles(genre) url = httpwsaudioscrobblercom20method= url += taggettoptracksamptag=genreampapi_key=$lastfm_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody) responseelementscollect(track) do |track| [ trackelements[artist]elements[name]text trackelements[name]text ] end unless responsenilend
ARGVeach do |genre| tracks = get_artists_and_titles(genre) lyrics = trackscollect|track| get_lyrics(track)compact qm = lyricsinject(00) |qm lyric| qm + lyriccount() p genre avg question marks 2f (qmlyricslength)end
Combining two music web APIs
25
Lessons learnt
Hip-hop lyrics have more ldquordquo than Country ones
Any programming language with libraries to retrieve pages and parse XML can do the work
Data from dierent web APIs can be aggregated
A mash-up application can uncover hidden musical relationships among dierent domains
26
A more advanced mash-up
ismir2009beneldsnetgmapradio
27
From instance to concept
ere is no limit to the chain of API calls
To connect even more resources unique identiers work better than ambiguous names
Many web sites identify musical objects through a specic set of Musicbrainz IDs which allow to easily match the same item in multiple places
28
e Linking Open Data project is a prominent attempt at expressing and connecting objects of dierent domains using semantic web technology
Music and web ontologies
linkeddataorg musicontologycom
29
3REVEALING
TRENDS
30
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Lastfm has 4M songs classied by tagsgenres
Retrieving songs by genre
lastfmmusic+tagcountry lastfmapishowservice=285
22
Lastfm has 4M songs classied by tagsgenres
wsaudioscrobblercom20method=taggettoptracksamp
tag=discoamp api_key=KEY
Retrieving songs by genre
lastfmmusic+tagcountry
23
e code is included in the le clyricsy_3rb
require nethttprequire rexmldocumentrequire Filedirname(__FILE__)lyricsfly_keyrequire Filedirname(__FILE__)lastfm_key
def get_lyrics(artist_and_title) artisttitle = artist_and_titlecollect|arg| arggsub([^a-zA-Z0-9]25)
url = httplyricsflycomapiapiphp url += a=artistampt=titleampi=$lyricsfly_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody)elements[tx] responsetextgsub([br] ) unless responsenilend
Combining two music web APIs
24
Finally $ ruby lyricsfly_3rb country hip-hop
def get_artists_and_titles(genre) url = httpwsaudioscrobblercom20method= url += taggettoptracksamptag=genreampapi_key=$lastfm_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody) responseelementscollect(track) do |track| [ trackelements[artist]elements[name]text trackelements[name]text ] end unless responsenilend
ARGVeach do |genre| tracks = get_artists_and_titles(genre) lyrics = trackscollect|track| get_lyrics(track)compact qm = lyricsinject(00) |qm lyric| qm + lyriccount() p genre avg question marks 2f (qmlyricslength)end
Combining two music web APIs
25
Lessons learnt
Hip-hop lyrics have more ldquordquo than Country ones
Any programming language with libraries to retrieve pages and parse XML can do the work
Data from dierent web APIs can be aggregated
A mash-up application can uncover hidden musical relationships among dierent domains
26
A more advanced mash-up
ismir2009beneldsnetgmapradio
27
From instance to concept
ere is no limit to the chain of API calls
To connect even more resources unique identiers work better than ambiguous names
Many web sites identify musical objects through a specic set of Musicbrainz IDs which allow to easily match the same item in multiple places
28
e Linking Open Data project is a prominent attempt at expressing and connecting objects of dierent domains using semantic web technology
Music and web ontologies
linkeddataorg musicontologycom
29
3REVEALING
TRENDS
30
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Lastfm has 4M songs classied by tagsgenres
wsaudioscrobblercom20method=taggettoptracksamp
tag=discoamp api_key=KEY
Retrieving songs by genre
lastfmmusic+tagcountry
23
e code is included in the le clyricsy_3rb
require nethttprequire rexmldocumentrequire Filedirname(__FILE__)lyricsfly_keyrequire Filedirname(__FILE__)lastfm_key
def get_lyrics(artist_and_title) artisttitle = artist_and_titlecollect|arg| arggsub([^a-zA-Z0-9]25)
url = httplyricsflycomapiapiphp url += a=artistampt=titleampi=$lyricsfly_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody)elements[tx] responsetextgsub([br] ) unless responsenilend
Combining two music web APIs
24
Finally $ ruby lyricsfly_3rb country hip-hop
def get_artists_and_titles(genre) url = httpwsaudioscrobblercom20method= url += taggettoptracksamptag=genreampapi_key=$lastfm_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody) responseelementscollect(track) do |track| [ trackelements[artist]elements[name]text trackelements[name]text ] end unless responsenilend
ARGVeach do |genre| tracks = get_artists_and_titles(genre) lyrics = trackscollect|track| get_lyrics(track)compact qm = lyricsinject(00) |qm lyric| qm + lyriccount() p genre avg question marks 2f (qmlyricslength)end
Combining two music web APIs
25
Lessons learnt
Hip-hop lyrics have more ldquordquo than Country ones
Any programming language with libraries to retrieve pages and parse XML can do the work
Data from dierent web APIs can be aggregated
A mash-up application can uncover hidden musical relationships among dierent domains
26
A more advanced mash-up
ismir2009beneldsnetgmapradio
27
From instance to concept
ere is no limit to the chain of API calls
To connect even more resources unique identiers work better than ambiguous names
Many web sites identify musical objects through a specic set of Musicbrainz IDs which allow to easily match the same item in multiple places
28
e Linking Open Data project is a prominent attempt at expressing and connecting objects of dierent domains using semantic web technology
Music and web ontologies
linkeddataorg musicontologycom
29
3REVEALING
TRENDS
30
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
e code is included in the le clyricsy_3rb
require nethttprequire rexmldocumentrequire Filedirname(__FILE__)lyricsfly_keyrequire Filedirname(__FILE__)lastfm_key
def get_lyrics(artist_and_title) artisttitle = artist_and_titlecollect|arg| arggsub([^a-zA-Z0-9]25)
url = httplyricsflycomapiapiphp url += a=artistampt=titleampi=$lyricsfly_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody)elements[tx] responsetextgsub([br] ) unless responsenilend
Combining two music web APIs
24
Finally $ ruby lyricsfly_3rb country hip-hop
def get_artists_and_titles(genre) url = httpwsaudioscrobblercom20method= url += taggettoptracksamptag=genreampapi_key=$lastfm_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody) responseelementscollect(track) do |track| [ trackelements[artist]elements[name]text trackelements[name]text ] end unless responsenilend
ARGVeach do |genre| tracks = get_artists_and_titles(genre) lyrics = trackscollect|track| get_lyrics(track)compact qm = lyricsinject(00) |qm lyric| qm + lyriccount() p genre avg question marks 2f (qmlyricslength)end
Combining two music web APIs
25
Lessons learnt
Hip-hop lyrics have more ldquordquo than Country ones
Any programming language with libraries to retrieve pages and parse XML can do the work
Data from dierent web APIs can be aggregated
A mash-up application can uncover hidden musical relationships among dierent domains
26
A more advanced mash-up
ismir2009beneldsnetgmapradio
27
From instance to concept
ere is no limit to the chain of API calls
To connect even more resources unique identiers work better than ambiguous names
Many web sites identify musical objects through a specic set of Musicbrainz IDs which allow to easily match the same item in multiple places
28
e Linking Open Data project is a prominent attempt at expressing and connecting objects of dierent domains using semantic web technology
Music and web ontologies
linkeddataorg musicontologycom
29
3REVEALING
TRENDS
30
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Finally $ ruby lyricsfly_3rb country hip-hop
def get_artists_and_titles(genre) url = httpwsaudioscrobblercom20method= url += taggettoptracksamptag=genreampapi_key=$lastfm_key result = NetHTTPget_response(URIparse(url)) response = REXMLDocumentnew(resultbody) responseelementscollect(track) do |track| [ trackelements[artist]elements[name]text trackelements[name]text ] end unless responsenilend
ARGVeach do |genre| tracks = get_artists_and_titles(genre) lyrics = trackscollect|track| get_lyrics(track)compact qm = lyricsinject(00) |qm lyric| qm + lyriccount() p genre avg question marks 2f (qmlyricslength)end
Combining two music web APIs
25
Lessons learnt
Hip-hop lyrics have more ldquordquo than Country ones
Any programming language with libraries to retrieve pages and parse XML can do the work
Data from dierent web APIs can be aggregated
A mash-up application can uncover hidden musical relationships among dierent domains
26
A more advanced mash-up
ismir2009beneldsnetgmapradio
27
From instance to concept
ere is no limit to the chain of API calls
To connect even more resources unique identiers work better than ambiguous names
Many web sites identify musical objects through a specic set of Musicbrainz IDs which allow to easily match the same item in multiple places
28
e Linking Open Data project is a prominent attempt at expressing and connecting objects of dierent domains using semantic web technology
Music and web ontologies
linkeddataorg musicontologycom
29
3REVEALING
TRENDS
30
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Lessons learnt
Hip-hop lyrics have more ldquordquo than Country ones
Any programming language with libraries to retrieve pages and parse XML can do the work
Data from dierent web APIs can be aggregated
A mash-up application can uncover hidden musical relationships among dierent domains
26
A more advanced mash-up
ismir2009beneldsnetgmapradio
27
From instance to concept
ere is no limit to the chain of API calls
To connect even more resources unique identiers work better than ambiguous names
Many web sites identify musical objects through a specic set of Musicbrainz IDs which allow to easily match the same item in multiple places
28
e Linking Open Data project is a prominent attempt at expressing and connecting objects of dierent domains using semantic web technology
Music and web ontologies
linkeddataorg musicontologycom
29
3REVEALING
TRENDS
30
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
A more advanced mash-up
ismir2009beneldsnetgmapradio
27
From instance to concept
ere is no limit to the chain of API calls
To connect even more resources unique identiers work better than ambiguous names
Many web sites identify musical objects through a specic set of Musicbrainz IDs which allow to easily match the same item in multiple places
28
e Linking Open Data project is a prominent attempt at expressing and connecting objects of dierent domains using semantic web technology
Music and web ontologies
linkeddataorg musicontologycom
29
3REVEALING
TRENDS
30
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
From instance to concept
ere is no limit to the chain of API calls
To connect even more resources unique identiers work better than ambiguous names
Many web sites identify musical objects through a specic set of Musicbrainz IDs which allow to easily match the same item in multiple places
28
e Linking Open Data project is a prominent attempt at expressing and connecting objects of dierent domains using semantic web technology
Music and web ontologies
linkeddataorg musicontologycom
29
3REVEALING
TRENDS
30
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
e Linking Open Data project is a prominent attempt at expressing and connecting objects of dierent domains using semantic web technology
Music and web ontologies
linkeddataorg musicontologycom
29
3REVEALING
TRENDS
30
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
3REVEALING
TRENDS
30
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
What is trendy
ldquoTrendrdquo is related to a specic time and context
Anything that is rapidly becoming famous in your enviroment (your friends your location hellip)
Mavens are the rst to pick up on nascent trends
Music example which artists should you now be listening to to keep up with the latest trends
31
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
is kind of information can be retrieved from music-related web communities such as Lastfm
Trendy artist of the month
Last month they mostly listened to
your friends
is month they are mostly listening to
32
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Hiding API calls with wrappers
Lastfm provides for each user the list of friends and the most played artists in a given period
ese data can be retrieved via Lastfm API or more easily using the Python wrapper pylast available at codegooglecomppylast
$ wget httppypipythonorgpackagessourceppylastpylast-0415targz$ gunzip lt pylast-0415targz | tar xvf -$ cd pylast-0415$ sudo python setuppy install
33
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Retrieving lists of friends
API wrappers abstract the functions that make HTTP calls to send and receive information
Using the pylast wrapper the code to obtain lists of friends from Lastfm is compact and clear
$ pythonimport pylastfrom lastfm_key import lastfm_keyapi = pylastget_lastfm_network(lastfm_key)friends = apiget_user(claudiob)get_friends()print Lastfm friends s friends
34
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Extracting trendy artists of the month
To reveal which artists a user should listen to
1 Retrieve the list of friends of that user
2 Retrieve the most played artists by the friends during this and the previous month printing those who have lsquogrownrsquo more in this period while excluding artists the user is already aware of
e code is included in the le clastfm_2py
$ python lastfm_2py claudiob
=raquo Trendy artists for claudiob1) Amy Winehouse already known by daddyrho recently discovered by kobra_cccpozzi pilomatic econ-luca
35
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Lessons learnt
Social data from the web helps uncover trends
Data for trends imply a temporal dimension a context (friends geographical location hellip) and a class of objects (artists tracks hellip) to observe
More transparent and lsquohumanrsquo than using collaborative ltering for recommendations
API wrappers shorten and clear up the code
36
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
4PERFORMING
AUDIO ANALYSIS
37
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
How do you extract acoustic features of a song
1 Write your own code
2 Use a software package
3 Retrieve from a web site
The web as a source of tools
echonestcomanalyze
38
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Estimating the tempo of a song
Acoustic analysis performed through a web API
upload lsquoUpload a track to e Echo Nests analyzer for analysis and later retrieval of track informationrsquo
get_tempo lsquoRetrieve the overall estimated tempo of a track in beats per minute after previously calling for analysis via uploadrsquo
Authentication is requireddeveloperechonestcompagesoverview
39
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
$ irb
require nethttp
require rexmldocument
require echonest_key
song = httpismir2009benfieldsnetm120bpmmp3
url= httpdeveloperechonestcomapiuploadresult = NetHTTPpost_form(URIparse(url)api_key =gt $echonest_key version =gt 3 url =gt song)
40
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Creating a Ruby script
Estimate tempo for the track m120bpmmp3
song_id = REXMLDocumentnew(resultbody)elements[track]attributes[id]
url = httpdeveloperechonestcomapiget_tempo
url+= id=song_id
url+= ampversion=3ampapi_key=$echonest_key
result = NetHTTPget_response(URIparse(url))
tempo = REXMLDocumentnew(resultbody)elements[tempo]text
puts The estimated tempo is tempo BPM
41
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Complete audio analysis
e code is included in the le cechonest_1rb
e script cechonest_2rb allows to specify the track location and estimates more features
$ ruby echonest_1rb
$ ruby echonest_2rb httpismir2009benfieldsnetm120bpmmp3
=raquo The estimated tempo is 120013 BPM
=raquo time_signature=gt 4 mode=gt 1 key=gt 5 tempo=gt 120
developerechonestcomforumsthread9
42
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Minormajor vs sadhappy
Songs in minor are sad
Songs in major are happy
Would you agree
lsquoSadrsquo and lsquoHappyrsquo
List songs by mood
List modes by mood Compare minormajor
43
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Running the experiment
e code is included in the le cechonest_3rb
Repeating the experiment with more songs can serve as a proper evaluation of the statement
Do not submit too many simultaneous queries
$ ruby echonest_3rb sad happy
=raquo sad songs are 025 major 075 minor happy songs are 100 major 000 minor
44
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Lessons learnt
e web makes available both musical data and tools for acoustic analysis
Even DJs can use web-based tools to remix
Symbolic analysis not availablehellip yet
e future of music software is on the web
45
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
5CAPTURING
SOCIAL DATA
46
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Social networks for musicians
Web sites for musician-to-musician networking
1 Grant access to an artistrsquos public music
2 Record relationships among musicians in the same network
3 Provide social data in the domain of music
Can be very useful for music informatics
47
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
SoundCloud an advanced music-sharing platform
A different kind of musical resource
soundcloudcom soundcloudcomapiconsole
48
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Retrieving lists of followers
Install the Python wrapper for SoundCloud API
Code is included in the le csoundcloud_1py
$ git clone gitgithubcomsoundcloudpython-api-wrappergit$ cd python-api-wrapper$ sudo python setuppy install
import scapifrom soundcloud_oauth import init_scoperoot = init_scope()user = rootusers(bfields)for friend in userfollowings() print Following s friend[username]
49
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
A different type of authentication
SoundCloud authenticates with OAuth protocol
csoundcloud_1py runs the full protocol
csoundcloud_2py includes a valid token only for this application
$ python soundcloud_2py
=raquo bfields is following Forss atl stunna
50
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Plotting networks of friends
Install the igraph library and Python wrapper
from
and test by drawing a simple graph into a le
$ pythonimport igraphg = igraphGraph(n=2 edges=[(01)])gwrite_svg(testsvg glayout(kk))
igraphsfnetdownloadhtml
pypipythonorgpypipython-igraph
and
=raquo
[testsvg]
51
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 2 =raquo
52
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
e code included in the le csoundcloud_3py
1 Adds a vertex for a given seed user
2 Gets from SoundCloud the list of people the user ldquofollowsrdquo
3 For each of these personsbull Recursively restart from 1 until the desired level of depthbull Adds an edge to connect to the person to the seed user
Plotting networks of friends
$ python soundcloud_3py bfields 3 =raquo
53
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Plotting as a web service
How to plot a snapshot of the full network
csoundcloud_4py collects the full network of SoundCloud friends (takes a long time)
LaNet-vi oers a web service that draws large scale networks of data (no software required)xavierinformaticsindianaedu
lanet-vi
54
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Plotting as a web service
ismir2009beneldsnetmsoundcloud_16kpng
55
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Lessons learnt
Musicians relate in online communities with each other (as friends followers hellip)
Social networks can easily be extracted and plotted either partially or completely
Plotting can also be outsourced to a web service
Researchers can benet for several applications playlist generation recommender systems hellip
56
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
6COLLECTING
FEEDBACK
57
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Subjective evaluation
Researchers need feedback in many scenarios
Setting up a web survey
isolated
hard to share
can vote twice (or never)
requires personal data
Recommender systems
Mood-based analysis
Automatic composition
hellipand more
has some drawbacks
58
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Benets of publishing the survey on Facebook
1 Collect personal data without lling any form
2 Explore social connections between users
3 Share and publish surveys through networks of friends
4 Potentially reach millions of users in a friendly environment
5 Attract more people with game-styled application
Advantages of social networks
59
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Advantages of social networks
appsfacebookcomherd-it
60
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
61
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Creating a PHP survey
e code is included in the le cfacebook_1phpltphp else $info = $_GET $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote $text = | $info[first_name] $info[last_name] $text = | $info[sex] $text = | $info[birth_year] $text = | $info[city] $file = fopen($data_file a) fwrite($file $text n) fclose($file) $file = file_get_contents($data_file r) $human = substr_count($file |Human|) $robot = substr_count($file |Robot|) echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
62
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Creating a Facebook application
1 Create a Facebook account
2 Navigate to facebookcomdevelopersappsphp
3 Add the Developer application to the Facebook prole
4 Set up a new application
63
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Setting up the environment
5 Copy and paste the application keys to cfacebook_keyphp
6 Download and unzip the Facebook PHP client library from facebookcomdevelopersappsphp to the c folder
7 Add the following lines at the top of cfacebook_1php
ltphp $app_id = 142884214891$api_key = 33e8acab5343ebfc3bc545c57c81c7e0$secret_key = d2721fe8b3276bd24a2d5a0d62b3f518 gt
ltphprequire_once(facebook_keyphp) require_once(facebook-platformphpfacebookphp)$facebook = new Facebook($api_key $secret)$user = $facebook-gtrequire_login() gt
64
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
8 Modify the rest of cfacebook_1php as follows
ltphp if(($vote = $_GET[vote])) gt
ltobject type=applicationx-shockwave-flash height=30 data=mp3playerswfautoplay=trueampampsong_url=httpismir2009benfieldsnetmsaxexmp3gtltobjectgt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
Creating a Facebook survey in PHP
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
ltphp if(($vote = $_GET[vote])) gt
ltfbmp3 src=httpismir2009benfieldsnetmsaxexmp3 title=Autumn Leaves album=Autumn Leaves artist=Human or Robot gt
ltformgtltbgtPersonal dataltbgtltbr gt Your name ltinput type=text name=first_name size=17gt ltinput type=text name=last_name size=17gt Your birth year ltinput type=text name=birth_year size=4gt Your sex ltinput type=radio name=sex value=malegt Male ltinput type=radio name=sex value=femalegt Female Your current home-town ltinput type=text name=city size=25gtltbgtSurveyltbgtltbr gt This song was performed by a ltinput type=submit value=Human name=vote gt or by a ltinput type=submit value=Robot name=vote gtltformgt
65
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
ltphp else $info = $_GET
$data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
9 Modify the rest of cfacebook_1php as follows
ltphp else $info = reset($facebook-gtapi_client-gtusers_getStandardInfo($user array(first_name last_name sex birthday current_location))) $info[birth_year] = isset($info[birthday]) date(Y strptime($info[birthday] m d Y)) $info[city] = isset($info[current_location]) $info[current_location][city] $data_file = tmpfb_surveytxt $text = | date(Ymd His) $text = | $vote [] echo Votes so far Human $human - Robot $robot echo ltpregt $file ltpregt gt
Creating a Facebook survey in PHP
66
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Deploying to Facebook
Update the code from the le cfacebook_2php to a web server and update Facebook settings
Click on the canvas tab
Fill the desired web address
Specify the location of the code
Select FBML as render method
Save changes
Visit the application page
67
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Deploying to Facebook
appsfacebookcomCANVAS_PAGE_URL
68
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Lessons learnt
Developing Facebook apps is fast and easy
Users can benet from the social environment
More social features can be exploited
69
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
CONCLUSIONS
70
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71
Mining the web for musical data is easy and fast
Every researcher can benet from this approach
Web APIs can be combined for specic goals
Online social networks are practical to collect human experiences and evaluate hypotheses
e web also oers tools for analysis and graphs
Give it a try
71