Archive for category code

Infinite Jukebox improved

It has been over two years since the Infinite Jukebox was first released after Music Hack Day Boston 2012.  Since then millions of people have spent nearly a million hours listening to infinite versions of their favorite songs. It has been my most popular hack.

There has always been a problem with the Infinite Jukebox. Certain songs have sections with very dense interconnections. For these songs the Infinite Jukebox would sometimes get stuck playing the same section of the song for many minutes or hours before breaking free.  This morning I finally sat down and worked out a good way to deal with this problem. The Infinite Jukebox will now try to steer the song toward the beats that have been played the least. When the jukebox is deciding which beat to play next, it will search through all the possible future paths up to five beats into the future to find the path that brings the jukebox to the least played part of the song.  The result is that we exit out of the rats nest of connections rather quickly.  The code is quite succinct – just 20 lines in one recursive function.  Good payback for such a small amount of code.

Infinite_Jukebox_for_Turn_Down_by_Rittz

While I was in the codebase, I made a few other minor changes. I switched around the color palettes to favor more green and blue colors, and I use a different color to draw the beat connections when we make a jump.

Leave a comment

More on “Where’s the Drama?”

My Music Hack Day Berlin hack was “Where’s the Drama?” – a web app that automatically identifies the most dramatic moment in any song and plays it for you. I’ve been having lots of fun playing with it … and even though (or perhaps because) I know how it works, I’m often surprised at how well it does at finding the most dramatic moments.  Here are some examples:

How does it work? The app grabs the detailed audio analysis for the song from The Echo Nest.  This includes a detailed loudness map of the song. This is the data I use to find the drama.  To do so, I look for the part of the song with the largest rise in volume over the course of a 30 second window (longer songs can have a bit of a longer dramatic window). I give extra weight to crescendos that culminate in louder peaks (so if there are two crescendos that are 20dB in range but one ends at 5dB louder, it will win). Once I identify the most dynamic part of a song, I pad it a bit (so we get to hear a bit of the drop after the build).

The rest is just UI – the song gets plotted as a heavily filtered loudness curve with the dramatic passage highlighted. I plot things with Highcharts, which is a pretty nifty javascript plotting and charting library. I recommend.

 Where_is_the_Drama_

Playing the music – I wanted to use Spotify to play the music, which was a bit problematic since there currently isn’t a way to play full streams with the Spotify Web API, so I did a couple of hacky hacks that got me pretty far. First of all, I discovered that you can add a time offset to a Spotify URI like so:

        spotify:track:2SHnUyZq0zwmvRIl4WY77G#1:05

When this URI is opened in Spotify (even when opened via a browser), Spotify will start to play the song a the 1:05 time offset.  

I still needed to be able to stop playing the track – and there’s no way to do that directly – so instead, I just open the URI:

      spotify:track:3nKrmorxtDSxnqvMgJudmV

which happens to be the URI for John Cage’s 4’33.  In other words, to stop playing one track, I just start playing another (that happens to be silent).  The awesome side effect of this is that I’ll be slowly turning anyone who uses “Where’s the Drama?” into experimental music listeners as the Spotify recommendation system responds to all of those John Cage ‘plays’. This should win some sort of ‘hackiest hack of the year’ award.

It was a fun hack to make, and great fun to demo. And now that I have the app, I am no longer wasting time listening to song intros and outros, I can just get to the bit of the song that matters the most. 

, , , , , ,

3 Comments

Acrostify – make Spotify playlists with embedded secret messages

For my summer vacation early-morning coding for fun project I revamped my old Acrostic Playlist Maker to work with Spotify.  The app, called Acrostify, will generate acrostic playlists with the first letter of each song in the playlist spelling out a secret message.  With the app, you can create acrostic playlists and save them to Spotify.

 

Screen Shot 2014-08-07 at 6.38.41 AM

The app was built using The Echo Nest and Spotify APIs. The source is on github.

