TL:DR - Using AppleScript, MIDI IAC Driver, some kludgy Python, you can control Spotify from Ableton/Push
Prerequisite: Some ability to capture your spotify output. I'm using "Loopback" from Rogue Amoeba
MacOS:
1) Install SpotifyControl applescript from github
https://github.com/dronir/SpotifyControl
1a) Create the symlink to /usr/local/bin/spotify per the SpotifyControl instructions.
2) In 'Audio Midi Setup', create a new IAC driver port called "Spotify"
Ableton:
3) Under the MIDI configuration for the "Spotify" IAC port, set Input=Remote, Output=Track
3a) Create a new MIDI track, output to channel 16 (or whatever you want, edit the script accordingly)
3b) For each command you want to execute, create a midi note, with looping off
For mine, I named them "Track", "Playlist", "Restart", "Stop", "Play/Pause", "Next", "Prev", and "Shuffle" corresponding to notes 127-120 respectively.
I've edited the python script argument for note 127 and 126 to go to a specific song, and a specific playlist respectively.
4) From the command line, install "mido" and "python-rtmidi" modules:
e.g., "pip install mido" and "pip install python-rtmidi"
Python:
Save/run the code below in a Terminal:
Code: Select all
import mido
import os
DEBUG=False
# My desired MIDI channel
channel = 15
midiNotes = {
127: {"command": "spotify play", "arg": "EnteraSpotifyURIHereToPlayIt" },
126: {"command": "spotify play", "arg": "EnterASpotifyPlaylistURIHereToPlayIt"},
125: {"command": "spotify jump", "arg": "0"},
124: {"command": "spotify stop", "arg": "" },
123: {"command": "spotify play/pause", "arg": ""},
122: {"command": "spotify next", "arg": ""},
121: {"command": "spotify prev", "arg": ""},
120: {"command": "spotify shuffle", "arg": ""},
}
with mido.open_input('IAC Driver Spotify') as inport:
for msg in inport:
if DEBUG: print(msg)
# only process "note_off" messages
if msg.type == "note_off" and msg.channel == channel:
try:
if DEBUG: print(midiNotes[msg.note])
os.system(midiNotes[msg.note]['command'] + " " + midiNotes[msg.note]['arg'])
except KeyError as e:
print("Unknown command received: ", (e))
-j