| 1 | |
| 2 | <refentry id="midinoteoff"> |
| 3 | <indexterm id="IndexMidinoteoff"><primary>midinoteoff</primary></indexterm> |
| 4 | <refentryinfo><title>Real-time MIDI:MIDI/Score Interoperability</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>midinoteoff</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | |
| 10 | |
| 11 | <refnamediv> |
| 12 | <refname>midinoteoff</refname> |
| 13 | <refpurpose> |
| 14 | Gets a MIDI noteoff value. |
| 15 | </refpurpose> |
| 16 | </refnamediv> |
| 17 | |
| 18 | <refsect1> |
| 19 | <title>Description</title> |
| 20 | <para> |
| 21 | This opcode is incorrect. It is <emphasis>identical</emphasis> to <emphasis>midinoteonkey</emphasis>. |
| 22 | It does not do what you would expect from its name, as it does not respond to Note-Off events, but is activated by Note-On. |
| 23 | The <emphasis>midiin</emphasis> opcode can be used to receive noteoff events and their velocities. |
| 24 | </para> |
| 25 | <para> |
| 26 | <emphasis>midinoteoff</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. |
| 27 | </para> |
| 28 | |
| 29 | <para> |
| 30 | In general, it should be possible to write instrument definitions that work identically with both scores |
| 31 | 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. |
| 32 | </para> |
| 33 | |
| 34 | <para> |
| 35 | 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. |
| 36 | </para> |
| 37 | </refsect1> |
| 38 | |
| 39 | <refsect1> |
| 40 | <title>Syntax</title> |
| 41 | <synopsis><command>midinoteoff</command> xkey, xvelocity</synopsis> |
| 42 | </refsect1> |
| 43 | |
| 44 | <refsect1> |
| 45 | <title>Performance</title> |
| 46 | <para> |
| 47 | <emphasis>xkey</emphasis> -- returns MIDI key during MIDI activation, remains unchanged otherwise. |
| 48 | </para> |
| 49 | |
| 50 | <para> |
| 51 | <emphasis>xvelocity</emphasis> -- returns MIDI velocity during MIDI activation, remains unchanged otherwise. |
| 52 | </para> |
| 53 | |
| 54 | <para> |
| 55 | If the instrument was activated by MIDI input, the opcode overwrites the values of the <emphasis>xkey</emphasis> and <emphasis>xvelocity</emphasis> with the corresponding values from MIDI input. If the instrument was <emphasis>NOT</emphasis> activated by MIDI input, the values of <emphasis>xkey</emphasis> and <emphasis>xvelocity</emphasis> remain unchanged. |
| 56 | </para> |
| 57 | |
| 58 | <para> |
| 59 | This enables score p-fields to receive MIDI input data during MIDI activation, and score values otherwise. |
| 60 | </para> |
| 61 | |
| 62 | <note> |
| 63 | <title>Adapting a score-activated Csound instrument.</title> |
| 64 | <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> |
| 65 | </note> |
| 66 | </refsect1> |
| 67 | |
| 68 | <refsect1> |
| 69 | <title>Examples</title> |
| 70 | <para> |
| 71 | Here is an example of the midinoteoff opcode. It uses the file <ulink url="examples/midinoteoff.csd"><citetitle>midinoteoff.csd</citetitle></ulink>. |
| 72 | <example> |
| 73 | <title>Example of the midinoteoff opcode.</title> |
| 74 | <para>See the sections <link linkend="UsingRealTime"><citetitle>Real-time Audio</citetitle></link> and <link linkend="CommandFlags"><citetitle>Command Line Flags</citetitle></link> for more information on using command line flags.</para> |
| 75 | <xi:include href="examples-xml/midinoteoff.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 76 | </example> |
| 77 | Its output should include lines like: |
| 78 | <screen> |
| 79 | i1 60.00000 |
| 80 | i1 76.00000 |
| 81 | </screen> |
| 82 | </para> |
| 83 | </refsect1> |
| 84 | |
| 85 | <refsect1> |
| 86 | <title>See also</title> |
| 87 | <para><link linkend="MidiInterop"><citetitle>MIDI/Score Interoperability</citetitle></link></para> |
| 88 | </refsect1> |
| 89 | |
| 90 | <refsect1> |
| 91 | <title>Credits</title> |
| 92 | <para>Author: Michael Gogins</para> |
| 93 | <para>New in version 4.20</para> |
| 94 | </refsect1> |
| 95 | </refentry> |