| 1 | |
| 2 | <refentry id="noteondur2"> |
| 3 | <indexterm id="IndexNoteondur2"><primary>noteondur2</primary></indexterm> |
| 4 | <refentryinfo><title>Real-time MIDI:Note Output</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>noteondur2</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | |
| 10 | |
| 11 | <refnamediv> |
| 12 | <refname>noteondur2</refname> |
| 13 | |
| 14 | <refpurpose> |
| 15 | Sends a noteon and a noteoff MIDI message both with the same channel, number and velocity. |
| 16 | </refpurpose> |
| 17 | </refnamediv> |
| 18 | |
| 19 | <refsect1> |
| 20 | <title>Description</title> |
| 21 | <para> |
| 22 | Sends a noteon and a noteoff MIDI message both with the same channel, number and velocity. |
| 23 | </para> |
| 24 | </refsect1> |
| 25 | |
| 26 | <refsect1> |
| 27 | <title>Syntax</title> |
| 28 | <synopsis><command>noteondur2</command> ichn, inum, ivel, idur</synopsis> |
| 29 | </refsect1> |
| 30 | |
| 31 | <refsect1> |
| 32 | <title>Initialization</title> |
| 33 | <para> |
| 34 | <emphasis>ichn</emphasis> -- MIDI channel number (1-16) |
| 35 | </para> |
| 36 | |
| 37 | <para> |
| 38 | <emphasis>inum</emphasis> -- note number (0-127) |
| 39 | </para> |
| 40 | |
| 41 | <para> |
| 42 | <emphasis>ivel</emphasis> -- velocity (0-127) |
| 43 | </para> |
| 44 | |
| 45 | <para> |
| 46 | <emphasis>idur</emphasis> -- how long, in seconds, this note should last. |
| 47 | </para> |
| 48 | </refsect1> |
| 49 | |
| 50 | <refsect1> |
| 51 | <title>Performance</title> |
| 52 | <para> |
| 53 | <emphasis>noteondur2</emphasis> (i-rate note on with duration) sends a noteon and a noteoff MIDI message both with the same channel, number and velocity. Noteoff message is sent after <emphasis>idur</emphasis> seconds are elapsed by the time <emphasis>noteondur2</emphasis> was active. |
| 54 | </para> |
| 55 | |
| 56 | <para> |
| 57 | <emphasis>noteondur</emphasis> differs from <emphasis>noteondur2</emphasis> in that <emphasis>noteondur</emphasis> truncates note duration when current instrument is deactivated by score or by real-time playing, while <emphasis>noteondur2</emphasis> will extend performance time of current instrument until <emphasis>idur</emphasis> seconds have elapsed. In real-time playing, it is suggested to use <emphasis>noteondur</emphasis> also for undefined durations, giving a large <emphasis>idur</emphasis> value. |
| 58 | </para> |
| 59 | |
| 60 | <para> |
| 61 | Any number of <emphasis>noteondur2</emphasis> opcodes can appear in the same Csound instrument, allowing chords to be played by a single instrument. |
| 62 | </para> |
| 63 | </refsect1> |
| 64 | |
| 65 | <refsect1> |
| 66 | <title>Examples</title> |
| 67 | <para> |
| 68 | Here is an example of the noteondur2 opcode. It uses the file <ulink url="examples/noteondur2.csd"><citetitle>noteondur2.csd</citetitle></ulink>. |
| 69 | |
| 70 | <example> |
| 71 | <title>Example of the noteondur2 opcode.</title> |
| 72 | <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> |
| 73 | <para>This example generates notes for every note received on the MIDI input. It generates MIDI notes on csound's MIDI output, so be sure to connect something.</para> |
| 74 | <xi:include href="examples-xml/noteondur2.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 75 | </example> |
| 76 | </para> |
| 77 | </refsect1> |
| 78 | |
| 79 | <refsect1> |
| 80 | <title>See also</title> |
| 81 | <para><link linkend="MidiOnoff"><citetitle>Note-on/Note-off Output</citetitle></link></para> |
| 82 | </refsect1> |
| 83 | |
| 84 | <refsect1> |
| 85 | <title>Credits</title> |
| 86 | <para> |
| 87 | <simplelist> |
| 88 | <member>Author: &namegabriel;</member> |
| 89 | <member>Italy</member> |
| 90 | </simplelist> |
| 91 | </para> |
| 92 | |
| 93 | <para>New in Csound version 3.47</para> |
| 94 | <para>Thanks goes to &namerasmus; for pointing out the correct MIDI channel and controller number ranges.</para> |
| 95 | </refsect1> |
| 96 | </refentry> |