]> Shamusworld >> Repos - ardour-manual/blob - _manual/22_using-control-surfaces/03_midi-binding-maps.html
copy-editing chapter 22
[ardour-manual] / _manual / 22_using-control-surfaces / 03_midi-binding-maps.html
1 ---
2 layout: default
3 title: MIDI Binding Maps
4 ---                        
5
6 <p>
7   Ardour 2.X supported 
8   <a href="/using-control-surfaces/midi-learn"><dfn>MIDI learning</dfn></a> 
9   for more or less any control. This was a nice feature that quite a few other
10   DAWs are providing by now, but it didn't allow Ardour to work "out of the
11   box" with sensible defaults for existing commercial MIDI
12   controllers. In Ardour 3 and later versions, we have augmented the
13   MIDI learn feature with the ability to load a <dfn>MIDI binding map</dfn> 
14   for a given controller, which can set up an arbitrary number of physical
15   controls with anything inside Ardour that can be controlled. 
16 </p>
17 <p>
18   At this time, these binding maps need to be created with a text editor.
19   Currently, we have presets for:
20 </p>
21 <ul>
22   <li>Behringer BCF 2000</li>
23   <li>Korg_nanoKONTROL</li>
24   <li>M-Audio Oxygen 8 v2</li>
25   <li>Roland SI-24</li>
26   <li>Behringer DDX3216</li>
27   <li>M-Audio Axiom 25</li>
28 </ul>
29 <p>
30   MIDI binding maps are accessible by double-clicking <kbd class="menu">Edit
31   &gt; Preferences &gt; Control Surfaces &gt; Generic MIDI</kbd>. Ardour will 
32   retain your selection after you choose one.
33 </p>
34
35 <h2>Creating new MIDI maps</h2>
36 <h3>The Basic Concept</h3>
37 <p>
38   Since the beginning of time (well, sometime early in the 2.X series), 
39   Ardour has had the concept of identifying each track and bus with a 
40   <dfn>remote control ID</dfn>. This ID uniquely identifies a track or bus 
41   so that when messages arrive from elsewhere via MIDI or OSC , we can determine 
42    which track or bus they are intended to control. Ardour has a 
43    <a
44   href="/working-with-tracks/controlling-track-ordering/track-ordering-and-remote-control-ids/">number 
45    of ways of assigning remote control IDs</a>, but they don't really matter 
46    very much when creating MIDI binding maps, so we won't discuss that here. 
47    You just need to know that there is a "first track" and its remote control 
48    ID is 1, and so on.
49 </p>
50 <h3>Getting Started</h3>
51 <p>
52   MIDI bindings are stored in files with the suffix ".map" attached to their 
53   name. The minimal content looks like this:
54 </p>
55 <pre>
56 &lt;?xml version="1.0" encoding="UTF-8"?&gt;
57 &lt;ArdourMIDIBindings version="1.0.0" name="The name of this set of
58 bindings"&gt;
59 &lt;/ArdourMIDIBindings&gt;
60 </pre>
61 <p>
62   So, to start, create a file with that as the initial contents.
63 </p>
64 <p>
65   On OS X, Ardour loads midi maps from its binary-bundle folder in 
66   <code>Ardour-&lt;version&gt;/midi_maps/</code> and checks 
67   various other locations as well (defined by the ARDOUR_MIDIMAPS_PATH 
68   environment variable). On GNU/Linux the easiest is to save the file to 
69   <code>~/.config/ardour3/midi_maps/</code>.
70 </p>
71
72 <h3>Finding out what your MIDI control surface sends</h3>
73 <p>
74   This is the most complex part of the job, but its still not very hard. 
75   You need to connect the control surface to an application that will show 
76   you the information that the device sends each time you modify a knob, 
77   slider, button etc. There are a variety of such applications (notably 
78   <code>gmidimon</code> and <code>kmidimon</code>, but you can actually use 
79   Ardour for this if you want. Start Ardour in a terminal window, connect 
80   MIDI ports up, and in the Preferences window, enable "Trace Input" on the 
81   relevant MIDI port. A full trace of the MIDI data received will show up in 
82   the terminal window. (Note: in Ardour3, you get a dedicated, custom dialog 
83   for this kind of tracing.)
84 </p>
85 <h3>Types of Bindings</h3>
86 <p>
87   There are two basic kinds of bindings you can make between a MIDI message 
88   and something inside Ardour. The first is a binding to a specific parameter 
89   of a track or bus. The second is a binding to a function that will change 
90   Ardour's state in some way.
91 </p>
92 <h4>Binding to Track/Bus controls</h4>
93 <p>
94   A track/bus binding has one of two basic structures
95 </p>
96 <code>
97   &lt;Binding <em>msg specification</em>  uri="<em>... control address ...</em>"/&gt;
98   &lt;Binding <em>msg specification</em>  function="<em>... function name ...</em>"/&gt;
99 </code>
100
101 <h4>Message specifications</h4>
102 <p>
103   You can create a binding for either 3 types of channel messages, or for a
104   system exclusive ("sysex") message.  A channel message specification looks 
105   like this:
106 </p>
107 <code>
108    &lt;Binding channel="1" ctl="13" ....
109 </code>
110 <p>
111   This defines a binding for a MIDI Continuous Controller message involving 
112   controller 13, arriving on channel 1. There are 16 MIDI channels, numbered 
113   1 to 16. Where the example above says <code>ctl</code>, you can alternatively 
114   use <code>note</code> (to create binding for a Note On message) or 
115   <code>pgm</code>  (to create a binding for a Program Change message).
116 </p>
117 <p>
118   You can also bind sysex messages:
119 </p>
120 <code>
121   &lt;Binding sysex="f0 0 0 e 9 0 5b f7" ....
122   &lt;Binding sysex="f0 7f 0 6 7 f7" ....
123 </code>
124 <p>
125   The string after the <code>sysex=</code> part is the sequence of MIDI bytes, 
126   as hexadecimal values, that make up the sysex message.
127 </p>
128 <p>
129   Finally, you can bind a totally arbitrary MIDI message:</p>
130 <code>
131   &lt;Binding msg="f0 0 0 e 9 0 5b f7" ....
132   &lt;Binding msg="80 60 40" ....
133 </code>
134 <p>
135   The string after the <code>msg=</code> part is the sequence of MIDI bytes, as 
136   hexadecimal values, that make up the message you want to bind. Using this is 
137   slightly less efficient than the other variants shown above, but is useful for 
138   some oddly designed control devices.
139 </p>
140
141 <h4>Control address</h4>
142 <p>
143   A <dfn>control address</dfn> defines what the binding will actually control. 
144   There are quite a few different things that can be specified here:
145 </p>
146 <dl class="wide-table">
147 <dt>/route/gain</dt>
148 <dd>the gain control ("fader") for the track/bus</dd>
149 <dt>/route/solo</dt>
150 <dd>a toggleable control for solo (and listen) of the track/bus</dd>
151 <dt>/route/mute</dt>
152 <dd>a toggleable control to mute/unmute the track/bus</dd>
153 <dt>/route/recenable</dt>
154 <dd>a toggleable control to record-enable the track</dd>
155 <dt>/route/panwidth</dt>
156 <dd>interpreted by the track/bus panner, should control image "width"</dd>
157 <dt>/route/pandirection</dt>
158 <dd>interpreted by the track/bus panner, should control image "direction"</dd>
159 <dt>/route/plugin/parameter</dt>
160 <dd>the Mth parameter of the Nth plugin of a track/bus
161 </dd>
162 <dt>/route/send/gain</dt>
163 <dd>the gain control ("fader") of the Nth send of a track/bus</dd>
164 </dl>
165 <p>Each of the specifications needs an address, which takes various forms too. For track-level controls (solo/gain/mute/recenable), the address is one the following:</p>
166 <dl class="wide-table">
167 <dt>a number, eg. "1"
168 </dt>
169 <dd>identifies a track or bus by its remote control ID
170 </dd>
171 <dt>B, followed by a number
172 </dt>
173 <dd>identifies a track or bus by its remote control ID within the current bank (see below for more on banks)
174 </dd>
175 <dt>one or more words
176 </dt>
177 <dd>identifies a track or bus by its name
178 </dd>
179 </dl>
180 <p>
181   For send/insert/plugin controls, the address consists of a track/bus 
182   address (as just described) followed by a number identifying the plugin/send 
183   (starting from 1). For plugin parameters, there is an additional third 
184   component: a number identifying the plugin parameter number (starting from
185   1).
186 </p>
187 <p>
188   One additional feature: for solo and mute bindings, you can also add 
189   <code>momentary="yes"</code> after the control address. This is useful 
190   primarily for NoteOn bindings &mdash; when Ardour gets the NoteOn it 
191   will solo or mute the targetted track or bus, but then when a NoteOff 
192   arrives, it will un-solo or un-mute it.
193 </p>
194
195 <h4>Bindings to Ardour "functions"</h4>
196 <p>
197   Rather than binding to a specific track/bus control, it may be useful to 
198   have a MIDI controller able to alter some part of Ardour's state. A 
199   binding definition that does this looks like this:
200 </p>
201 <code>
202   &lt;Binding channel="1" note="13" function="transport-roll"/&gt;
203 </code>
204 <p>
205   In this case, a NoteOn message for note number 13 (on channel 1) will 
206   start the transport rolling. The following function names are available:
207 </p>
208 <dl class="narrower-table">
209 <dt>
210 <code>transport-stop</code>
211 </dt>
212 <dd>stop the transport
213 </dd>
214 <dt>
215 <code>transport-roll</code>
216 </dt>
217 <dd>start the transport "rolling"
218 </dd>
219 <dt>
220 <code>transport-zero</code>
221 </dt>
222 <dd>move the playhead to the zero position
223 </dd>
224 <dt>
225 <code>transport-start</code>
226 </dt>
227 <dd>move the playhead to the start marker
228 </dd>
229 <dt>
230 <code>transport-end</code>
231 </dt>
232 <dd>move the playhead to the end marker
233 </dd>
234 <dt>
235 <code>loop-toggle</code>
236 </dt>
237 <dd>turn on loop playback
238 </dd>
239 <dt>
240 <code>rec-enable</code>
241 </dt>
242 <dd>enable the global record button
243 </dd>
244 <dt>
245 <code>rec-disable</code>
246 </dt>
247 <dd>disable the global record button
248 </dd>
249 <dt>
250 <code>next-bank</code>
251 </dt>
252 <dd>Move track/bus mapping to the next bank (see Banks below)
253 </dd>
254 <dt>
255 <code>prev-bank</code>
256 </dt>
257 <dd>Move track/bus mapping to the previous bank (see Banks below)
258 </dd>
259 </dl>
260
261 <h4>Binding to Ardour "actions"</h4>
262 <p>
263   You can also bind a sysex or arbitrary message to any of the items
264   that occur in Ardour's main menu (and its submenus).  The best place 
265   to look for the (long) list of how to address each item is in your 
266   keybindings file, which will contain lines that look like this:
267 </p>
268 <code>
269 (gtk_accel_path "&lt;Actions&gt;/Editor/temporal-zoom-in" "equal")
270 </code>
271 <p>
272   To create a binding between an arbitrary MIDI message (we'll use a 
273   note-off on channel 1 of MIDI note 60 (hex) with release velocity 
274   40 (hex)), the binding file would contain:
275 </p>
276 <code>
277    &lt;Binding msg="80 60 40" action="Editor/temporal-zoom-in"/&gt;
278 </code>
279 <p>
280   The general rule, when taken an item from the keybindings file and 
281   using it in a MIDI binding is to simply strip the 
282   <code>&lt;Action&gt;</code> prefix of the second field in the 
283   keybinding definition.
284 </p>
285
286 <h3>Banks and Banking</h3>
287 <p>
288   Because many modern control surfaces offer per-track/bus controls 
289   for far fewer tracks &amp; busses than many users want to control, 
290   Ardour offers the relatively common place concept of <dfn>banks</dfn>. Banks 
291   allow you to control any number of tracks and/or busses easily, 
292   regardless of how many faders/knobs etc. your control surface has.<br /> 
293   To use banking, the control addresses must be specified using the 
294   <dfn>bank relative</dfn> format mentioned above ("B1" to identify 
295   the first track of a bank of tracks, rather than "1" to identify 
296   the first track).
297 </p>
298 <p>
299   One very important extra piece of information is required to use 
300   banking: an extra line near the start of the list of bindings 
301   that specifies how many tracks/busses to use per bank. If the 
302   device has 8 faders, then 8 would be a sensible value to use for 
303   this. The line looks like this:</p>
304 <code>
305    &lt;DeviceInfo bank-size="8"/&gt;
306 </code>
307 <p>
308   In addition, you probably want to ensure that you bind something
309   on the control surface to the <code>next-bank</code> and 
310   <code>prev-bank</code> functions, otherwise you and other users 
311   will have to use the mouse and the GUI to change banks, which 
312   rather defeats the purpose of the bindings.
313 </p>
314 <h2>A Complete (though muddled) Example</h2>
315 <pre>
316 &lt;?xml version="1.0" encoding="UTF-8"?&gt;
317 &lt;ArdourMIDIBindings version="1.0.0" name="pc1600x transport controls"&gt;
318   &lt;DeviceInfo bank-size="16"/&gt;
319   &lt;Binding channel="1" ctl="1"   uri="/route/gain B1"/&gt;
320   &lt;Binding channel="1" ctl="2"   uri="/route/gain B2"/&gt;
321   &lt;Binding channel="1" ctl="3"   uri="/route/send/gain B1 1"/&gt;
322   &lt;Binding channel="1" ctl="4"   uri="/route/plugin/parameter B1 1 1"/&gt;
323   &lt;Binding channel="1" ctl="6"   uri="/bus/gain master"/&gt;
324
325   &lt;Binding channel="1" note="1"  uri="/route/solo B1"/&gt;
326   &lt;Binding channel="1" note="2"  uri="/route/solo B2" momentary="yes"/&gt;
327
328   &lt;Binding channel="1" note="15"  uri="/route/mute B1" momentary="yes"/&gt;
329   &lt;Binding channel="1" note="16"  uri="/route/mute B2" momentary="yes"/&gt;
330
331   &lt;Binding sysex="f0 0 0 e 9 0 5b f7" function="transport-start"/&gt;
332   &lt;Binding sysex="f0 7f 0 6 7 f7" function="rec-disable"/&gt;
333   &lt;Binding sysex="f0 7f 0 6 6 f7" function="rec-enable"/&gt;
334   &lt;Binding sysex="f0 0 0 e 9 0 53 0 0 f7" function="loop-toggle"/&gt;
335
336   &lt;Binding channel="1" note="13" function="transport-roll"/&gt;
337   &lt;Binding channel="1" note="14" function="transport-stop"/&gt;
338   &lt;Binding channel="1" note="12" function="transport-start"/&gt;
339   &lt;Binding channel="1" note="11" function="transport-zero"/&gt;
340   &lt;Binding channel="1" note="10" function="transport-end"/&gt;
341 &lt;/ArdourMIDIBindings&gt;
342 </pre>
343 <p>
344   Please note that channel, controller and note numbers are specified as 
345   decimal numbers in the ranges 1-16, 0-127 and 0-127 respectively 
346   (the channel range may change at some point).
347 </p>
348