Package org.jfugue.realtime
Class RealtimeMidiParserListener
- java.lang.Object
-
- org.jfugue.midi.TrackTimeManager
-
- org.jfugue.realtime.RealtimeMidiParserListener
-
- All Implemented Interfaces:
ParserListener
public class RealtimeMidiParserListener extends TrackTimeManager implements ParserListener
The callbacks in RealtimeMidiParserListener are only called when a user sends a Pattern to the RealtimePlayer. Otherwise, individual events like "note on" or "change instrument" are handled by RealtimePlayer itself. When this listener receives an event from the parser, it schedules the event with a command that will execute directly on the RealtimePlayer.
-
-
Constructor Summary
Constructors Constructor Description RealtimeMidiParserListener(RealtimePlayer player)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterParsingFinished()Called when the parser has parsed its last item.voidbeforeParsingStarts()Called when the parser first starts up, but before it starts parsing anything.voidfinish()longgetCurrentTime()RealtimePlayergetRealtimePlayer()voidonBarLineParsed(long time)The separator character which indicates a bar line has been parsed.voidonChannelPressureParsed(byte pressure)voidonChordParsed(Chord chord)voidonControllerEventParsed(byte controller, byte value)voidonEventScheduled(long timeInMillis, ScheduledEvent event)voidonEventUnscheduled(long timeInMillis, ScheduledEvent event)voidonFunctionParsed(java.lang.String id, java.lang.Object message)voidonInstrumentParsed(byte instrument)Called when the parser encounters a new instrument selection.voidonInterpolatorStarted(RealtimeInterpolator interpolator, long durationInMillis)voidonInterpolatorStopping(RealtimeInterpolator interpolator)voidonKeySignatureParsed(byte key, byte scale)voidonLayerChanged(byte layer)Called when the parser encounters a new layer.voidonLyricParsed(java.lang.String lyric)voidonMarkerParsed(java.lang.String marker)voidonNoteParsed(Note note)We may have actually parsed a musical note! In previous versions of JFugue, ParserListener had separate listeners for parallel notes and sequential notes (now termed harmonic and melodic notes, respectively) In this version of JFugue, whether a note is the first note, a harmonic note, or a melodic note is kept as a property on the Note object itself.voidonNotePressed(Note note)Used to indicate when a note is pressed.voidonNoteReleased(Note note)Used to indicate when a note is released.voidonPitchWheelParsed(byte lsb, byte msb)voidonPolyphonicPressureParsed(byte key, byte pressure)voidonSystemExclusiveParsed(byte... bytes)voidonTempoChanged(int tempoBPM)Called when the parser encounters a new tempo selection.voidonTimeSignatureParsed(byte numerator, byte powerOfTwo)The first parameter is the number of beats per measure; The second parameter is the power by which 2 must be raised to create the note that represents one beat.voidonTrackBeatTimeBookmarked(java.lang.String timeBookmarkID)voidonTrackBeatTimeBookmarkRequested(java.lang.String timeBookmarkID)voidonTrackBeatTimeRequested(double time)voidonTrackChanged(byte track)Called when the parser encounters a new track (also known as a channel; previously in JFugue, known as a Voice).voidscheduleCommand(long timeInMillis, org.jfugue.realtime.RealtimeMidiParserListener.Command command)voidscheduleEvent(long timeInMillis, ScheduledEvent event)voidunscheduleEvent(long timeInMillis, ScheduledEvent event)-
Methods inherited from class org.jfugue.midi.TrackTimeManager
addTrackTickTimeBookmark, advanceTrackBeatTime, createTrack, getCurrentLayerNumber, getCurrentTrackNumber, getInitialNoteBeatTimeForHarmonicNotes, getLastCreatedTrackNumber, getLatestTrackBeatTime, getTrackBeatTime, getTrackBeatTimeBookmark, setAllTrackBeatTime, setCurrentLayerNumber, setCurrentTrack, setInitialNoteBeatTimeForHarmonicNotes, setTrackBeatTime
-
-
-
-
Constructor Detail
-
RealtimeMidiParserListener
public RealtimeMidiParserListener(RealtimePlayer player) throws javax.sound.midi.MidiUnavailableException
- Throws:
javax.sound.midi.MidiUnavailableException
-
-
Method Detail
-
getCurrentTime
public long getCurrentTime()
-
finish
public void finish()
-
getRealtimePlayer
public RealtimePlayer getRealtimePlayer()
-
scheduleCommand
public void scheduleCommand(long timeInMillis, org.jfugue.realtime.RealtimeMidiParserListener.Command command)
-
scheduleEvent
public void scheduleEvent(long timeInMillis, ScheduledEvent event)
-
unscheduleEvent
public void unscheduleEvent(long timeInMillis, ScheduledEvent event)
-
beforeParsingStarts
public void beforeParsingStarts()
Description copied from interface:ParserListenerCalled when the parser first starts up, but before it starts parsing anything. Provides listeners with a chance to initialize variables and get ready for the parser events.- Specified by:
beforeParsingStartsin interfaceParserListener
-
afterParsingFinished
public void afterParsingFinished()
Description copied from interface:ParserListenerCalled when the parser has parsed its last item. Provides listeners with a chance to clean up.- Specified by:
afterParsingFinishedin interfaceParserListener
-
onTrackChanged
public void onTrackChanged(byte track)
Description copied from interface:ParserListenerCalled when the parser encounters a new track (also known as a channel; previously in JFugue, known as a Voice). Tracks correspond to MIDI tracks/channels.- Specified by:
onTrackChangedin interfaceParserListener- Parameters:
track- the new track event that has been parsed
-
onLayerChanged
public void onLayerChanged(byte layer)
Description copied from interface:ParserListenerCalled when the parser encounters a new layer. A layer deals with polyphony within a track. While any track may have layers, layers are intended for use with the percussion track, where each layer may represent notes for a specific percussive instrument. Layers can essentially be thought of as a "track within a track." Each layer maintains its own time progression, so "L1 Eq Eq L2 Cq Gq" would be the same as saying "Eq+Cq Eq+Gq". Layers are a JFugue feature, and are not a part of the MIDI specification.- Specified by:
onLayerChangedin interfaceParserListener
-
onInstrumentParsed
public void onInstrumentParsed(byte instrument)
Description copied from interface:ParserListenerCalled when the parser encounters a new instrument selection.- Specified by:
onInstrumentParsedin interfaceParserListener- Parameters:
instrument- the MIDI instrument value that has been parsed
-
onTempoChanged
public void onTempoChanged(int tempoBPM)
Description copied from interface:ParserListenerCalled when the parser encounters a new tempo selection.- Specified by:
onTempoChangedin interfaceParserListener- Parameters:
tempoBPM- The new tempo value
-
onKeySignatureParsed
public void onKeySignatureParsed(byte key, byte scale)- Specified by:
onKeySignatureParsedin interfaceParserListener
-
onTimeSignatureParsed
public void onTimeSignatureParsed(byte numerator, byte powerOfTwo)Description copied from interface:ParserListenerThe first parameter is the number of beats per measure; The second parameter is the power by which 2 must be raised to create the note that represents one beat. Example 1: For a 5/8 time signature, expect 5,3 (since 2^3 = 8) Example 2: For a 4/4 time signature, expect 4,2 (since 2^2 = 4)- Specified by:
onTimeSignatureParsedin interfaceParserListener
-
onBarLineParsed
public void onBarLineParsed(long time)
Description copied from interface:ParserListenerThe separator character which indicates a bar line has been parsed. Generally, you will want to care about this if you're counting measures, but this should have no effect on the rendering of a parsed piece of music.- Specified by:
onBarLineParsedin interfaceParserListener- Parameters:
time- This is the id of the measure, which is an optional numeric value following the bar character.
-
onTrackBeatTimeBookmarked
public void onTrackBeatTimeBookmarked(java.lang.String timeBookmarkID)
- Specified by:
onTrackBeatTimeBookmarkedin interfaceParserListener
-
onTrackBeatTimeBookmarkRequested
public void onTrackBeatTimeBookmarkRequested(java.lang.String timeBookmarkID)
- Specified by:
onTrackBeatTimeBookmarkRequestedin interfaceParserListener
-
onTrackBeatTimeRequested
public void onTrackBeatTimeRequested(double time)
- Specified by:
onTrackBeatTimeRequestedin interfaceParserListener
-
onPitchWheelParsed
public void onPitchWheelParsed(byte lsb, byte msb)- Specified by:
onPitchWheelParsedin interfaceParserListener
-
onChannelPressureParsed
public void onChannelPressureParsed(byte pressure)
- Specified by:
onChannelPressureParsedin interfaceParserListener
-
onPolyphonicPressureParsed
public void onPolyphonicPressureParsed(byte key, byte pressure)- Specified by:
onPolyphonicPressureParsedin interfaceParserListener
-
onSystemExclusiveParsed
public void onSystemExclusiveParsed(byte... bytes)
- Specified by:
onSystemExclusiveParsedin interfaceParserListener
-
onControllerEventParsed
public void onControllerEventParsed(byte controller, byte value)- Specified by:
onControllerEventParsedin interfaceParserListener
-
onLyricParsed
public void onLyricParsed(java.lang.String lyric)
- Specified by:
onLyricParsedin interfaceParserListener
-
onMarkerParsed
public void onMarkerParsed(java.lang.String marker)
- Specified by:
onMarkerParsedin interfaceParserListener
-
onFunctionParsed
public void onFunctionParsed(java.lang.String id, java.lang.Object message)- Specified by:
onFunctionParsedin interfaceParserListener
-
onNotePressed
public void onNotePressed(Note note)
Description copied from interface:ParserListenerUsed to indicate when a note is pressed. Used in realtime cases when notes are actually being pressed and released. Parsers that do not operate in realtime are not expected to report onNotePressed. Expect the Note event to contain only the note number and note-on velocity.- Specified by:
onNotePressedin interfaceParserListener
-
onNoteReleased
public void onNoteReleased(Note note)
Description copied from interface:ParserListenerUsed to indicate when a note is released. Used in realtime cases when notes are actually being pressed and released. Parsers that do not operate in realtime are not expected to report onNoteReleased. Expect the Note event to contain only the note number and note-off velocity. Duration may not be set on the Note from onNoteReleased.- Specified by:
onNoteReleasedin interfaceParserListener
-
onNoteParsed
public void onNoteParsed(Note note)
Description copied from interface:ParserListenerWe may have actually parsed a musical note! In previous versions of JFugue, ParserListener had separate listeners for parallel notes and sequential notes (now termed harmonic and melodic notes, respectively) In this version of JFugue, whether a note is the first note, a harmonic note, or a melodic note is kept as a property on the Note object itself.- Specified by:
onNoteParsedin interfaceParserListener- Parameters:
note- The note that was parsed. Please see the Note class for more details about notes!- See Also:
Note
-
onChordParsed
public void onChordParsed(Chord chord)
- Specified by:
onChordParsedin interfaceParserListener
-
onEventScheduled
public void onEventScheduled(long timeInMillis, ScheduledEvent event)
-
onEventUnscheduled
public void onEventUnscheduled(long timeInMillis, ScheduledEvent event)
-
onInterpolatorStarted
public void onInterpolatorStarted(RealtimeInterpolator interpolator, long durationInMillis)
-
onInterpolatorStopping
public void onInterpolatorStopping(RealtimeInterpolator interpolator)
-
-