Archive for category web services

The Echo Nest remix 1.0 is released!

Version 1.0 of the Echo Nest remix has been released. Echo Nest Remix is an open source SDK for Python that lets you write programs that  manipulate music.  For example, here’s a python function  that will take all the beats of a song, and reverse their order:

def reverse(inputFilename, outputFilename):
    audioFile = audio.LocalAudioFile(inputFilename)
    chunks = audioFile.analysis.beats
    chunks.reverse()
    reversedAudio = audio.getpieces(audioFile, chunks)
    reversedAudio.encode(outputFilename)

When you apply this to a song by The Beatles you get something that sounds like this:

which is surprisingly recognizable,  musical – and yet different from the original.

Quite a few web apps have been written that use remix.  One of my favorites is DonkDJ, which will ‘put a donk‘ on any song.  Here’s an example: Hung Up by Madonna (with a Donk on it):

This is my jam lets you create mini-mixes to share with people.

myjam

And where would the web be without the ability to add more cowbell to any song.

There’s lots of good documentation already for remix. Adam Lindsay has created a most excellent overview and tutorial for remix. There’s API documentation and there’s documentation for the underlying Echo Nest web services that perform the audio analysis.  And of course, the source is available too.

So, if you are looking for that fun summer coding project, or if you need an excuse to learn Python, or perhaps you are a budding computational remixologist download remix, grab an API key from the Echo Nest and start writing some remix code.

Here’s one more example of the fun stuff you can do with remix.   Guess the song, and guess the manipulation:

, ,

4 Comments

#recsplease – the Blip.fm Recommender bot

blipfmJason has put together a mashup (ah, that term seems so old and dated now)  that combines twitter, blip.fm,  and the Echo Nest.  When you Blip a song, just add the tag #recsplease to the twitter blip and you’ll get a reply with some artists that  you might like to listen to.

playtapus

This is similar to recomme developed by Adam Lindsay but recomme has been down for a few weeks, so clearly there was a twitter-music-recommendation gap that needed to be filled.

Check out Jason’s Blip.fm/twitter recommender bot.

, , , , ,

1 Comment

libre.fm – what’s the point?

librelogoLibre.fm is essentially an open source clone of Last.fm’s audioscrobbler.  With Libre.fm you can scrobble  your music play behavior to a central server, where your data is aggregated with all of the other scrobbles and can be used to create charts, recommendations, playlists – all the sorts of things we see at Last.fm. As the name implies, everything about Libre.fm is free. All the Libre.fm code is released under the GNU AGPL.  You can run your own server.  You own your own data.

The Libre project is just getting underway.  Not only is paint is not dry, they’ve only just put down the drop cloth, got the brushes ready and  opened the can.  Right now there’s a minimal scrobbler server (called GNUkebox) that will take anyone’s scrobbles and adds them to a postgres database.  This server is compatible with Last.fm’s so nearly all scrobbling clients will scrobble to Libre.fm.  (Note that to get many clients to work you actually have to modify your /etc/hosts file to redirect outgoing connections that would normally go to post.audioscrobbler.com so that they go to the libre.fm scrobbling machine.  It is  a clever way to get instant support for Libre.fm by lots of clients, but I must admit I feel a bit dirty lying to my computer about where to send the scrobbles.)

Another component of Libre.fm is the web front end (called nixtape) that shows what people are playing, what is popular, artist charts and clouds.  (Imagine what Audioscrobbler.com looked like in 2005).  Here’s my Libre.fm page:

libreThere is already quite a lot of functionality on the web front end – there are (at least minimal) user, artist, album and track pages. However,  there are some critical  missing bits – perhaps most significant of these is the lack of a recommender.   The only discovery tool so far at Libre.fm is the clickable ‘Explore popular artist’ cloud:

libre2

Libre.fm has only been live for a few week – but it is already closing in on its millionth scrobble.  As I write this, about 340K tracks have been scrobbled by 2011 users with a total of 920052 plays. (Note that since Libre.fm lets you import your Last.fm listening history,  many of these plays have been previously scrobbled at Last.fm).

