uk.org.toot.midi.message
Class NoteMsg

java.lang.Object
  extended by uk.org.toot.midi.message.MidiMsg
      extended by uk.org.toot.midi.message.ShortMsg
          extended by uk.org.toot.midi.message.ChannelMsg
              extended by uk.org.toot.midi.message.PitchMsg
                  extended by uk.org.toot.midi.message.NoteMsg

public class NoteMsg
extends PitchMsg

This class provides method to simplify client handling of NOTE_ON and NOTE_OFF messages. The methods isOn() and isOff() encapsulate the knowledge of when a NOTE_ON is really a NOTE_OFF (when velocity equals 0) so that client code need not be concerned about this matter. Accessors and mutators are provided for the Velocity properties.


Field Summary
 
Fields inherited from class uk.org.toot.midi.message.ChannelMsg
CHANNEL_PRESSURE, CONTROL_CHANGE, NOTE_OFF, NOTE_ON, PITCH_BEND, POLY_PRESSURE, PROGRAM_CHANGE
 
Constructor Summary
NoteMsg()
           
 
Method Summary
static int getVelocity(javax.sound.midi.MidiMessage msg)
          Get the velocity byte for the specified MidiMessage.
static boolean isNote(int status)
           
static boolean isNote(javax.sound.midi.MidiMessage msg)
          Determine whether the specified MidiMessage can be handled by this class.
static boolean isOff(int status, int data2)
           
static boolean isOff(javax.sound.midi.MidiMessage msg)
          Determine whether the specified MidiMessage is effectively a Note Off message.
static boolean isOn(int status, int data2)
           
static boolean isOn(javax.sound.midi.MidiMessage msg)
          Determine whether this MidiMessage is effectively a Note On.
static javax.sound.midi.MidiMessage louden(javax.sound.midi.MidiMessage msg, int velocityDelta)
          Louden the specified MidiMessage by adding the specified velocityDelta to the velocity byte.
static javax.sound.midi.MidiMessage off(int chan, int note)
          Create a MidiMessage representing a Note Off message.
static javax.sound.midi.MidiMessage off(int chan, int note, int vel)
          Create a MidiMessage representing a Note Off message.
static javax.sound.midi.MidiMessage on(int chan, int note, int vel)
          Create a MidiMessage representing a Note On message.
static javax.sound.midi.MidiMessage setVelocity(javax.sound.midi.MidiMessage msg, int vel)
          Set the velocity byte for the specified MidiMessage.
 
Methods inherited from class uk.org.toot.midi.message.PitchMsg
getPitch, isPitch, isPitch, setPitch, transpose
 
Methods inherited from class uk.org.toot.midi.message.ChannelMsg
createChannel, createChannel, getChannel, getChannel, getCommand, getCommand, isChannel, isChannel, setChannel, setChannel
 
Methods inherited from class uk.org.toot.midi.message.ShortMsg
createShort, createShort, createShort, getData1, getData1and2, getData1and2, getData2, isShort, isShort, setData1, setData2, setMessage, setMessage
 
Methods inherited from class uk.org.toot.midi.message.MidiMsg
getLength, getMessage, getStatus
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NoteMsg

public NoteMsg()
Method Detail

isNote

public static boolean isNote(javax.sound.midi.MidiMessage msg)
Determine whether the specified MidiMessage can be handled by this class.


isNote

public static boolean isNote(int status)

on

public static javax.sound.midi.MidiMessage on(int chan,
                                              int note,
                                              int vel)
                                       throws javax.sound.midi.InvalidMidiDataException
Create a MidiMessage representing a Note On message.

Throws:
javax.sound.midi.InvalidMidiDataException

off

public static javax.sound.midi.MidiMessage off(int chan,
                                               int note,
                                               int vel)
                                        throws javax.sound.midi.InvalidMidiDataException
Create a MidiMessage representing a Note Off message.

Throws:
javax.sound.midi.InvalidMidiDataException

off

public static javax.sound.midi.MidiMessage off(int chan,
                                               int note)
                                        throws javax.sound.midi.InvalidMidiDataException
Create a MidiMessage representing a Note Off message. Which may be a zero-velocty Note On.

Throws:
javax.sound.midi.InvalidMidiDataException

isOn

public static boolean isOn(javax.sound.midi.MidiMessage msg)
Determine whether this MidiMessage is effectively a Note On. This definition excludes a Note On with a velocity of zero which is considered to effectively be a Note Off.


isOn

public static boolean isOn(int status,
                           int data2)

isOff

public static boolean isOff(javax.sound.midi.MidiMessage msg)
Determine whether the specified MidiMessage is effectively a Note Off message.


isOff

public static boolean isOff(int status,
                            int data2)

getVelocity

public static int getVelocity(javax.sound.midi.MidiMessage msg)
Get the velocity byte for the specified MidiMessage.


setVelocity

public static javax.sound.midi.MidiMessage setVelocity(javax.sound.midi.MidiMessage msg,
                                                       int vel)
                                                throws javax.sound.midi.InvalidMidiDataException
Set the velocity byte for the specified MidiMessage.

Throws:
javax.sound.midi.InvalidMidiDataException

louden

public static javax.sound.midi.MidiMessage louden(javax.sound.midi.MidiMessage msg,
                                                  int velocityDelta)
                                           throws javax.sound.midi.InvalidMidiDataException
Louden the specified MidiMessage by adding the specified velocityDelta to the velocity byte. A negatibe delta makes the message quieter. Value is clamped.

Throws:
javax.sound.midi.InvalidMidiDataException


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