Class Routing

java.lang.Object
eu.bandm.music.midi.Routing

public class Routing extends Object
Contains methods and classes for a midi message/event processing network. Plus some wrappers which lift some deficient classes from java.sound.midi to the modern interfaces. The basic data structures are
   +----- MidiEvent---+
   |  long tick       |
   | +---MidiMesage-+ |
   | |              | |
   | +--------------+ |
   +------------------*
  
  
Attention: The time stamps in "midi events", coming from a "midi standard file", and those coming with "MidiMessages" (as separate method parameters) have different meanings.
  • Field Details

  • Constructor Details

    • Routing

      public Routing()
  • Method Details

    • checkParameterValue

      public static void checkParameterValue(int i, String text)
    • extractCommand

      public static int extractCommand(int m)
      Parameters:
      m - the int value of a MidiMessage status byte
      Returns:
      the int value of the midi command, based on ZERO, ie. from midi_note_on to midi_system_message as defined in this class.
    • extractChannel

      public static int extractChannel(int m)
      Parameters:
      m - the int value of a MidiMessage status byte
      Returns:
      the int value of the adressed channel, from 0 to 15
    • extract14bits

      public static int extract14bits(ShortMessage message)
      Parameters:
      message - a pitch bend message
      Returns:
      the int value when concatenating the 7 lower bits of the two data byes.
    • packStatus

      public static int packStatus(int code, int channel)
      Parameters:
      code - the int value of the command, packed into the higher nibble. (May by based on zero or eight, since hi bit will be set anyhow.)
      channel - value packed into the lower nibble.
      Returns:
      the int value of the status byte, high bit always set
    • getKeyNumber

      public static int getKeyNumber(MidiMessage m)
      ATTENTION: java-bytes are SIGNED, and must be converted to int to get their midi meaning, wich is unsigned.
      ATTENTION: this method does only make sense when a key is really part of the message, i.e. the commands from "midi_note_off" to "midi_polyphonic_aftertouch". (im case of "midi_program_change" and "midi_control_change" it does make sense to get the data byte, but this is an abuse w.r.t. the NAME of this method!)
    • range_included

      public static Pattern<Integer> range_included(int from, int to)
      A pattern which matches any Integer in the range between the two bounds, both INCLUDED!
    • range

      public static Pattern<Integer> range(int from, int to)
      A pattern which matches any Integer in the range between the two bounds, lower included, upper not.
    • statusByte

      public static Pattern<Integer> statusByte(Pattern<Integer> command, Pattern<Integer> channel)
      Constructs a Pattern for an integer which represents a status byte.
    • status

      public static Pattern<MidiMessage> status(Pattern<Integer> statusByte)
    • statusByteM

      public static Pattern<MidiMessage> statusByteM(Pattern<Integer> command, Pattern<Integer> channel)
      Replace by content( statusByte(..,..))
    • statusByteE

      public static Pattern<MidiEvent> statusByteE(Pattern<Integer> command, Pattern<Integer> channel)
    • system

      public static Pattern<Integer> system(Pattern<Integer> systemMessage)
    • systemM

      public static Pattern<MidiMessage> systemM(Pattern<Integer> systemMessage)
    • systemE

      public static Pattern<MidiEvent> systemE(Pattern<Integer> systemMessage)
    • keyM

      public static Pattern<MidiMessage> keyM(Pattern<Integer> keyNumber)
    • main

      public static void main(String[] args) throws InvalidMidiDataException, IOException
      Throws:
      InvalidMidiDataException
      IOException