When you compare these numbers to Last.fm’s,  Libre.fm’s numbers are very small – but if you consider the very short time that it has been live, these numbers start to look pretty good.  What is even more important is that Libre.fm has already  built a core team of over two dozen developers.   Two dozen developers can write a crazy amount of code in a short time – so I’m expecting to see the gaps in Libre.fm functionality to be filled rather quickly. And as the gaps in functionality are eliminated,  more users will come (especially those users who’ve recently abandoned Last.fm when Last.fm started to charge users that don’t live in the U.S., U.K. or Germany).

I remember way back in 1985 reading this article in Byte magazine about this seemingly crazy guy named Richard Stallman who was creating his own operating system called GNU.  I couldn’t understand why he was doing it.  We already had MS-DOS and Unix (I was using DEC’s Ultrix at the time which was a mighty fine OS). I didn’t think we needed anything else.   But Stallman was on a mission – that mission was to create free software. Software that you were free to run, free to modify, free to distribute.  I was wrong about Stallman.  His set of tools became key parts of Linux and his ideas about ‘CopyLeft’ enabled the  open source movement.

When I first heard about Libre.fm, my reaction was very similar to my reaction back in 1985 to Stallman  – what’s the point?  Last.fm already provides all these services and much more. Last.fm lets you get access to your data via their web services.  Last.fm already has billions of scrobbles from millions of users.  Why do we need another Last.fm?  But this time I’m prepared to be wrong.  Perhaps we don’t really want our data held by one company. Perhaps a community of passionate developers can take the core concept of the audioscrobbler to somewhere new.  Just as Stallman’s crazy idea has changed the way we think about developing software, perhaps Libre.fm is the begining of the next revolution in music discovery.

Update – I asked mattl, founder of libre.fm, what his  motivation for creating libre.fm is. He says there are two prime motivations:

  1. Artistic – “I wants to support libre musicians.  To give them a platform where they are the ruling class.”
  2. freedom – “give everyone access to their data, so even if they don’t like what we’re  doing with libre music, the software is still free (to them and us)”

, ,

9 Comments

Removing accents in artist names

If you write software for music applications, then you understand the difficulties in dealing with matching artist names.   There are lots of issues: spelling errors, stop words (‘the beatles’ vs. ‘beatles, the’ vs ‘beatles’),  punctuation (is it “Emerson, Lake and Palmer” or “Emerson, Lake & Palmer“),  common aliases (ELP, GNR, CSNY, Zep), to name just  a few of the issues. One common problem is dealing with international characters.   Most Americans don’t know how to type accented characters on their keyboards so when they are looking for Beyoncé they will type ‘beyonce’.    If you want your application to find the proper artist for these queries you are going to have deal with these missing accents in the query.  One way to do this is to extend the artist name matching to include a check against a version of the artist name where all of the accents have been removed.   However, this is not so easy to do –  You could certainly  build  a mapping table of all the possible accented characters, but that is prone to failure. You may neglect  some obscure character mapping  (like that funny ř in Antonín Dvořák).

Luckily, in Java 1.6 there’s a pretty reliable way to do this.  Java 1.6 added a Normalizer class to the java. text package.  The Normalize class allows you to apply Unicode Normalization to strings.  In particular you can apply Unicode decomposition that will replace any precomposed character into a base character and the combining accent.  Once you do this, its a simple string replace to get rid of the accents.  Here’s a bit of code to remove accents:

    public static String removeAccents(String text) {
          return Normalizer.normalize(text, Normalizer.Form.NFD)
               .replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
    }

This is nice and straightforward code, and has no effect on strings that have no accents.

Of course ‘removeAccents’ doesn’t solve all of the problems – it certainly won’t help you deal with artist names like ‘KoЯn’ nor will it deal with the wide range of artist name misspellings.   If you are trying to deal normalizing aritist names   you should read  how Columbia researcher Dan Ellis has approached the problem.   I suspect that someday,   (soon, I hope) there will be a magic music web service  that will solve this problem once and for all and you”ll never again have to scratch our head at why you are listening to a song by Peter, Bjork and John, instead of a song by Björk.

, ,

4 Comments

