summaryrefslogtreecommitdiff
path: root/opcodes/midinoteonpch.xml
blob: a8a7836a132f90abdc1c474e62bc9d1b57ae7397 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<refentry id="midinoteonpch">
<indexterm id="IndexMidinoteonpch"><primary>midinoteonpch</primary></indexterm>
  <refentryinfo><title>Real-time MIDI:MIDI/Score Interoperability</title></refentryinfo>
  <refmeta>
    <refentrytitle>midinoteonpch</refentrytitle>
  </refmeta>



  <refnamediv>
    <refname>midinoteonpch</refname>
    <refpurpose>
      Gets a MIDI note number as a pitch-class value.
          </refpurpose>
  </refnamediv>
  
  <refsect1>
    <title>Description</title>
    <para>
      <emphasis>midinoteonpch</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.
    </para>

    <para>
      In general, it should be possible to write instrument definitions that work identically with both scores
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.
    </para>

    <para>
      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.
    </para>
  </refsect1>

  <refsect1>
    <title>Syntax</title>
    <synopsis><command>midinoteonpch</command> xpch, xvelocity</synopsis>
  </refsect1>

  <refsect1>
    <title>Performance</title>
    <para>
      <emphasis>xpch</emphasis> -- returns MIDI key translated to octave.pch during MIDI activation, remains unchanged otherwise.
    </para>

    <para>
      <emphasis>xvelocity</emphasis> -- returns MIDI velocity during MIDI activation, remains unchanged otherwise.
    </para>

    <para>
      If the instrument was activated by MIDI input, the opcode overwrites the values of <emphasis>xpch</emphasis> and <emphasis>xvelocity</emphasis> with the corresponding value from MIDI input. If the instrument was <emphasis>NOT</emphasis> activated by MIDI input, the values of <emphasis>xpch</emphasis> and <emphasis>xvelocity</emphasis> remain unchanged.
    </para>

    <para>
      This enables score p-fields to receive MIDI input data during MIDI activation, and score values otherwise.
    </para>

    <note>
      <title>Adapting a score-activated Csound instrument.</title>
      <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>
    </note>
  </refsect1>

  <refsect1>
    <title>Examples</title>
    <para>
      Here is an example of the midinoteonpch opcode. It uses the file <ulink url="examples/midinoteonpch.csd"><citetitle>midinoteonpch.csd</citetitle></ulink>.

      <example>
        <title>Example of the midinoteonpch opcode.</title>

        

        <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>
          <xi:include href="examples-xml/midinoteonpch.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
      </example>

      Its output should include lines like:
      <screen>
 i1     8.09000
 i1     9.05000
      </screen>
    </para>
  </refsect1>

  <refsect1>
    <title>See Also</title>
    <para>
      <link linkend="midichannelaftertouch"><citetitle>midichannelaftertouch</citetitle></link>, 
      <link linkend="midicontrolchange"><citetitle>midicontrolchange</citetitle></link>, 
      <link linkend="mididefault"><citetitle>mididefault</citetitle></link>, 
      <link linkend="midinoteoff"><citetitle>midinoteoff</citetitle></link>, 
      <link linkend="midinoteoncps"><citetitle>midinoteoncps</citetitle></link>, 
      <link linkend="midinoteonkey"><citetitle>midinoteonkey</citetitle></link>, 
      <link linkend="midinoteonoct"><citetitle>midinoteonoct</citetitle></link>, 
      <link linkend="midipitchbend"><citetitle>midipitchbend</citetitle></link>, 
      <link linkend="midipolyaftertouch"><citetitle>midipolyaftertouch</citetitle></link>, 
      <link linkend="midiprogramchange"><citetitle>midiprogramchange</citetitle></link>
    </para>
  </refsect1>

  <refsect1>
    <title>Credits</title>
    <para>Author: Michael Gogins</para>
    <para>Example written by &namekevin;.</para>
    <para>New in version 4.20</para>
  </refsect1>
</refentry>