net.charlesames.music.midi
Class MidiNote

java.lang.Object
  extended by net.charlesames.music.midi.MidiNote

public class MidiNote
extends java.lang.Object

Author:
Charles Ames

Constructor Summary
MidiNote(MidiTrack midiTrack, long onTicks, long offTicks)
          Simple constructor for MidiNote instances.
MidiNote(MidiTrack midiTrack, long onTicks, long offTicks, int bank, int program, int velocity, int key)
          Extended constructor for MidiNote instances.
 
Method Summary
 MidiNote copy(MidiTrack midiTrack)
          Create a new note in the specified MIDI track and copy this note's attributes to the new note.
 void createAfterTouchEvent(long ticks, int pressure)
          Create a MIDI after touch event.
 void createNoteEvents()
          Generate MIDI note on and MIDI note off events.
 void createProgramChangeEvent()
          Generate program change events for MIDI bank and MIDI program, whichever has actually changed on the channel.
 int getBank()
          Get the MIDI bank.
 int getKey()
          Get the MIDI key number.
 MidiChannel getMidiChannel()
          Get the MIDI channel.
 long getOffTicks()
          Get the note end time in ticks.
 int getOnsetPitchBend()
          Get the pitch bend at the onset of the note.
 long getOnTicks()
          Get the note start time in ticks.
 int getProgram()
          Get the MIDI program.
 int getReleasePitchBend()
          Get the pitch bend at the release of the note
 MidiTrack getTrack()
          Get the MidiTrack instance that hold the note.
 int getVelocity()
          Get the MIDI velocity.
 void interpolatePitchBend()
          Create a sequence of MIDI pitch-bend events over the duration of the note that plot a line from the onset value to the relase value.
 void setBank(int bank)
          Set the MIDI bank.
 void setKey(int key)
          Set the MIDI key number.
 void setMidiChannel(MidiChannel midiChannel)
          Set the MIDI channel.
 void setOriginPitchBend(int originPitchBend)
          Set the pitch bend at the onset of the note.
 void setProgram(int program)
          Set the MIDI program
 void setReleasePitchBend(int goalPitchBend)
          Set the pitch bend at the release of the note
 void setVelocity(int velocity)
          Set the MIDI velocity.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MidiNote

public MidiNote(MidiTrack midiTrack,
                long onTicks,
                long offTicks)
Simple constructor for MidiNote instances.

Parameters:
midiTrack - The MidiTrack instance that hold the note.
onTicks - The note start time in ticks.
offTicks - The note end time in ticks.

MidiNote

public MidiNote(MidiTrack midiTrack,
                long onTicks,
                long offTicks,
                int bank,
                int program,
                int velocity,
                int key)
Extended constructor for MidiNote instances.

Parameters:
midiTrack - The MidiTrack instance that hold the note.
onTicks - The note start time in ticks.
offTicks - The note end time in ticks.
bank -
program -
velocity -
key -
Method Detail

getTrack

public MidiTrack getTrack()
Get the MidiTrack instance that hold the note.

Returns:
The MidiTrack instance that hold the note.

getOnTicks

public long getOnTicks()
Get the note start time in ticks.

Returns:
The note start time in ticks.

getOffTicks

public long getOffTicks()
Get the note end time in ticks.

Returns:
The note end time in ticks.

getMidiChannel

public MidiChannel getMidiChannel()
Get the MIDI channel.

Returns:
A MidiChannel instance.

setMidiChannel

public void setMidiChannel(MidiChannel midiChannel)
Set the MIDI channel.

Parameters:
midiChannel - A MidiChannel instance.

getBank

public int getBank()
Get the MIDI bank.

Returns:
The current MIDI bank.

setBank

public void setBank(int bank)
Set the MIDI bank.

Parameters:
bank - The intended MIDI Bank.

getProgram

public int getProgram()
Get the MIDI program.

Returns:
The current MIDI program (1-128)

setProgram

public void setProgram(int program)
Set the MIDI program

Parameters:
program - The intended MIDI program (1-128).

getVelocity

public int getVelocity()
Get the MIDI velocity.

Returns:
The MIDI current velocity (0-127).

setVelocity

public void setVelocity(int velocity)
Set the MIDI velocity.

Parameters:
velocity - The intended MIDI velocity (0-127).

getKey

public int getKey()
Get the MIDI key number.

Returns:
The current MIDI key number (60 is middle C).

setKey

public void setKey(int key)
Set the MIDI key number.

Parameters:
key - The inteded MIDI key number (60 is middle C).

getOnsetPitchBend

public int getOnsetPitchBend()
Get the pitch bend at the onset of the note.

Returns:
The current onset pitch bend.

setOriginPitchBend

public void setOriginPitchBend(int originPitchBend)
Set the pitch bend at the onset of the note.

Parameters:
originPitchBend - The intended onset pitch bend.

getReleasePitchBend

public int getReleasePitchBend()
Get the pitch bend at the release of the note

Returns:
The current release pitch bend.

setReleasePitchBend

public void setReleasePitchBend(int goalPitchBend)
Set the pitch bend at the release of the note

Parameters:
goalPitchBend -

copy

public MidiNote copy(MidiTrack midiTrack)
Create a new note in the specified MIDI track and copy this note's attributes to the new note.

Parameters:
midiTrack - The specified MIDI track.
Returns:
The newly created MidiNote instance.

createNoteEvents

public void createNoteEvents()
                      throws javax.sound.midi.InvalidMidiDataException
Generate MIDI note on and MIDI note off events.

Throws:
javax.sound.midi.InvalidMidiDataException

createProgramChangeEvent

public void createProgramChangeEvent()
                              throws javax.sound.midi.InvalidMidiDataException
Generate program change events for MIDI bank and MIDI program, whichever has actually changed on the channel.

Throws:
javax.sound.midi.InvalidMidiDataException

createAfterTouchEvent

public void createAfterTouchEvent(long ticks,
                                  int pressure)
                           throws javax.sound.midi.InvalidMidiDataException
Create a MIDI after touch event.

Parameters:
ticks - The event time.
pressure - The after-touch value.
Throws:
javax.sound.midi.InvalidMidiDataException

interpolatePitchBend

public void interpolatePitchBend()
                          throws javax.sound.midi.InvalidMidiDataException
Create a sequence of MIDI pitch-bend events over the duration of the note that plot a line from the onset value to the relase value.

Throws:
javax.sound.midi.InvalidMidiDataException