]> Shamusworld >> Repos - ardour-manual/blob - include/generic-midi-binding-maps.html
try to explain the connection and difference between function and action bindings...
[ardour-manual] / include / generic-midi-binding-maps.html
1
2 <p>
3   Ardour 2.X supported
4   <a href="@@generic-midi-learn"><dfn>MIDI learning</dfn></a>
5   for more or less any control. This was a nice feature that quite a few other
6   DAWs are providing by now, but it didn't allow Ardour to work "out of the
7   box" with sensible defaults for existing commercial MIDI
8   controllers. In Ardour 3 and later versions, we have augmented the
9   MIDI learn feature with the ability to load a <dfn>MIDI binding map</dfn>
10   for a given controller, which can set up an arbitrary number of physical
11   controls with anything inside Ardour that can be controlled.
12 </p>
13 <p>
14   Currently (August 2016), we have presets for the following devices/modes:
15 </p>
16 <ul>
17   <li>AKAI MidiMix (2 layouts)</li>
18   <li>AKAI MPD-32</li>
19   <li>AKAI MPK61</li>
20   <li>AKAI MPKmini</li>
21   <li>Alesis QX25</li>
22   <li>Arturia KeyLab49</li>
23   <li>Behringer BCF2000</li>
24   <li>Behringer BCF2000 (Mackie Emulation mode; better to use
25     Ardour's actual Mackie Control Protocol support)</li>
26   <li>Behringer DDX3216</li>
27   <li>Korg nanoKONTROL (3 layouts)</li>
28   <li>Korg nanoKONTROL 2 (2 layouts)</li>
29   <li>Korg Taktile</li>
30   <li>M-Audio Axiom 25</li>
31   <li>M-Audio Axiom 61</li>
32   <li>M-Audio Axiom Air 25</li>
33   <li>M-Audio Axiom Air Mini 32</li>
34   <li>M-Audio Oxygen 8v2</li>
35   <li>M-Audio Oxygen 25</li>
36   <li>M-Audio Oxygen 49</li>
37   <li>M-Audio Oxygen 61v3 (2 layouts)</li>
38   <li>Novation Impulse 49</li>
39   <li>Novation Impulse 61</li>
40   <li>Novation LaunchControl XL</li>
41   <li>Novation LaunchKey 25</li>
42   <li>Novation LaunchKey 49</li>
43   <li>Roland SI-24</li>
44   <li>Roland V Studio 20</li>
45   <li>WiiMote</li>
46   <li>Xboard 61</li>
47   <li>Yamaha KX25</li>
48 </ul>
49   At this time, new binding maps need to be created with a text editor.
50 <p>
51   MIDI binding maps are accessible by double-clicking <kbd class="menu">Edit
52   &gt; Preferences &gt; Control Surfaces &gt; Generic MIDI</kbd>. Ardour will
53   retain your selection after you choose one.
54 </p>
55
56 <h2>Creating new MIDI maps</h2>
57 <h3>The Basic Concept</h3>
58 <p>
59   Since the beginning of time (well, sometime early in the 2.X series),
60   Ardour has had the concept of identifying each track and bus with a
61   <dfn>remote control ID</dfn>. This ID uniquely identifies a track or bus
62   so that when messages arrive from elsewhere via MIDI or OSC , we can determine
63    which track or bus they are intended to control. See
64    <a href="@@controlling-track-ordering">
65    remote control IDs</a> for more information.
66    You just need to know that there is a "first track" and its remote control
67    ID is 1, and so on.
68 </p>
69 <h3>Getting Started</h3>
70 <p>
71   MIDI bindings are stored in files with the suffix ".map" attached to their
72   name. The minimal content looks like this:
73 </p>
74 <pre>
75 &lt;?xml version="1.0" encoding="UTF-8"?&gt;
76 &lt;ArdourMIDIBindings version="1.0.0" name="The name of this set of
77 bindings"&gt;
78 &lt;/ArdourMIDIBindings&gt;
79 </pre>
80 <p>
81   So, to start, create a file with that as the initial contents.
82 </p>
83 <p>
84         The file should be located in the midi_maps sub directory located in
85         the <a href="@@files-and-directories-ardour-knows-about">Ardour configuration directory</a>
86 </p>
87
88 <h3>Finding out what your MIDI control surface sends</h3>
89 <p>
90   This is the most complex part of the job, but its still not very hard.
91   You need to connect the control surface to an application that will show
92   you the information that the device sends each time you modify a knob,
93   slider, button etc. There are a variety of such applications (notably
94   <code>gmidimon</code> and <code>kmidimon</code>, but you can actually use
95   Ardour for this if you want. Start Ardour in a terminal window, connect
96   MIDI ports up, and in the Preferences window, enable "Trace Input" on the
97   relevant MIDI port. A full trace of the MIDI data received will show up in
98   the terminal window. (Note: in Ardour3, you get a dedicated, custom dialog
99   for this kind of tracing.)
100 </p>
101 <h3>Types of Bindings</h3>
102 <p>
103   There are two basic kinds of bindings you can make between a MIDI message
104   and something inside Ardour. The first is a binding to a specific parameter
105   of a track or bus. The second is a binding to something that will change
106   Ardour's state in some way (the "something" could either be called a
107   function or an action, see below).
108 </p>
109 <h4>Binding to Track/Bus controls</h4>
110 <p>
111   A track/bus binding has one of three basic structures
112 </p>
113 <code>
114   &lt;Binding <em>msg specification</em>  uri="<em>&hellip; control address &hellip;</em>"/&gt;</br>
115   &lt;Binding <em>msg specification</em>  function="<em>&hellip; function name &hellip;</em>"/&gt;
116   &lt;Binding <em>msg specification</em>  action="<em>&hellip; action name &hellip;</em>"/&gt;
117 </code>
118
119 <h4>Message specifications</h4>
120 <p>
121   You can create a binding for either 3 types of channel messages, or for a
122   system exclusive ("sysex") message.  A channel message specification looks
123   like this:
124 </p>
125 <code>
126    &lt;Binding channel="1" ctl="13" &hellip;
127 </code>
128 <p>
129   This defines a binding for a MIDI Continuous Controller message involving
130   controller 13, arriving on channel 1. There are 16 MIDI channels, numbered
131   1 to 16. Where the example above says <code>ctl</code>, you can alternatively
132   use <code>note</code> (to create binding for a Note On message) or
133   <code>pgm</code>  (to create a binding for a Program Change message).
134 </p>
135 <p>
136         Continous Controlers (CCs) have coninued to evolve for different controlers.
137         The use of Encoders, RPN, NRPN, and controller buttons that give a 0 value
138         when released instead of toggling are now supported. These all have their
139         own type. The whole list of CC types are:
140 </p>
141 <p>
142         <ul>
143                 <li>ctl - sets a CC to the value sent (works the same as
144                 <code>note</code> with the <code>momentary</code> parameter set)</li>
145                 <li>ctl-toggle - for CC controls that send a 127 for button press
146                 and 0 for button release. The release is ignored and the value is
147                 toggled with each press. (works the same as <code>note</code>)</li>
148                 <li>ctl-dial - passes the CC value to the controlled object</li>
149                 <li>rpn - The CC value may be a 14 bit value</li>
150                 <li>nrpn - The CC number and the value may both be 14 bit values</li>
151                 <li>rpn-delta - The value is expected to be a signed 14bit value
152                 that is added to the current value. For use with encoders</li>
153                 <li>nrpn-delta - The value is expected to be a signed 14bit value
154                 that is added to the current value. For use with encoders</li>
155                 <li>enc-r, enc-l, enc-2 and enc-b - For 7 bit encoders. See below</li>
156         </ul>
157 </p>
158 <p>
159   As of Ardour 4.2, <code>enc-r</code>, <code>enc-l</code>, <code>enc-2</code> and
160   <code>enc-b</code> may be used for surfaces that have encoders that send
161   offsets rather than values. These accept Continuous Controller messages
162   but treat them as offsets. These are good for banked controls as they are
163   always at the right spot to start adjusting. (
164    <a href="@@generic-midi-and-encoders">
165    Learn more about working with encoders
166    </a>)
167 </p>
168 <p>
169         <ul>
170                 <li><code>&lt;Binding channel="1" enc-r="13" &hellip;</code></li>
171                 <li><code>&lt;Binding channel="1" enc-l="13" &hellip;</code></li>
172                 <li><code>&lt;Binding channel="1" enc-2="13" &hellip;</code></li>
173                 <li><code>&lt;Binding channel="1" enc-b="13" &hellip;</code></li>
174         </ul>
175         The <code>enc-*</code> value is the CC number used by the encoder.
176         Encoders only work with CC messages.
177 </p>
178 <p class="note">
179         Ardour 5.12 has a bug with the encoder detection where the first
180         encoder message resets the control to 0. Setting "Enable Feedback"
181         on allows encoders to work as expected.
182 </p>
183 <p>
184   You can also bind sysex messages:
185 </p>
186 <code>
187   &lt;Binding sysex="f0 0 0 e 9 0 5b f7" &hellip;.</br>
188   &lt;Binding sysex="f0 7f 0 6 7 f7" &hellip;.
189 </code>
190 <p>
191   The string after the <code>sysex=</code> part is the sequence of MIDI bytes,
192   as hexadecimal values, that make up the sysex message.
193 </p>
194 <p>
195   Finally, you can bind a totally arbitrary MIDI message:</p>
196 <code>
197   &lt;Binding msg="f0 0 0 e 9 0 5b f7" &hellip;.</br>
198   &lt;Binding msg="80 60 40" &hellip;.
199 </code>
200 <p>
201   The string after the <code>msg=</code> part is the sequence of MIDI bytes, as
202   hexadecimal values, that make up the message you want to bind. Using this is
203   slightly less efficient than the other variants shown above, but is useful for
204   some oddly designed control devices.
205 </p>
206
207 <p class="note">
208   As of Ardour 4.6 it is possible to use multi-event MIDI strings such as
209   two event CC messages, RPN or NRPN.
210 </p>
211
212 <p class="note">
213   The <code>sysex=</code> and <code>msg=</code> bindings will only work with
214   <code>function=</code> or <code>action=</code> control addresses. They
215   will <em>not</em> work with the <code>uri=</code> control addresses.
216   Controls used with <code>uri=</code> require a <em>Value</em> which is
217   only available in a known place with channel mode MIDI events.
218 </p>
219
220 <h4>Control address</h4>
221 <p>
222   A <dfn>control address</dfn> defines what the binding will actually control.
223   There are quite a few different things that can be specified here:
224 </p>
225 <p class="note">
226         Enable Feeback applies to these "Control Addresses" only.
227 </p>
228 <table class="dl">
229 <tr><th>/route/gain</th>
230 <td>the gain control ("fader") for the track/bus</td></tr>
231 <tr><th>/route/trim</th>
232 <td>the trim control for the track/bus (new in 4.1)</td></tr>
233 <tr><th>/route/solo</th>
234 <td>a toggleable control for solo (and listen) of the track/bus</td></tr>
235 <tr><th>/route/mute</th>
236 <td>a toggleable control to mute/unmute the track/bus</td></tr>
237 <tr><th>/route/recenable</th>
238 <td>a toggleable control to record-enable the track</td></tr>
239 <tr><th>/route/panwidth</th>
240 <td>interpreted by the track/bus panner, should control image "width"</td></tr>
241 <tr><th>/route/pandirection</th>
242 <td>interpreted by the track/bus panner, should control image "direction"</td></tr>
243 <tr><th>/route/plugin/parameter</th>
244 <td>the Mth parameter of the Nth plugin of a track/bus
245 </td></tr>
246 <tr><th>/route/send/gain</th>
247 <td>the gain control ("fader") of the Nth send of a track/bus</td></tr>
248 </table>
249 <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>
250 <table class="dl">
251 <tr><th>a number, e.g. "1"
252 </th>
253 <td>identifies a track or bus by its remote control ID
254 </td></tr>
255 <tr><th>B, followed by a number
256 </th>
257 <td>identifies a track or bus by its remote control ID within the current bank (see below for more on banks)
258 </td></tr>
259 <tr><th>S, followed by a number
260 </th>
261 <td>identifies a selected track in order they have been selected, S1 should be the same track as the Editor Mixer
262 </td></tr>
263 <tr><th>one or more words
264 </th>
265 <td>identifies a track or bus by its name
266 </td></tr>
267 </table>
268 <p>
269   For send/insert/plugin controls, the address consists of a track/bus
270   address (as just described) followed by a number identifying the plugin/send
271   (starting from 1). For plugin parameters, there is an additional third
272   component: a number identifying the plugin parameter number (starting from
273   1).
274 </p>
275 <p>
276   One additional feature: for solo and mute bindings, you can also add
277   <code>momentary="yes"</code> after the control address. This is useful
278   primarily for NoteOn bindings&mdash;when Ardour gets the NoteOn it
279   will solo or mute the targetted track or bus, but then when a NoteOff
280   arrives, it will un-solo or un-mute it.
281 </p>
282
283 <h4>Bindings to Ardour "functions"</h4>
284 <p class="note">
285   There is currently no feedback available for functions.
286 </p>
287 <p>
288   Rather than binding to a specific track/bus/plugin control, it may be useful to
289   have a MIDI controller able to alter some part of Ardour's
290   state. Ardour's Generic MIDI support provides a small number of
291   easily-used "functions" to do the most common operations, using a
292   binding that looks like this:
293 </p>
294 <code>
295   &lt;Binding channel="1" note="13" function="transport-roll"/&gt;
296 </code>
297 <p>
298   In this case, a NoteOn message for note number 13 (on channel 1) will
299   start the transport rolling. 
300 </p>
301 <p>
302   Note that a much greater number of operations are possible using
303   actions, described below.
304 </p>
305 <p>
306   The following function names are available:
307 </p>
308 <table class="dl">
309 <tr><th>
310 <code>transport-stop</code>
311 </th>
312 <td>stop the transport
313 </td></tr>
314 <tr><th>
315 <code>transport-roll</code>
316 </th>
317 <td>start the transport "rolling"
318 </td></tr>
319 <tr><th>
320 <code>transport-zero</code>
321 </th>
322 <td>move the playhead to the zero position
323 </td></tr>
324 <tr><th>
325 <code>transport-start</code>
326 </th>
327 <td>move the playhead to the start marker
328 </td></tr>
329 <tr><th>
330 <code>transport-end</code>
331 </th>
332 <td>move the playhead to the end marker
333 </td></tr>
334 <tr><th>
335 <code>loop-toggle</code>
336 </th>
337 <td>turn on loop playback
338 </td></tr>
339 <tr><th>
340 <code>rec-enable</code>
341 </th>
342 <td>enable the global record button
343 </td></tr>
344 <tr><th>
345 <code>rec-disable</code>
346 </th>
347 <td>disable the global record button
348 </td></tr>
349 <tr><th>
350 <code>next-bank</code>
351 </th>
352 <td>Move track/bus mapping to the next bank (see Banks below)
353 </td></tr>
354 <tr><th>
355 <code>prev-bank</code>
356 </th>
357 <td>Move track/bus mapping to the previous bank (see Banks below)
358 </td></tr>
359 </table>
360
361 <h4>Binding to Ardour "actions"</h4>
362 <p class="note">
363   It is not possible to have feedback available for actions because
364   these represent keyboard shortcuts which are input only.
365 </p>
366 <p>
367   You can also bind a sysex or arbitrary message to any of the items
368   that occur in Ardour's main menu (and its submenus). The <a
369   href="@@list-of-menu-actions">
370   list of actions</a> shows all available values of <em>action-name</em>.
371 <p>
372   To create a binding between an arbitrary MIDI message (we'll use a
373   note-off on channel 1 of MIDI note 60 (hex) with release velocity
374   40 (hex)), the binding file would contain:
375 </p>
376 <code>
377    &lt;Binding msg="80 60 40" action="Editor/temporal-zoom-in"/&gt;
378 </code>
379 <p>
380   The general rule, when taken an item from the keybindings file and
381   using it in a MIDI binding is to simply strip the
382   <code>&lt;Action&gt;</code> prefix of the second field in the
383   keybinding definition.
384 </p>
385
386 <h3>Banks and Banking</h3>
387 <p>
388   Because many modern control surfaces offer per-track/bus controls
389   for far fewer tracks &amp; busses than many users want to control,
390   Ardour offers the relatively common place concept of <dfn>banks</dfn>. Banks
391   allow you to control any number of tracks and/or busses easily,
392   regardless of how many faders/knobs etc. your control surface has.<br>
393   To use banking, the control addresses must be specified using the
394   <dfn>bank relative</dfn> format mentioned above ("B1" to identify
395   the first track of a bank of tracks, rather than "1" to identify
396   the first track).
397 </p>
398 <p>
399   One very important extra piece of information is required to use
400   banking: an extra line near the start of the list of bindings
401   that specifies how many tracks/busses to use per bank. If the
402   device has 8 faders, then 8 would be a sensible value to use for
403   this. The line looks like this:</p>
404 <code>
405    &lt;DeviceInfo bank-size="8"/&gt;
406 </code>
407 <p>
408   In addition, you probably want to ensure that you bind something
409   on the control surface to the <code>next-bank</code> and
410   <code>prev-bank</code> functions, otherwise you and other users
411   will have to use the mouse and the GUI to change banks, which
412   rather defeats the purpose of the bindings.
413 </p>
414 <h3>The Selected Strip</h3>
415 <p>
416   Often times one wants to just deal with the strip currently
417   selected by the GUI (or the control surface). In the same way as with
418   banks above the selected strip can be designated with <em>S1</em>.
419 </p>
420 <h2>A Complete (though muddled) Example</h2>
421 <pre>
422 &lt;?xml version="1.0" encoding="UTF-8"?&gt;
423 &lt;ArdourMIDIBindings version="1.0.0" name="pc1600x transport controls"&gt;
424   &lt;DeviceInfo bank-size="16"/&gt;
425   &lt;Binding channel="1" ctl="1"   uri="/route/gain B1"/&gt;
426   &lt;Binding channel="1" ctl="2"   uri="/route/gain B2"/&gt;
427   &lt;Binding channel="1" ctl="3"   uri="/route/send/gain B1 1"/&gt;
428   &lt;Binding channel="1" ctl="4"   uri="/route/plugin/parameter B1 1 1"/&gt;
429   &lt;Binding channel="1" ctl="6"   uri="/bus/gain master"/&gt;
430
431   &lt;Binding channel="1" note="1"  uri="/route/solo B1"/&gt;
432   &lt;Binding channel="1" note="2"  uri="/route/solo B2" momentary="yes"/&gt;
433
434   &lt;Binding channel="1" note="15"  uri="/route/mute B1" momentary="yes"/&gt;
435   &lt;Binding channel="1" note="16"  uri="/route/mute B2" momentary="yes"/&gt;
436
437   &lt;Binding channel="1" enc-r="11"   uri="/route/pandirection B1"/&gt;
438   &lt;Binding channel="1" enc-r="12"   uri="/route/pandirection B2"/&gt;
439
440   &lt;Binding sysex="f0 0 0 e 9 0 5b f7" function="transport-start"/&gt;
441   &lt;Binding sysex="f0 7f 0 6 7 f7" function="rec-disable"/&gt;
442   &lt;Binding sysex="f0 7f 0 6 6 f7" function="rec-enable"/&gt;
443   &lt;Binding sysex="f0 0 0 e 9 0 53 0 0 f7" function="loop-toggle"/&gt;
444
445   &lt;Binding channel="1" note="13" function="transport-roll"/&gt;
446   &lt;Binding channel="1" note="14" function="transport-stop"/&gt;
447   &lt;Binding channel="1" note="12" function="transport-start"/&gt;
448   &lt;Binding channel="1" note="11" function="transport-zero"/&gt;
449   &lt;Binding channel="1" note="10" function="transport-end"/&gt;
450 &lt;/ArdourMIDIBindings&gt;
451 </pre>
452 <p>
453   Please note that channel, controller and note numbers are specified as
454   decimal numbers in the ranges 1-16, 0-127 and 0-127 respectively
455   (the channel range may change at some point).
456 </p>
457