Give it a try at Acrostify.

 

,

1 Comment

Outside Lands Recommendations

I am at Outside Hacks this weekend – A hackathon associated with the Outside Lands music festival. For this hack I thought it would be fun to try out the brand new Your Music Library endpoints in the Spotify Web API. These endpoints let you inspect and manipulate the tracks that a user has saved to their music. Since the hackathon is all about building apps for a music festival, it seems natural to create a web app that gives you festival artist recommendations based upon your Spotify saved tracks. The result is the Outside Lands Recommender:

 

Your_Outside_Lands_Festival_Recommendations

 

The Recommender works by pulling in all the saved tracks from your Spotify ‘Your Music’ collection, aggregating the artists and then using the Echo Nest Artist Similar API to find festival artists that match or are similar to those artists. The Spotify API is then used to retrieve artist images and audio samples for the recommendations where they are presented in all of their bootstrap glory.

This was a pretty straight forward app, which was good since I only had about half the normal hacking time for a weekend hackathon. I spent the other half of the time building a festival dataset for hackers to use (as well as answering lots of questions about both the Spotify and Echo Nest APIs).

It has been a very fun hackathon. It is extremely well organized, the Weebly location is fantastic, and the quality of hackers is very high. I’ve already seen some fantastic looking hacks and we are still a few hours from demo time.  Plus, this happened.

Screenshot_7_27_14__12_32_PM

Two more victims

,

Leave a comment

Outside Lands lineup

I’m on my way to Outside Hacks - a hackathon tied in with the Outside Lands music festival.  Since many hacks at the hackathon will be related to the festival it is pretty important to have a machine-readable version of the artist lineup for the festival. However, I couldn’t find any online.  Since I had an hour in the airport lounge, and the airport actually has decent WiFi, I thought I would try to be a good hacker citizen and generate an easily parseable lineup.

A little python + some BeautifulSoup and a bit of Echo Nest Rosetta Data and I have created an Outside Lands lineup JSON that includes links to artist pages, plus Echo Nest, Spotify and Rdio IDs.  The JSON is hosted online at:

http://static.echonest.com/OutsideLands/lineup_2014.json

Here’s the code:

It’s about time to get on the plane. If you can think of other interesting data to add to the lineup json let me know and I’ll try to add it before the hackathon.

Leave a comment

Fetching my saved tracks from Spotify

The @SpotifyPlatform team just pushed out an update to the Spotify Web API that lets a developer retrieve and manipulate the tracks that a user has saved in ‘Your Music’. To show off this new functionality I wrote a quick demo that shows how to fetch the saved tracks for a Spotify user via the nifty new API.  The demo will first solicit permission from the user, and if the user grants such permissions, the app will then retrieved the saved tracks and show them as a simple list.

My Saved Tracks

 

The demo is on line here: My Saved Tracks and the source is on github.

,

Leave a comment

Set Listener update – now listen to specific shows in Spotify

Last month I released the Set Listener –  a web app that lets you create a Spotify playlist for an artist’s most recent show.   A frequent request by users has been to allow the creation of a Spotify playlist for any show, not just the most recent one. However, I didn’t want to have to implement an elaborate event search and browse feature (this was supposed to be a quick hack) especially since SetList.fm already implements this browsing. So instead I did a bit of hack to implement this feature – in addition to accepting an artist name, the Set Listener will accept the url of any setlist.fm show. If you enter a setlist.fm show URL, the Set Listener will grab the songs for that show and generate the playlist. Here’s the flow:

Go to setlist.fm and browse until you find your show of interest. Grab the URL

God_Is_an_Astronaut_Concert_Setlist_at_Melnā_Piektdiena__Riga_on_May_19__2014___setlist_fm

 

Paste the URL into the Set Listener and you should be good to go:

The_Set_Listener

,

3 Comments

Follow

Get every new post delivered to your Inbox.

Join 1,265 other followers