Package uk.org.toot.midi.message

This package addresses issues with MidiMessage, such as the subclass problems (what is a MidiMessage that isn't one of the specified subclasses?).

See:
          Description

Class Summary
ChannelMsg The class for creating accessing and mutating 1, 2 and 3 bytes MidiMessages representing Channel Voice and Channel Mode messages without knowledge of the implementation class.
CommonMsg The class for creating accessing and mutating 1, 2 and 3 bytes MidiMessages representing System Common messages without knowledge of the implementation class.
MachineControlMsg This class provides methods and constants to simplify client handling of MIDI Machine Control messages.
MetaMsg The class for creating accessing and mutating arbitrary length MidiMessages representing Meta messages without knowledge of the implementation class.
MidiMsg The class for handling abstract MIDI messages.
NoteMsg This class provides method to simplify client handling of NOTE_ON and NOTE_OFF messages.
PitchMsg This class provides methods to simplify client handling of pitched messages.
RealTimeMsg The class for creating and accessing 1 byte MidiMessages representing System Real Time messages without knowledge of the implementation class.
ShortMsg The base class for creating accessing and mutating 1, 2 and 3 byte MidiMessages without knowledge of the implementation class.
SysexMsg The class for creating accessing and mutating arbitrary length MidiMessages representing System Exclusive messages without knowledge of the implementation class.
TimeMsg This class provides methods to simplify the handling of MIDI Time Code messages.
UniversalSysexMsg This class provides methods to simplify the handling of Universal System Exclusive messages.
 

Package uk.org.toot.midi.message Description

This package addresses issues with MidiMessage, such as the subclass problems (what is a MidiMessage that isn't one of the specified subclasses?). Here the client need only be concerned with MidiMessage. Specialised classes are provided to create, access and mutate Channel Voice, Channel Mode, System Common, System Real Time, System Exclusive and Meta messages, regardless of their specific implementation class.

It does not currently address transport GC-inefficiency (mutability defensive cloning)

Some examples which show the relative ease of use compared to javax.sound.midi

Setting the Track Name Meta Event with MidiMessage msg, String name

import javax.sound.midi.MetaMessage;
...
if (msg instanceof MetaMessage) {
        MetaMessage mm = (MetaMessage)msg;
        if (mm.getType() == 0x03) {
                byte[] bytes = name.getBytes();
                mm.setMessage(0x03, bytes, bytes.length);
        }
        
}
becomes
import static uk.org.toot.midi.message.MetaMsg.*;
...
if (isMeta(msg) && getType(msg) == TRACK_NAME) {
        setString(msg, name);
}

Transposing notes with MidiMessage msg, int semitones

import javax.sound.midi.ShortMessage;
...
if (msg instanceof ShortMessage) {
        ShortMessage sm = (ShortMessage)msg;
        int cmd = sm.getCommand();
        if (cmd == ShortMessage.NOTE_ON || 
                cmd == ShortMessage.NOTE_OFF || 
                cmd == ShortMessage.POLY_PRESSURE) {
                        sm.setMessage(cmd, sm.getChannel(), sm.getData1()+semitones, sm.getData2());
        }
                
}
becomes
import static uk.org.toot.midi.message.PitchMsg.*;
...
if (isPitch(msg))
        transpose(msg, semitones)

Detecting a NOTE_OFF

import javax.sound.midi.ShortMessage;
...
if (msg instanceof ShortMessage) {
        ShortMessage sm = (ShortMessage)msg;
        int cmd = sm.getCommand();
        boolean b = cmd == ShortMessage.NOTE_OFF || (cmd == ShortMessage.NOTE_ON && sm.getData2() == 0);
}
becomes
import static uk.org.toot.midi.NoteMsg.*;
...
boolean b = isNote(msg) && isOff(msg);

Package uk.org.toot.midi.message UML Class Diagram



Copyright © 2004, 2005, 2006, 2007 Steve Taylor. All Rights Reserved.