Last active
July 7, 2024 01:45
-
-
Save miguno/7b4c86a0ac84df7a86974968a1c111da to your computer and use it in GitHub Desktop.
MidiPipe AppleScript for macOS to reconfigure the AKAI APC 40 mk2 MIDI controller to execute Undo (Cmd-Z) and Redo (Shift-Cmd-Z) in Ableton Live with the controller's 'NUDGE -' and 'NUDGE +' buttons, respectively, instead of nudging the tempo.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MidiPipe: http://www.subtlesoft.square7.net/MidiPipe.html | |
# | |
# The APC 40 out-of-the-box is great for performing, but less useful for producing because it lacks | |
# frequently used functionality such as Undo/Redo (doh, made a mistake) or deleting clips, for which | |
# you are forced to go back to mouse and keyboard. | |
# | |
# This example AppleScript shows how to use MidiPipe to re-configure the AKAI APC 40 mk2 MIDI controller | |
# to execute Undo (Cmd-Z) and Redo (Shift-Cmd-Z) in Ableton Live with the controller's 'NUDGE -' and 'NUDGE +' | |
# buttons, respectively, instead of nudging the tempo. | |
# | |
# The full MidiPipe setup uses: | |
# 1. MIDI In [input is the APC 40, with 'hijack' enabled] | |
# 2. AppleScript Trigger [this script] | |
# 3. Key Mapper [Key In: 'E 8 (100)', Key Out: filter out; prevents the 'NUDGE-' key | |
# to run its original function of nudging the tempo] | |
# 4. Key Mapper [Key In: 'F 8 (101)', Key Out: filter out; prevents the 'NUDGE+' key | |
# to run its original function of nudging the tempo] | |
# 5. MIDI Out [output is MidiPipe Output 1, with 'Use Note Off Velocity' and 'Pass Through' enabled] | |
# | |
# The Ableton setup under Ableton > Preferences > Link/MIDI: | |
# - Control Surface: APC40 MkII / Input: MidiPipe Output 1 / Output: APC40 mkII | |
# - MIDI Ports ([Track] [Sync] [Remote]) | |
# - Input: APC40_MkII Input (MidiPipe Output 1): [On] [On] [On] | |
# - Output: APC40_MkII Output (APC40 mkII): [On] [Off] [Off] | |
property appName : "Ableton Live 10 Suite" | |
property noteOnStatus : 144 | |
property minVelocity : 1 | |
# AKAI APC 40 mk2 MIDI setup | |
property nudgeMinus : 100 | |
property nudgePlus : 101 | |
on runme(message) | |
# MIDI Table - http://fmslogo.sourceforge.net/manual/midi-table.html | |
# MIDI Number to Note: https://newt.phys.unsw.edu.au/jw/notes.html | |
# | |
# Note On: | |
# (item 1 of message) = Status Byte [144 + Channel (0-15)], e.g. 146 = Note On for Channel 3 | |
# (item 2 of message) = Data Byte 1 [0-127 Pitch] | |
# (item 3 of message) = Data Byte 2 [0-127 Velocity] | |
# | |
# Tip: Use the 'AList' component in MidiPipe to inspect incoming MIDI messages | |
# (think: println debugging) | |
if ((item 1 of message = noteOnStatus) and ¬ | |
(item 2 of message = nudgeMinus) and ¬ | |
(item 3 of message ≥ minVelocity)) then | |
# https://stackoverflow.com/questions/3690167 | |
tell application appName to activate | |
tell application "System Events" | |
keystroke "z" using command down | |
end tell | |
end if | |
if ((item 1 of message = noteOnStatus) and ¬ | |
(item 2 of message = nudgePlus) and ¬ | |
(item 3 of message ≥ minVelocity)) then | |
tell application appName to activate | |
tell application "System Events" | |
keystroke "z" using {shift down, command down} | |
end tell | |
end if | |
end runme |
Author
miguno
commented
Oct 30, 2019
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment