Class:            MIDIDevice

Environment:      Siren
Superclass:         Siren.DeviceModel
Category:         MusicIO-MIDI
Class variables:      MStream

MIDIDevice is a subclass of Model whose instances are used to model MIDI input/output hardware devices.
The abstract class MIDIDevice implements the generic MIDI note on/off type events.
Subclasses of MIDIDevice exist for specific models of devices and implement the device-specific (system exclusive) commands.
MIDIDevice are passed Events and channel numbers by their voices and generate commands as ByteArrays that they pass to MIDIPorts.
Several devices may share one port (if there are several MIDI-capable devices on one cable), and one voice may point to several device/channel pairs on one or more devices.

Instance variables:
   port the MIDIPort I use
   stream logging stream
   debug verbosity flag for Transcript dumping

Class variable:
   MStream    the stream I dump by bytes on if my port is nil (good for debugging new subclasses)

Standard MIDI Commands:
      Note On = 9n kk vv
      Note Off = 8n kk vv
      Key Pressure = An kk vv
      Pitch Wheel = En ll ll
      After Touch Channel Pressure = Dn vv
      Control Change = Bn cc vv
      Program change = Cn pp

Relevant Constants for description of MIDI commands:
      n = 4-bit channel number
      kk = 7-bit key number
      vv = 7-bit key velocity
      ll = 7-bit low-order value
      hh = 7-bit high-order value
      cc = 7-bit control number
      pp = 7-bit program number

accessing

port
   Answer the receiver's I/O port.

port: aPort
   Set the receiver's I/O port.

stream
   Answer the receiver's MIDI stream ID.

stream: aNumber
   Set the receiver's MIDI stream ID.

initialization

checkPort
   Ensure that the receiver's output port is initialized.

close
   Release the receiver's hold on the port.

initialize
   Set the receiver up on the default output port.

initialize: thePort
   Set the receiver up on the given output port.

play: anAss on: channelNumber
   play the given event on my port as a default MIDI noteOn/noteOff pair

note events

play: anEvent at: aTime
   Play the given event on my port as a default MIDI noteOn/noteOff pair.

parameter mapping

mapAmplitude: aVal
   Map a numerical or symbolic amplitude to a MIDI-compatible
    volume number (key velocity)

mapDuration: aVal
   Map a numerical or symbolic duration value to a
    MIDI-compatible duration in msec.

mapPitch: aVal
   Map a numerical or symbolic pitch to a MIDI-compatible note number.

mapVoice: aVal
   Map a numerical or symbolic pitch to a MIDI-compatible note number.

MetaClass:         MIDIDevice class

examples

playOnDevice
   Play a note out MIDI from the device level.

scheduleExample
   Play MIDI using the event scheduler.

instance creation

new
   Open a generic MidiDevice on the default Port

on: port
   Open a generic MidiDevice on the given Port

class initialization

initialize
   Set up the one class variable