The BPM Explorer

Last month I wrote about using the Echo Nest API to analyze tracks to generate plots that you can use to determine whether or not a machine is responsible for setting the beat of a song.   I received many requests to analyze tracks by particular  artists, far too many for me to do without giving up my day job.   To satisfy this pent up demand for click track analysis I’ve written an application called the BPM Explorer that you let you create your own click plots.  With this application you can analyze any song in your collection, view its click plot and listen to your music, synchronized with the plot.  Here’s what the app looks like:

Check out the application here:  The Echo Nest BPM Explorer.  It’s written in Processing and deployed with Java Webstart, so it (should) just work.

My primary motiviation for writing this application was to check out the new Echo Nest Java Client to make sure that it was easy to use from Processing.   One of my secret plans is to get people in the Processing community interested in using the Echo Nest API.  The Processing community is filled with some  ultra-creative folks that have have strong artistic, programming and data visualization skills.   I’d love to see more song visualizations like this and this that are built using the Echo Nest APIs.  Processing is really cool – I was able to write the BPM explorer in just a few hours (it took me longer to remember how to sign jar files for webstart than it did to write the core plotter).    Processing strips away all of the boring parts of writing graphic programming (create a frame,  lay it out with a gridbag, make it visible,  validate, invalidate, repaint, paint arghh!). For processing, you just write a method ‘draw()’ that will be called 30 times a second.   I hope I get the chance to write more Processing programs.

Update: I’ve released the BPM Explorer code as open source – as part of the echo-nest-demos project hosted at google-code.  You can also browse the read  for the BPM Explorer.

, , , ,

11 Comments

New Java Client for the Echo Nest API

Today we are releasing a Java client library for the Echo Nest developer API.   This  library gives the Java programmer  full access to the Echo Nest developer API. The API includes artist-level methods such as getting artist news, reviews, blogs, audio, video, links,  familiarity, hotttnesss, similar artists, and so on.  The API also includes access to the renown track analysis API that will allow you to get a detailed musical analysis of any music track. This analysis includes loudness, mode, key, tempo, time signature, detailed beat structure, harmonic content, and timbre information for a track.

To use the API you need to get an Echo Nest developer key (it’s free) from developer.echonest.com.   Here are some code samples:

// a quick and dirty audio search engine
   ArtistAPI artistAPI = new ArtistAPI(MY_ECHO_NEST_API_KEY);

   List<Artist> artists = artistAPI.searchArtist("The Decemberists", false);
   for (Artist artist : artists) {
       DocumentList<Audio> audioList = artistAPI.getAudio(artist, 0, 15);
       for (Audio audio : audioList.getDocuments()) {
          System.out.println(audio.toString())
       }
   }
// find similar artists for weezer
   ArtistAPI artistAPI = new ArtistAPI(MY_ECHO_NEST_API_KEY);
   List<Artist> artists = artistAPI.searchArtist("weezer", false);
    for (Artist artist : artists) {
          List<Scored<Artist>> similars = artistAPI.getSimilarArtists(artist, 0, 10);
          for (Scored<Artist> simArtist : similars) {
              System.out.println("   " + simArtist.getItem().getName());
          }
     }

// Find the tempo of a track
    TrackAPI trackAPI = new TrackAPI(MY_ECHO_NEST_API_KEY);
    String id = trackAPI.uploadTrack(new File("/path/to/music/track.mp3"), false);
    AnalysisStatus status = trackAPI.waitForAnalysis(id, 60000);
    if (status == AnalysisStatus.COMPLETE) {
       System.out.println("Tempo in BPM: " + trackAPI.getTempo(id));
    }

There are some nifty bits in the API.  The API will cache data for you so frequently requested data (everyone wants the latest news about Cher) will be served up very quickly. The cache can be persisted, and the shelf-life for data in the cache can be set programmatically (the default age is one week).  The API will (optionally) schedule requests to ensure that you don’t exceed your call limit.   For those that like to look under the hood, you can turn on tracing to see what the method URL calls look like and see what the returned XML looks like.

If you are interested in kicking the tires of the Echo Nest API and you are a Java or Processing programmer, give the API a try.

