Skip to content

Instantly share code, notes, and snippets.

@rafrombrc
Last active November 24, 2022 05:37
Show Gist options
  • Save rafrombrc/b36d60a109a14a990954aa9f0289c526 to your computer and use it in GitHub Desktop.
Save rafrombrc/b36d60a109a14a990954aa9f0289c526 to your computer and use it in GitHub Desktop.
Script using mididings to improve the functionality of behringer x-touch with Ardour DAW
"""
Very simple mididings script to enhance the functionality of a behringer
x-touch mixing control surface when used with a DAW via the mackie control
protocol (MCP). Written for use with Ardour and an x-touch running firmware
v1.21. Might work with other DAWs and firmware versions, might steal your
wallet and drink your booze. Idea stolen from a similar effort done with MaxMSP
/ PureData for use with Cubase:
https://www.pgaudio.com.br/site/improve-mackie-controller-xtouch-integration-daw
Meant to be run as a proxy on the MCP input channel. MIDI out from the x-touch
should be routed into mididings input, and mididings output connected to the
DAW's MCP input.
"""
import time
from mididings import *
from mididings.engine import output_event
from mididings.event import NoteOnEvent, NoteOffEvent
config(
backend='jack',
)
def note_events(ev, note):
"""
Generate a note on/off pair for the provided event's port and channel.
"""
noteOn = NoteOnEvent(ev.port, ev.channel, note, 127)
noteOff = NoteOffEvent(ev.port, ev.channel, note, 64)
return [noteOn, noteOff]
def delay(ev, note, ms=40):
"""
Pause for specified number of milliseconds before emitting a note on/off
pair.
"""
time.sleep(ms/1000)
noteOn, noteOff = note_events(ev, note)
output_event(noteOn)
output_event(noteOff)
return
run(
Filter(NOTEON) % KeySplit({
# send: The `send` button allows setting output levels for the selected
# track's sends, using the pan knobs by default. this auto-clicks the
# `flip` button to switch to the fader controls. I thought I'd have to
# awkwardly and wrongly track the `flip` button state to decide whether
# it needed to be hit, but it seems like hitting `send` toggles the
# `flip` button off so this always works as desired.
41: +Call(delay, 50),
# fader bank left: Auto-clicks `select` button on the leftmost track
# after `fader bank left` is hit. This causes the DAW UI to show the
# same tracks that are showing on the x-touch.
46: +Call(delay, 24),
# fader bank right: Same as above but the other direction. This gets
# janky at the end of the track list; unless the track count is a
# multiple of 8 the rightmost track on the x-touch won't correspond to
# a track in the session, so the `select` button will have no
# effect. It'd be great to know this and instead select the last
# existing track, but no way to tell at the moment.
47: +Call(delay, 31),
# channel left / channel right: These next two are the same as the
# previous two but for single channel left and right instead of fader
# bank left and right.
48: +Call(delay, 24),
49: +Call(delay, 31),
None: Pass(),
})
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment