Reaper, Ableton Live and RME TotalMix mappings for Logitech G502 Hero and AHK
This repo is mostly for my own purposes, to remind myself what I did and how to replicate it in future if necessary. If anyone else finds it useful, great.
I must've tried and/or owned almost every type and form factor of studio control surface in my life, from Mackie MCU Pro to Faderport motorised things to Korg nanoKontrol Studio to Novation X-Station and Remote, and everything in between. I spend ages getting them set up and then realise I've created a fragile workflow that doesn't adapt well to the variety of software I use and work I do. Invariably I end up with a dust-gathering thing taking up valuable desk space in the studio, occasionally flashing lights at me, before it inevitably goes on eBay.
But I've always loved working with a mouse. I came up on the Amiga, where although trackers involve a lot of keyboard-fu, plenty of the UI is still completely dependent on a 2-button mouse. In modern DAWs I work much more efficiently with a mouse, and stopping to map, remap, or sometimes completely re-plug some USB MIDI surface gives a net reduction in efficiency relative to its supposed benefits in convenience or tactility.
The mouse I've settled on as a model with enough reprogrammable buttons, a decent feel in the hand and enough mass-market success that I shouldn't struggle to find replacements is the Logitech G502 Hero. One very cool thing about it is its LUA scripting interface - I suppose it's intended for gaming cheats, but I use it to send otherwise unused keyboard scancodes (F16 and F17) when the 'g-shift' button is pressed, allowing me to manage a shift-function state in AHK.
With a rich array of inputs from the G502's 2 main buttons, 4 side buttons, g-shift button, scrollwheel click, scrollwheel-tilt left/right and reprogrammable DPI change button, I can control a vast array of stuff in TotalMix, Reaper and Ableton Live without having to reach for another hardware control or recall obtuse keyboard shortcuts.
In TotalMix, globally throughout Windows, I use the DPI button to toggle the mute state of my main studio speaker output on my Fireface UCX II. Then when the g-shift button is held down, the scrollwheel controls the master output volume. That's it: just two things, but they took me ages to work out (hence my documenting them here). They rely not only on AHK but also a great little AHK-OSC bridge that lets me construct OSC messages that TotalMix can understand.
The Ableton Live API allows a lot of MIDI mappings to DAW (rather than just instrument/effect) features, but it's a bit limited compared with Reaper, where pretty much anything is scriptable and configurable if you have the will and the time. For the most part, my Live and Reaper controls replicate the functionality of my last big effort to find the perfect control surface, my Korg nanoKontrol Studio Remote script
My AHK mappings for Live go about as far as I think I can go with them, minus various features that I ended up needing less than I'd expected after using the Remote script for a while. Reaper, however, is an ongoing work in progress: I absolutely love how much is exposed to the scripting API and I wish I'd grasped years ago how fundamental it is to come to terms with the fact that, no, Reaper is not perfect out of the box - and nor is it meant to be. DAWs preferences are far too personal for that to be realistic; if you really want the perfect workflow, you should expect to have to create it. And Reaper lets you do that! Or...arguably...requires you to do that.
As default, except for the following (where 'low' means nearest to you in each button pair, and 'high' means furthest away):
- Upper-left 'high' button: Macro 'CtrlAltShiftHome'
-
- as above with G-Shift: Macro 'CtrlAltShiftPageUp'
- Upper-left 'low' button: Macro 'CtrlAltShiftEnd'
-
- as above G-Shift: Macro 'CtrlAltShiftPageDown'
- Mousewheel Tilt Left: PGUP
- Mousewheel Tilt Right: PGDOWN
- DPI button: Macro 'RAltRCtrlRShiftF12'
- Side 'high' button: Browser Forward
- Side 'low' button: Browser Back
- Paste the contents of this script into the Scripting section of your Profile under 'Manage Profiles' (yeah, it's weird and annoying)
TotalMix is controlled by intercepting two mouse events with AutoHotkey and then sending OSC messages. DPI button (RAlt+RCtrl+RShift+F12) sends a float message of 1.0 to the OSC address '/3/muteGroups/4/1', which toggles main speaker mute. Master volume is controlled with the mousewheel when g-shift is held, by reading the current master volume and incrementing or decrementing. We check in AutoHotkey if g-shift is down, then add or subtract 0.005 to our local cached volume value, then make an OSC call to '/1/mastervolume'.
This is contingent on some LUA scripting in the Logitech mouse profile which listens for the g-shift button being pressed or released, and triggers key events for the scancodes 0x67 (F16) or 0x68 (F17) accordingly. The AHK script sets its local gShiftState var based on receipt of F16 or F17 revents. Sounds flimsy, but it's robust!
You'll need OSC2AHK to control TotalMix: for more details see https://github.com/echolevel/AHK-TotalMix-Remote
Note: it'll stop working if you're using a VPN and you'll go mad wondering why until you remember that OSC is a network protocol, and the VPN messes it up even though it's sending to localhost. I rarely use a VPN so I haven't bothered to find a workaround.
I use AHK to intercept most of the above G502 input events and map them to certain functions in Live. These mappings only work when the Live window is active. I check like this:
#IfWinActive ahk_class Ableton Live Window Class
I have two local variables in my AHK script called jogShiftState and zoomShiftState which I use as booleans. Jog is toggled by XButton1 (browser back button) and zoom is toggled by XButton2 (browser forward button).
When jogShiftState > 0, the mousewheel acts as a transport jog/scrub dial by using sendmidi to send messages to my loopMIDIPort on CCs 85 and 83. My loopMIDIPort (renamed to remove the space) lets me use MIDI-OX to attach multiple MIDI devices to a single Ableton-facing MIDI input, and it makes this whole setup a bit more robust.
When zoomShiftState > 0, the mousewheel acts as an arrangement view zoom-to-mouse-position by adding a Ctrl Down event to the wheel event. It's equivalent to holding Ctrl while mousewheeling in Ableton, which is the standard way of doing arrangement view zoom.
Also while zoomShiftState > 0, middle-clicking the mouse toggles an arrangement marker at the current playhead position.
Other functions include:
- Middle-click and drag moves around arrangement view with the hand tool (equivalent to holding Ctrl and Alt)
- Upper-left 'high' button sends Ctrl+Space, which plays selection (or plays from the start of the currently focused clip)
- Upper-left 'low' button sends Space, to stop playback
- Upper-left 'high' button with g-shift sets Loop to selection
- Upper-left 'low' button with g-shift selects the current Loop
Summary: I love a jog wheel, but I hate almost every existing hardware design that features a MIDI jog wheel. I love my nanoKontrol Studio, but the jog wheel is on the wrong side for my desk layout and I so rarely use those 8 fader strips that it's a huge waste of desk space. While I've written a pretty deep Ableton Live Remote script for the nanoKontrol Studio in python, the truth is that I rarely need most of that functionality. Really I just want some critical things available at all times under my mouse hand.
I'm still refining my Reaper workflow and it's already way more complex than what's below, but at least this is a basic starting point for anyone who wants to get deeper mouse control in Reaper than the default. Like most well-written apps, Reaper refuses to assume that you have a mouse with more than 3 buttons (because most people don't, and because buttons beyond Left, Middle and Right are usually implemented in a completely non-standard way by different manufacturers).
zoomShiftReaper with mousewheel works the same way as in Ableton Live.
By default, Reaper zooms to the playhead; in Options, you can instruct horizontal zoom to track mouse position. Reaper doesn't show you what Action shortcuts you customised; I have Ctrl+Mousewheel for Zoom Horizontally though this may not be default. Add it if not.
jogShiftReaper and mousewheel works the same way as in Ableton Live, though WheelUp sends CC 82 with a value of 1, while WheelDown sends CC 82 with a value of 65.
Upper-left 'high' button sends Ctrl+Alt+Shift+End, which in Reaper is a custom action for 'Transport: Play/stop (move edit cursor on stop). 'End' should be deleted from Reaper's action for 'Go to end of project'
Upper-left 'low' button sends Ctrl+Alt+Shift+Home, which in Reaper is a custom action for 'Xenakios/SWS: Play selected items once'. 'Home' should be deleted from Reaper's action for 'Go to start of project'
Upper-left 'high' button with g-shift sends Ctrl+Alt+Shift+PGUP, which in Reaper is mapped to 'Loop points: set loop points to items'.
Upper-left 'low' button with g-shift sends Ctrl+Alt+Shift+PGDOWN, which in Reaper is mapped to 'Time selection: Move time selection to loop points'
Upper-left 'high' button with zoomShiftReaper true plus middle mouse button sends the letter 'm', which creates a marker in Reaper.
Hand-icon scroll dragging is assigned from middle-click + drag in Reaper Preferences -> Mouse Modifiers. I have Shift as Hand scroll, Ctrl as Scrub Audio and Shift+Ctrl as Jog Audio. In AHK, I send Shift along with the MButton Down to use middle button as hand scroll (remapping purely in Reaper doesn't work - maybe bugged).
Coming soon...