If you have any questions / comments or problems abut the API  post to the Echo Nest Forums.

, ,

1 Comment

track upload sample code

One of the biggest pain points users have with the Echo Nest developer API is with the track upload method.  This method lets  you upload a track for analysis (which can be subsequently retrieved by a number of other API method calls such as get_beats, get_key, get_loudness and so on).   The track upload, unlike all of the other of The Echo Nest methods requires you to construct a multipart/form-data post request. Since I get a lot of questions about track upload I decided that I needed to actually code my own to get a full understanding of how to do it – so that (1) I could answer detailed questions about the process and (2) point to my code as an example of how to do it.   I could have used a library (such as the Jakarta http client library) to do the heavy lifting but I wouldn’t have learned a thing nor would I have some code to point people at.  So I wrote some Java code (part of the forthcoming Java Client for the Echo Nest web services) that will do the upload.

You can take a look at this post method in its google-code repository. The tricky bits about the multipart/form-data post is getting the multip-part form boundaries just right.  There’s a little dance one has to do with the proper carriage returns and linefeeds, and double-dash prefixes and double-dash suffixes and random boundary strings.  Debugging can be a pain in the neck too, because if you get it wrong,  typically the only diagnostic one gets is a ‘500 error’ which means something bad happened.

Track upload can also be a pain in the neck because you need to wait 10 or 20 seconds for the track upload to finish and for the track analysis to complete.  This time can be quite problematic if you have thousands of tracks to analyze.  20 seconds * one thousand tracks is about 8 hours.  No one wants to wait that long to analyze a music collection.  However, it is possible to short circuit this analysis.  You can skip the upload entirely if we already have performed an analysis on your track of interest.   To see if an analysis of a track is already available you can perform a query such as ‘get_duration’ using the MD5 hash of the audio file.  If you get a result back then we’ve already done the analysis and you can skip the upload and just use the MD5 hash of your track as the ID for all of your queries.   With all of the apps out there using the track analysis API, (for instance, in just a week, donkdj has already analyzed over 30K tracks) our database of pre-cooked analyses is getting quite large – soon I suspect that you won’t need to perform an upload of most tracks (certainly not mainstream tracks). We will already have the data.

, , , ,

7 Comments

Killer music technology

We’ve been head down here at the Echo Nest putting the finishing touches on what I think is a game changer for music discovery.   For years, music recommendation companies have been trying to get collaborative filtering technologies to work.  These CF systems work pretty well, but sooner or later, you’ll get a bad recommendation. There are just too many ways for a CF recommender to fail.   Here at the ‘nest we’ve decided to take a completely different approach.  Instead of recommending music based on the wisdom of the crowds or based upon what your friends are listening to, we are going to recommend music just based on whether or not the music is good.   This is such an obvious idea –  recommend music that is good, and don’t recommend music that is bad – that it is a puzzle as to why this approach hasn’t been taken before.  Of course deciding which music is good and which music is bad can be problematic. But the scientists here at The Echo Nest have spent years building machine learning technologies so that we can essentially reproduce the thought process of a Pitchfork music critic. Think of this technology  as Pitchfork-in-a-box.

Our implementation is quite simple. We’ve added a single API method ‘get_goodness’ to our set of developer offerings.  You give this method an Echo Nest artist ID (that you can obtain via an artist search call) and get_goodness returns a number between zero and one that indicates how good or bad the artist is.    Here’s an example call for radiohead:

http://developer.echonest.com/api/get_goodness?api_key=EHY4JJEGIOFA1RCJP&id=music://id.echonest.com/~/AR/ARH6W4X1187B99274F&version=3

The results are:

<response version="3">
   <status>
     <code>0</code>
      <message>Success</message>
   </status>
   <query>
    <parameter name="api_key">EHY4JJEGIOFA1RCJP</parameter>
    <parameter name="id">music://id.echonest.com/~/AR/ARH6W4X1187B99274F</parameter>
  </query>
  <artist>
    <name>Radiohead</name>
    <id>music://id.echonest.com/~/AR/ARH6W4X1187B99274F</id>
    <goodness>0.47</goodness>
    <instant_critic>More enjoyable than Kanye bitching.</instant_critic>
  </artist>
</response>

We also include in the response, a text string that indicates how you should feel about this artist.  This is just the tip of the iceberg for our forthcoming automatic music review technology that will generate blog entries, amazon reviews, wikipedia descriptions and press releases automatically, just based upon the audio.

We’ve made a web demo of this technology that will allow you try out the goodness API. Check it out at:  demo.echonest.com.

We’ve had lots of late nights in the last few weeks, but now that this baby is launched, time to celebrate (briefly) and then on to the next killer music tech!

25 Comments

The Billboard API

220px-billboard_logosvg1Billboard, the venerable maintainer of the Billboard Hot 100 and a bevy of other music charts, is now making this data available via an API.  The API “puts the entire rich history of the Billboard charts at your fingertips to sample and mix into your web pages and applications.”.  The API is in public beta –  but already it is supplying some really good information.

The first service that they’ve rolled out is the ‘Chart’ service, which lets you search and retrieve Billboard chart information.

For example, to find all appearances of The Beatles  on any of the Billboard charts during the first week of June in 1964, you could make the call:

http://api.billboard.com/apisvc/chart/v1/list?artist=The+Beatles&sdate=1964-06-01&edate=1964-06-08&api_key=your_key

With results:

<?xml version='1.0' encoding='UTF-8'?>
<searchResults firstPosition='1' totalReturned='6' totalRecords='6'>
    <chartItem id='8807769' rank='2' exrank='0'>
        <chart id='3070264'>
            <name>The Billboard Hot 100</name>
            <issueDate>1964-06-06</issueDate>
            <specId>379</specId>
            <specType>Singles</specType>
        </chart>
        <artist>The Beatles</artist>
        <writer />
        <song>Love Me Do</song>
        <producer />
        <catalogNo>9008</catalogNo>
        <promotion />
        <distribution>Tollie</distribution>
        <peak>1</peak>
        <weeksOn>14</weeksOn>
    </chartItem>
    <chartItem id='8715479' rank='4' exrank='0'>
        <chart id='3068613'>
            <name>The Billboard 200</name>
            <issueDate>1964-06-06</issueDate>
            <specId>305</specId>
            <specType>Albums</specType>
        </chart>
        <artist>The Beatles</artist>
        <writer />
        <song>The Beatles' Second Album</song>
        <producer />
        <catalogNo>2080</catalogNo>
        <promotion />
        <distribution>Capitol</distribution>
        <peak>1</peak>
        <weeksOn>55</weeksOn>
    </chartItem>
    <chartItem id='8715481' rank='6' exrank='0'>
        <chart id='3068613'>
            <name>The Billboard 200</name>
            <issueDate>1964-06-06</issueDate>
            <specId>305</specId>
            <specType>Albums</specType>
        </chart>
        <artist>The Beatles</artist>
        <writer />
        <song>Meet The Beatles!</song>
        <producer />
        <catalogNo>2047</catalogNo>
        <promotion />
        <distribution>Capitol</distribution>
        <peak>1</peak>
        <weeksOn>71</weeksOn>
    </chartItem>
    <chartItem id='8807803' rank='36' exrank='0'>
        <chart id='3070264'>
            <name>The Billboard Hot 100</name>
            <issueDate>1964-06-06</issueDate>
            <specId>379</specId>
            <specType>Singles</specType>
        </chart>
        <artist>The Beatles</artist>
        <writer />
        <song>Do You Want To Know A Secret</song>
        <producer />
        <catalogNo>587</catalogNo>
        <promotion />
        <distribution>Vee-Jay</distribution>
        <peak>2</peak>
        <weeksOn>11</weeksOn>
    </chartItem>
    <chartItem id='8715486' rank='11' exrank='0'>
        <chart id='3068613'>
            <name>The Billboard 200</name>
            <issueDate>1964-06-06</issueDate>
            <specId>305</specId>
            <specType>Albums</specType>
        </chart>
        <artist>The Beatles</artist>
        <writer />
        <song>Introducing...The Beatles</song>
        <producer />
        <catalogNo>1062</catalogNo>
        <promotion />
        <distribution>Vee-Jay</distribution>
        <peak>2</peak>
        <weeksOn>49</weeksOn>
    </chartItem>
    <chartItem id='8807777' rank='10' exrank='0'>
        <chart id='3070264'>
            <name>The Billboard Hot 100</name>
            <issueDate>1964-06-06</issueDate>
            <specId>379</specId>
            <specType>Singles</specType>
        </chart>
        <artist>The Beatles</artist>
        <writer />
        <song>P.S. I Love You</song>
        <producer />
        <catalogNo>9008</catalogNo>
        <promotion />
        <distribution>Tollie</distribution>
        <peak>10</peak>
        <weeksOn>8</weeksOn>
    </chartItem>
