Skip to content

Instantly share code, notes, and snippets.

@mlegore
Last active December 19, 2022 23:01
Show Gist options
  • Save mlegore/477741b6b6a2c8f658d81d2c02de0974 to your computer and use it in GitHub Desktop.
Save mlegore/477741b6b6a2c8f658d81d2c02de0974 to your computer and use it in GitHub Desktop.
My custom MPK249 control script for Ableton Live. Only tested on Windows 10 & Live 10. It fixes the automap for device knobs to automap to the knobs able the 249's sliders. Go to C:\ProgramData\Ableton\Live 10 Suite\Resources\MIDI Remote Scripts\MPK249 and make a backup of that folder and put this script in the folder and restart Ableton.
# Embedded file name: c:\Jenkins\live\output\win_64_static\Release\python-bundle\MIDI Remote Scripts\MPK249\MPK249.py
from __future__ import absolute_import, print_function, unicode_literals
from _Framework.ControlSurface import ControlSurface
from _Framework.Layer import Layer
from _Framework.DrumRackComponent import DrumRackComponent
from _Framework.TransportComponent import TransportComponent
from _Framework.DeviceComponent import DeviceComponent
from _Framework.MixerComponent import MixerComponent
from _Framework.MidiMap import MidiMap as MidiMapBase
from _Framework.MidiMap import make_button, make_encoder, make_slider
from _Framework.InputControlElement import MIDI_NOTE_TYPE, MIDI_CC_TYPE
class MidiMap(MidiMapBase):
def __init__(self, *a, **k):
super(MidiMap, self).__init__(*a, **k)
self.add_button(u'Play', 0, 118, MIDI_CC_TYPE)
self.add_button(u'Record', 0, 119, MIDI_CC_TYPE)
self.add_button(u'Stop', 0, 117, MIDI_CC_TYPE)
self.add_button(u'Loop', 0, 114, MIDI_CC_TYPE)
self.add_button(u'Forward', 0, 116, MIDI_CC_TYPE)
self.add_button(u'Backward', 0, 115, MIDI_CC_TYPE)
self.add_matrix(u'Sliders', make_slider, 0, [[12,
13,
14,
15,
16,
17,
18,
19]], MIDI_CC_TYPE)
self.add_matrix(u'Encoders', make_encoder, 0, [[22,
23,
24,
25,
26,
27,
28,
29]], MIDI_CC_TYPE)
self.add_matrix(u'Arm_Buttons', make_button, 0, [[32,
33,
34,
35,
36,
37,
38,
39]], MIDI_CC_TYPE)
self.add_matrix(u'Drum_Pads', make_button, 1, [[81,
83,
84,
86],
[74,
76,
77,
79],
[67,
69,
71,
72],
[60,
62,
64,
65]], MIDI_NOTE_TYPE)
class MPK249(ControlSurface):
def __init__(self, *a, **k):
super(MPK249, self).__init__(*a, **k)
with self.component_guard():
midimap = MidiMap()
drum_rack = DrumRackComponent(name=u'Drum_Rack', is_enabled=False, layer=Layer(pads=midimap[u'Drum_Pads']))
drum_rack.set_enabled(True)
transport = TransportComponent(name=u'Transport', is_enabled=False, layer=Layer(play_button=midimap[u'Play'], record_button=midimap[u'Record'], stop_button=midimap[u'Stop'], seek_forward_button=midimap[u'Forward'], seek_backward_button=midimap[u'Backward'], loop_button=midimap[u'Loop']))
transport.set_enabled(True)
device = DeviceComponent(name='Device', is_enabled=False, layer=Layer(parameter_controls=midimap['Encoders']))
device.set_enabled(True)
mixer_size = len(midimap[u'Sliders'])
mixer = MixerComponent(mixer_size, name=u'Mixer', is_enabled=False, layer=Layer(volume_controls=midimap[u'Sliders'], arm_buttons=midimap[u'Arm_Buttons']))
mixer.set_enabled(True)
@ammanueladdis
Copy link

i love you good sir :) from a newly happy MPK249 owner

@jleiv
Copy link

jleiv commented Oct 21, 2018

Hi mlegore. Can you help me implement this? I've gone through the hidden folders of Ableton yet I'm still having trouble. I appreciate the effort you've put in.

Copy link

ghost commented Nov 25, 2018

This works perfectly with Ableton 10.0.3 on Mac high sierra. Thank you so much!

@ibalashov
Copy link

ibalashov commented Dec 6, 2018

I'm new to this. Everybody is saying MPK249 does not play well with Ableton. Does this script solve the issue?

@akuzni2
Copy link

akuzni2 commented Dec 8, 2018

dope! Cant thank you enough for this script. Got this working on OSX and Live 9. For anyone trying to do this on OSX the location of the Midi Scripts folder is as follows.

  1. Go to applications folder, right click on Ableton -> Contents -> App-Resources-> Midi Remote Scripts -> MPK249. Put in this .py file and you get the blue hand :)

@neilsutcliffe
Copy link

neilsutcliffe commented Aug 7, 2019

This correctly maps the knobs to the macro knobs in the same way the push does.

I'm wondering if there is a way to automate the endless encoders that the mpk249 has to behave like the push. I can set them to INC/DEC2 on the MPK, but Ableton with the above script has no idea how to interpret that.

Additionally the index of the buttons for track selection is absolute to the top left item of the screen, and not the range of 8 displayed on the push. My ultimate dream scenario is that the controls mirror those on the Push with the faders acting as matching volume faders.

@neilsutcliffe
Copy link

Update: This works for endless encoders. This should give you a more intuitive experience. You can actually move the knob on the push and the mpk249 in opposite directions and keep the value in the same place!

http://richardmedek.com/2016/01/13/ableton-live-and-akais-endless-encoders/

@seejaycee
Copy link

Does this work for the MPK261? I put the file into the folder and now MPK261 isn’t showing up in the Control Surface list :( even after putting back the original backup files it still doesn’t show up I’m so lost

@CodeBrotha
Copy link

Will this work for MPK261?

@neilsutcliffe
Copy link

You may have to make similar modifications to the files in the MPK261. The uncompiled files are available on github. Just google for MPK261.py or similar. If the files are placed in the same location as the pyc (compiled) file. They will be used.

@ksitch
Copy link

ksitch commented May 21, 2020

Hey there. For some reason, when I put this in my folder, it doesn't show up under control surface anymore. I think it may be because it's a PY and not a PYC. I'm a mac user. Can anyone help here? Would appreciate it!

@maxcloutier13
Copy link

maxcloutier13 commented Oct 4, 2020

Spent a couple more hours on this and it somehow started working. Not sure what was missing but hey ;o)
EDIT: Actually it's adding this line that fixed it for me: self.set_device_component(device)
Sometimes the blue hand won't appear on the first device after load, but if I select another one it will work from there.
Missing a couple things to be complete, but it's getting there.
Thanks for the reference.

I also implemented the fix for the relative encoder mentioned by neilsutcliffe
My script for the MPK261: https://github.com/maxcloutier13/MPK261-MIDI-Remote-Script

@maxcloutier13
Copy link

Things eventually started making sense. My solution was crude but I've fixed all 3 problems I had with my MPK261.
1 - Encoders automap to current track device.
2 - Encoders are actually using the relative mode...
3 - And the B and C banks are fully working for a nice 24 track arming and volume control.

Thanks again mlegore. This post was the start of the rabbit hole ;o)
Feel free to steal my trick.

@pipposowlo
Copy link

Hi, I am on win10/live10 and I created the mpk249.py file and put it in the path you suggested. When I reload ableton, I notice that the knobs that used to control each track panning now do not control that anymore. Then I tried to put Operator in a midi track, enable the track and check if the knobs do anything (e.g. controlling the pitch) but they don't. Nothing happens. I also tried changing knobs behaviour (from MIDI to INC/DEC2) but no succe either....Can someone point me in the right direction ? Thanks!

@neilsutcliffe
Copy link

neilsutcliffe commented Oct 21, 2020

They won't do anything on instruments alone. They are designed for macros. All the preset instruments have these.

What you can also do is check the logs for python errors. Nothing gets logged to the screen if the code is broken so you'll have to do some digging.

@pipposowlo
Copy link

Hey, thanks for the hint. Still the macro knobs weren't moving. But adding the self.set_device_component(device) string made the trick also for me as maxcloutier13 pointed out!

@dangdangofficial
Copy link

Made an account just to thank you for this!! I just purchased an MPK249 yesterday and this solved so many issues I never would've solved on my own. Followed your instructions (placing in the MPK249 folder instead of the 261 folder) and it worked like a charm! Just need to figure out how to have additional mapped configs for other VSTs and plugins. Seriously, this is a lifesaver, thank you so much for your work!!!

@participationaward
Copy link

Thank you sir <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment