Skip to content

reactify/dj-spotify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DJ Spotify

Allows you to DJ using streamed content. Hacked together at MIDEM Music Hack Day 2014.

Here's the hack in action: http://www.youtube.com/watch?v=uTgwAMZiwMw

How it works

This system relies on a virtual machine (Parallels in my hack's case) to play a second Spotify stream. The two streams are then sent into individual tracks in Ableton Live, each with a Max For Live patch which reads the Spotify streams into internal buffers which can then be sped up or slowed down at will, effectively allowing you to beat-match and, theoretically, do a whole DJ with streamed content.

Disclaimer

This hack is incredibly impractical. It requires lots of different bits of software to each perform seemingly innocuous tasks, but every singly task is critical to the system working. If anyone can think of any ways to streamline this process, please do let me know. Needless to say, this implementation is OS X only, but it would definitely be possible on Windows, as well.

I do not have any intention to maintain or update this code. I am simply posting it here for prosperity and for tinkerers who are interested in how this was achieved. That said...

Components and required software

DJ Spotify topology The above is a diagram of how the hack works. As you can see it's a complete spider's web of messy hacks involving most components of the OS.

In order to recreate this particular set-up on your machine you will need the following software installed:

There are alternatives for many of these programs e.g. Jack instead of Soundflower, Virtual Box instead of Parallels, and Pure data is simply used to reroute the output of Soundflower to another input of Soundflower, so really, any DAW application capable of passing audio from an input to an ouput will do...

For the automatic retreival of EchoNest data for the currently playing Spotify track, you will also need:

If you choose to use Spotify and would like to display key and BPM information alongside your playlists, you can also install and use my Key and BPM Spotify app, the code for which can be found here:

Finally, if you would like to control Ableton Live with a custom DJing template on the iPad, install TouchOSC on your iPad:

Method

Two audio streams

  1. On your main machine, install all of the above software and start Spotify
  2. On your virtual machine, install Spotify and, if desired, Growl, pyechonest, appscript and pyOSC
  3. On your main machine start SoundFlower and set the system audio output to be SoundFlower (64ch) in your System Preferences
  4. Set the audio output of Parallels (note: not the system output of your virtual machine, but of the virtual machine hosting software itself) to be SoundFlower (2ch)
  5. Open Soundflower-re-route.pd and set Pd's input device to be SoundFlower (2ch) and it's output to be SoundFlower (64ch)
  6. Start Live Template.als in Ableton Live and set the audio input of Live to by SoundFlower (64ch). Set the audio output to be whatever you want e.g. Built-in Output or an external soundcard.

Start audio playing on your main and virtual machines, and, in Live, you should now see audio from your main machine coming in on Track 1, and audio from your virtual machine coming in on Track 2

Automated key and BPM retreival from Echonest

Unless otherwise stated, the following steps must be performed on both your main and virtual machines

  1. Open Growl and place the Rules.scpt file in the following path: "/Users/[username]/Library/Application Scripts/com.Growl.GrowlHelperApp/" Growl should run this AppleScript every time it receives a notification, so we use it to automatically launch the getTempoAndKey.py Python script which, in turn, queries Spotify for it's currently playing track, retreives the Key/BPM/Mode data for that track from EchoNest, and sends that information over OSC
  2. Check that Growl is running the AppleScript by uncommenting the 'say "hello"' line in the Rules.scpt. Try skipping tracks in Spotify. If your machine says 'Hello', then you're good to go
  3. In Rules.scpt change the path to the getTempoAndKey.py file to wherever you have it saved
  4. In getTempoAndKey.py change the EchoNest API Key on line 7 to your own one. Go here if you need to get an EchoNest API Key.
  5. On your main machine, change the port number on line 4 of getTempoAndKey.py to 8070, and to 8090 on the virtual machine
  6. In Live on your main machine, check that the key and BPM data is coming through to the Stream-Pitch Max For Live devices on tracks 1 and 2

Extra brownie points - controlling Live

Now that you've got all the audio coming in to Live, you could make MIDI mappings to any hardware controller you happen to have lying around. If you would like to use the TouchOSC layout I made for iPad, follow these steps:

  1. Set-up TouchOSC to communicate with your main machine. Instructions here
  2. Open TouchOSC Editor and sync the Max DJ.touchosc layout on to your iPad Instructions here
  3. Open TouchOSC on your iPad
  4. Open the Audio MIDI Setup app (Spotlight it) and open the MIDI Window (⌘+2)
  5. Double-click the Network window and you should see the name of your iPad in the Directory panel on the left hand side. Click on it and click 'Connect' below the panel
  6. Open the Max DJ layout on your iPad and go back into Live. With any luck, all the MIDI mappings should still be present in Live, but if they're not, remake them

Even more extra brownie points - displaying arist, title and BPM information in TouchOSC

The Live template also has the capacity to talk back to the TouchOSC layout so that it can display the aritst, title and BPM information of the currently playing tracks. To get this working:

  1. In the Master track in Live, open the Master-tempo-send Max For Live device and change the IP address and port number to those of your iPad. Again, see here for instructions on where to find those

Beer time!

Now, go and pour yourself a tasty beverage because you deserve it for getting this far. Tweet us at @reactify if you do because I would like to personally congratulate you (on getting this far, not pouring yourself a tasty beverage...)

Legal stuff

Copyright (c) 2014 Reactify Music LLP

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

All the hacky tools required to DJ with Spotify

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published