MidiInput class overview

MidiInput contains all of the functionality of the MidiInPort class but also adds the ability to maintain a private MIDI buffer (as opposed to the MidiInPort class which all share a common set of input buffers.) This class is analogous to the MidiOutput class.

You can echo the input coming into one MidiInPort class by inserting an extracted message into another MidiInPort instance, as shown in Example 1 below:

MidiInput Example 1: Copying Midi input streams to other MidiInput objects  

   
   MidiInput midiIn(0);   // open midi hardware port 0
   MidiInput midiEcho;    // set to MIDI hardware port 0 by default

   midiEcho.makeOrphanBuffer();  // make private Midi input buffer, default size

   // how to transfer a Midi message from midiIn to midiEcho:
   if (midiIn.getCount() != 0) {
      MidiMessage message = midiIn.extract();
      midiEcho.insert(message);
   }

Some of the MidiInPort class functions are redefined to handle the orphan buffer. The following function will affect the orphan buffer or the hardware buffers depending on which one is being accessed. The modified functions are:

  1. operator[]
  2. insert
  3. extract
  4. setBufferSize
  5. getCount














Send comments/errors on this page to craig@ccrma.stanford.edu