abc4j API Specification

abc.midi
Class MidiConverterAbstract

java.lang.Object
  extended by abc.midi.MidiConverterAbstract
All Implemented Interfaces:
MidiConverterInterface
Direct Known Subclasses:
BasicMidiConverter

public abstract class MidiConverterAbstract
extends java.lang.Object
implements MidiConverterInterface

MidiConverter class defines various static methods to convert abc related stuff to midi : notes, tunes etc...


Constructor Summary
MidiConverterAbstract()
           
 
Method Summary
 javax.sound.midi.Instrument getInstrument()
          Returns the instrument currently used for sequence playback.
abstract  javax.sound.midi.MidiMessage[] getMidiMessagesFor(Tempo tempo)
          Returns the corresponding midi events for a tempo change.
static byte getMidiNoteNumber(Note note, KeySignature key)
          Returns the midi note number corresponding a note in the given key.
static long getNoteLengthInTicks(MultiNote note)
          Returns the length of the multi note in ticks.
abstract  javax.sound.midi.MidiMessage[] getNoteOffMessageFor(Note note, KeySignature key)
           
abstract  javax.sound.midi.MidiMessage[] getNoteOneMessageFor(Note note, KeySignature key)
           
 void setInstrument(javax.sound.midi.Instrument instr)
          Sets the instrument to be used for sequence playback.
 javax.sound.midi.Sequence toMidiSequence(Tune tune)
          Converts the given tune to a midi sequence.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MidiConverterAbstract

public MidiConverterAbstract()
Method Detail

toMidiSequence

public javax.sound.midi.Sequence toMidiSequence(Tune tune)
Converts the given tune to a midi sequence.

Specified by:
toMidiSequence in interface MidiConverterInterface
Parameters:
tune - The tune to be converted.
Returns:
The midi sequence of the tune.

getInstrument

public javax.sound.midi.Instrument getInstrument()
Returns the instrument currently used for sequence playback.

Specified by:
getInstrument in interface MidiConverterInterface
Returns:
The instrument currently used for sequence playback. Returns null if not set.

setInstrument

public void setInstrument(javax.sound.midi.Instrument instr)
                   throws javax.sound.midi.MidiUnavailableException
Sets the instrument to be used for sequence playback. This implicitly loads the given instrument.

Specified by:
setInstrument in interface MidiConverterInterface
Parameters:
instr - The instrument to be used for sequence playback.
Throws:
javax.sound.midi.MidiUnavailableException

getNoteOneMessageFor

public abstract javax.sound.midi.MidiMessage[] getNoteOneMessageFor(Note note,
                                                                    KeySignature key)
                                                             throws javax.sound.midi.InvalidMidiDataException
Throws:
javax.sound.midi.InvalidMidiDataException

getNoteOffMessageFor

public abstract javax.sound.midi.MidiMessage[] getNoteOffMessageFor(Note note,
                                                                    KeySignature key)
                                                             throws javax.sound.midi.InvalidMidiDataException
Throws:
javax.sound.midi.InvalidMidiDataException

getMidiMessagesFor

public abstract javax.sound.midi.MidiMessage[] getMidiMessagesFor(Tempo tempo)
                                                           throws javax.sound.midi.InvalidMidiDataException
Returns the corresponding midi events for a tempo change.

Throws:
javax.sound.midi.InvalidMidiDataException

getNoteLengthInTicks

public static long getNoteLengthInTicks(MultiNote note)
Returns the length of the multi note in ticks. This length is calculated from the resolution of the midi sequence manipulated internally.

Returns:
The length of the multi note in ticks : this is equal to the length of the longest note of the multi note.

getMidiNoteNumber

public static byte getMidiNoteNumber(Note note,
                                     KeySignature key)
Returns the midi note number corresponding a note in the given key.

Parameters:
note - The note.
key - The key this note should refer to for accidentals.
Returns:
The midi height of the note in the given key.

abc4j API Specification

Submit a bug or feature