| 1 | |
| 2 | <refentry id="midicontrolchange"> |
| 3 | <indexterm id="IndexMidicontrolchange"><primary>midicontrolchange</primary></indexterm> |
| 4 | <refentryinfo><title>Real-time MIDI:MIDI/Score Interoperability</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>midicontrolchange</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | |
| 10 | |
| 11 | <refnamediv> |
| 12 | <refname>midicontrolchange</refname> |
| 13 | <refpurpose> |
| 14 | Gets a MIDI control change value. |
| 15 | </refpurpose> |
| 16 | </refnamediv> |
| 17 | |
| 18 | <refsect1> |
| 19 | <title>Description</title> |
| 20 | <para> |
| 21 | <emphasis>midicontrolchange</emphasis> is designed to simplify writing instruments that can be used interchangeably for either score or MIDI input, and to make it easier to adapt instruments originally written for score input to work with MIDI input. |
| 22 | </para> |
| 23 | |
| 24 | <para> |
| 25 | In general, it should be possible to write instrument definitions that work identically with both scores |
| 26 | and MIDI, including both MIDI files and real-time MIDI input, without using any conditional statements, and that take full advantage of MIDI voice messages. |
| 27 | </para> |
| 28 | |
| 29 | <para> |
| 30 | Note that correlating Csound instruments with MIDI channel numbers is done using the <link linkend="massign"><citetitle>massign</citetitle></link> opcode for real-time performance,. For file-driven performance, instrument numbers default to MIDI channel number + 1, but the defaults are overridden by any MIDI program change messages in the file. |
| 31 | </para> |
| 32 | </refsect1> |
| 33 | |
| 34 | <refsect1> |
| 35 | <title>Syntax</title> |
| 36 | <synopsis><command>midicontrolchange</command> xcontroller, xcontrollervalue [, ilow] [, ihigh]</synopsis> |
| 37 | </refsect1> |
| 38 | |
| 39 | <refsect1> |
| 40 | <title>Initialization</title> |
| 41 | <para> |
| 42 | <emphasis>ilow</emphasis> (optional) -- optional low value after rescaling, defaults to 0. |
| 43 | </para> |
| 44 | |
| 45 | <para> |
| 46 | <emphasis>ihigh</emphasis> (optional) -- optional high value after rescaling, defaults to 127. |
| 47 | </para> |
| 48 | </refsect1> |
| 49 | |
| 50 | <refsect1> |
| 51 | <title>Performance</title> |
| 52 | <para> |
| 53 | <emphasis>xcontroller</emphasis> -- specifies the MIDI controller number (0-127) to read from. |
| 54 | </para> |
| 55 | |
| 56 | <para> |
| 57 | <emphasis>xcontrollervalue</emphasis> -- returns the value of the MIDI controller during MIDI activation, remains unchanged otherwise. |
| 58 | </para> |
| 59 | |
| 60 | <para> |
| 61 | If the instrument was activated by MIDI input, the opcode overwrites the value of <emphasis>xcontrollervalue</emphasis> with the corresponding value from the MIDI data of the specified <emphasis>xcontroller</emphasis>. If the instrument was <emphasis>NOT</emphasis> activated by MIDI input, the value remains unchanged. |
| 62 | </para> |
| 63 | |
| 64 | <para> |
| 65 | This enables score p-fields to receive MIDI input data during MIDI activation, and score values otherwise. |
| 66 | </para> |
| 67 | |
| 68 | <note> |
| 69 | <title>Adapting a score-activated Csound instrument.</title> |
| 70 | <para>See the <link linkend="MidiInterop"><citetitle>MIDI interop opcodes</citetitle></link> section for details on adapting score driven instruments for MIDI or vice-versa.</para> |
| 71 | </note> |
| 72 | </refsect1> |
| 73 | |
| 74 | <refsect1> |
| 75 | <title>Examples</title> |
| 76 | <para> |
| 77 | Here is an example of the midicontrolchange opcode. It uses the file <ulink url="examples/midicontrolchange.csd"><citetitle>midicontrolchange.csd</citetitle></ulink> |
| 78 | |
| 79 | <example> |
| 80 | <title>Example of the midicontrolchange opcode.</title> |
| 81 | <xi:include href="examples-xml/midicontrolchange.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 82 | </example> |
| 83 | </para> |
| 84 | </refsect1> |
| 85 | |
| 86 | <refsect1> |
| 87 | <title>See also</title> |
| 88 | <para><link linkend="MidiInterop"><citetitle>MIDI/Score Interoperability</citetitle></link></para> |
| 89 | </refsect1> |
| 90 | |
| 91 | <refsect1> |
| 92 | <title>Credits</title> |
| 93 | <para>Author: Michael Gogins</para> |
| 94 | <para>New in version 4.20</para> |
| 95 | <para>Thanks goes to &namerasmus; for pointing out the correct MIDI channel and controller number ranges.</para> |
| 96 | </refsect1> |
| 97 | </refentry> |