</searchResults>

You can restrict searches to various charts (Hot Country, Pop 100, Top Latin, etc.) , and you can search  by artist and/or song name over a range of dates.  (Unfortunately, but not too surprisingly, the data for the current month is not available in the searches).

The terms-of-service seem pretty reasonable- you are allowed to make 1,500 API calls per day at up to 2 queries per second.  Commercial use seems to be allowed (But I’m not a lawyer, so you should check for yourself).  However, according to the terms, you are not allowed to store any of the Billboard data. The services are well documented, support JSON as well as XML output and query times are fast.

I can think of all sorts of uses for this data  – to help create playlists for the 25 year high school reunion, tracking artist popularity over time, answering bar room music questions like “What was the highest charting instrumental-only single?” or “Did Ringo ever have a hit?”.  It is perfect data for the Music Alchemists that are trying to build  an automatic hit predictor.

The Billboard chart API is an excellent addition to the world of music web services.   It goes straight into my Top Ten Music APIs chart – with a bullet.

, ,

7 Comments

Day #2 at the startup

I just finished day #2 at my new job.  Sorry to be so cagey about where I was going, but they wanted to keep it quiet until they could  do a press release about it.   I see the press release is public now, so I’m free to talk about my new job.

As many of the commenters have guessed, I’ve joined, as  the director of the developer community,  The Echo Nest –   a company that is devoted to providing music intelligence for the next generation of online music application.   In this role, I will work with the rest of the  Echo Nest team to help grow an active, vibrant music application developer  community around The Echo Nest  developer API.

I’m really excited to be here at The Echo Nest.   The Echo Nest has already established a reputation as a company that provides a new breed  of hardcore music intelligence.  The Echo Nest goes far beyond the “wisdom of the crowds” model of music discovery (“People who listened to the Beatles also listened to the Rolling Stones”). Instead of just data mining user behavior, The Echo Nest crawls the web to learn everything it can about music by analyzing what the world is saying about music.  The Echo Nest also directly analyzes the audio content of music – extracting musical traits such as key, tempo, structure, timbre from the audio.

Home of The Echo Nest

Home of The Echo Nest

From this  analysis of the social context, the user behavior and the actual audio, the Echo Nest gets a deep understanding of the entire world music.   It knows which artists are getting the most buzz, which artists are getting stale,  how and why artists are related, what words are being used to describe the music.     This data goes far beyond the “if you like Britney, you might like Christina” level.  The Echo Nest understands enough about music to be able to answer queries such as “make me a playlist of  songs with a tempo of 90 beats per minute by an unknown emo artist that sounds something like Dashboard Confessional,  and has violins”.  The really neat thing is that the Echo Nest is exposing a lot of this functionality in their developer API.  This lets anyone who is building a music application to tap into this large resource of music intelligence.

One of my main duties is to be the voice of the developer in the Echo Nest.  I’ve written my fair share of music apps, so I have a good idea of some of the many pain points and difficulties that a music application developer has to face, but I’d like to hear more, so if you are developing a music application and you need a particular problem solved let me know – or better yet, post to The Echo Nest developer forums.

I’ll be writing a lot about The Echo Nest in upcoming posts – in particular about using the developer APIs, but I shall still continue to post about all of the interesting things going on the music space – so this blog won’t be too much different from Duke Listens!

6 Comments