Squeak Class Documentation category index | class index  
 
MIDIInputParser
  category: Sound-Scores
  superclass: Object
  subclasses:

I am a parser for a MIDI data stream. I support:

real-time MIDI recording,
overdubbing (recording while playing),
monitoring incoming MIDI, and
interactive MIDI performances.

Note: MIDI controllers such as pitch benders and breath controllers generate large volumes of data which consume processor time. In cases where this information is not of interest to the program using it, it is best to filter it out as soon as possible. I support various options for doing this filtering, including filtering by MIDI channel and/or by command type.

instance methods
  accessing
  midiPort
midiPort:

  midi filtering
  ignoreChannel:
ignoreCommand:
ignoreSysEx:
ignoreTuneAndRealTimeCommands
noFiltering
recordOnlyChannels:

  midi monitor
  monitor
printCmd:with:with:

  private-other
  setMIDIPort:

  private-state machine
  endSysExclusive:
ignoreOne:
ignoreTwo:
ignoreZero:
processByte:
recordOne:
recordTwo:
recordZero:
startSysExclusive:
undefined:

  real-time processing
  midiDo:
midiDoUntilMouseDown:

  recording
  clearBuffers
processMIDIData
received

class methods
  class initialization
  initialize

  instance creation
  on:

instance methods
  accessing top  
 

midiPort


 

midiPort:

Use the given MIDI port.


  midi filtering top  
 

ignoreChannel:

Don't record any events arriving on the given MIDI channel (in the range 1-16).


 

ignoreCommand:

Don't record the given MIDI command on any channel.


 

ignoreSysEx:

If the argument is true, then ignore incoming system exclusive message.


 

ignoreTuneAndRealTimeCommands

Ignore tuning requests and real-time commands.


 

noFiltering

Revert to accepting all MIDI commands on all channels. This undoes any earlier request to filter the incoming MIDI stream.


 

recordOnlyChannels:

Record only MIDI data arriving on the given list of channel numbers (in the range 1-16).


  midi monitor top  
 

monitor

Print MIDI messages to the transcript until any mouse button is pressed.


 

printCmd:with:with:

Print the given MIDI command.


  private-other top  
 

setMIDIPort:

Initialize this instance for recording from the given MIDI port. Tune and real-time commands are filtered out by default; the client can send noFiltering to receive these messages.


  private-state machine top  
 

endSysExclusive:

Error! Received 'end system exclusive' command when not receiving system exclusive data.


 

ignoreOne:

Ignore a one argument command.


 

ignoreTwo:

Ignore a two argument command.


 

ignoreZero:

Ignore a zero argument command, such as tune request or a real-time message. Stay in the current and don't change active status. Note that real-time messages can arrive between data bytes without disruption.


 

processByte:

Process the given incoming MIDI byte and record completed commands.


 

recordOne:

Record a one argument command at the current time.


 

recordTwo:

Record a two argument command at the current time.


 

recordZero:

Record a zero-byte message, such as tune request or a real-time message. Don't change active status. Note that real-time messages can arrive between data bytes without disruption.


 

startSysExclusive:

The beginning of a variable length 'system exclusive' command.


 

undefined:

We have received an unexpected MIDI byte (e.g., a data byte when we were expecting a command). This should never happen.


  real-time processing top  
 

midiDo:

Poll the incoming MIDI stream in real time and call the given block for each complete command that has been received. The block takes one argument, which is an array of the form (<time><cmd byte>[<arg1>[<arg2>]]). The number of arguments depends on the command byte. For system exclusive commands, the argument is a ByteArray containing the system exclusive message.


 

midiDoUntilMouseDown:

Process the incoming MIDI stream in real time by calling midiActionBlock for each MIDI event. This block takes three arguments: the MIDI command byte and two argument bytes. One or both argument bytes may be nil, depending on the MIDI command. If not nil, evaluatue idleBlock regularly whether MIDI data is available or not. Pressing any mouse button terminates the interaction.


  recording top  
 

clearBuffers

Clear the MIDI record buffers. This should be called at the start of recording or real-time MIDI processing.


 

processMIDIData

Process all MIDI data that has arrived since the last time this method was executed. This method should be called frequently to process, filter, and timestamp MIDI data as it arrives.


 

received

Answer my current collection of all MIDI commands received. Items in this list have the form (<time><cmd byte>[<arg1>[<arg2>]]). Note that the real-time processing facility, midiDo:, removes items from this list as it processes them.


class methods
  class initialization top  
 

initialize

Build the default MIDI command-byte action table. This table maps MIDI command bytes to the action to be performed when that is received. Note that MIDI data bytes (bytes whose value is < 128) are never used to index into this table.


  instance creation top  
 

on:

Answer a new MIDI parser on the given port.