MIDI/Score Interoperability opcodes

The following opcodes can be used to design instruments that work interchangably for real-time MIDI and score events:

[Note] Adapting a score-activated Csound instrument.

To adapt an ordinary Csound instrument designed for score activation for score/MIDI interoperability:

  • Change all linen, linseg, and expseg opcodes to linenr, linsegr, and expsegr, respectively, except for a de-clicking or damping envelope. This will not materially change score-driven performance.

  • Add the following lines at the beginning of the instrument definition:

      ; Ensures that a MIDI-activated instrument
      ; will have a positive p3 field.
      mididefault 60, p3 
      ; Puts MIDI key translated to cycles per
      ; second into p4, and MIDI velocity into p5
      midinoteoncps p4, p5

    Obviously, midinoteoncps could be changed to midinoteonoct or any of the other options, and the choice of p-fields is arbitrary.

[Note] MIDI Realtime Input/Ouput command line options

New MIDI I/O flags in Csound 5.02, can replace most uses of these MIDI interop opcodes, and make usage easier.