Class MusicXmlParserListener

  • All Implemented Interfaces:
    ParserListener

    public class MusicXmlParserListener
    extends java.lang.Object
    implements ParserListener
    This class is used to build a MusicXML file) given a MIDI Sequence, Music String, etc.
    Author:
    E.Philip Sobolik
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void afterParsingFinished()
      Called when the parser has parsed its last item.
      void beforeParsingStarts()
      Called when the parser first starts up, but before it starts parsing anything.
      nu.xom.Document getMusicXMLDoc()
      creates the internal Document with the top-level Element.
      java.lang.String getMusicXMLString()
      creates the internal Document with the top-level Element and then creates the MusicXML file (as a string) from the internal Document
      void onBarLineParsed​(long id)
      The separator character which indicates a bar line has been parsed.
      void onChannelPressureParsed​(byte pressure)  
      void onChordParsed​(Chord chord)  
      void onControllerEventParsed​(byte controller, byte value)  
      void onFunctionParsed​(java.lang.String id, java.lang.Object message)  
      void onInstrumentParsed​(byte instrument)
      Called when the parser encounters a new instrument selection.
      void onKeySignatureParsed​(byte key, byte scale)  
      void onLayerChanged​(byte layer)
      Called when the parser encounters a new layer.
      void onLyricParsed​(java.lang.String lyric)  
      void onMarkerParsed​(java.lang.String marker)  
      void onNoteParsed​(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.
      void onNotePressed​(Note note)
      Used to indicate when a note is pressed.
      void onNoteReleased​(Note note)
      Used to indicate when a note is released.
      void onPitchWheelParsed​(byte lsb, byte msb)  
      void onPolyphonicPressureParsed​(byte key, byte pressure)  
      void onSystemExclusiveParsed​(byte... bytes)  
      void onTempoChanged​(int tempoBPM)
      Called when the parser encounters a new tempo selection.
      void onTimeSignatureParsed​(byte numerator, byte denominator)
      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.
      void onTrackBeatTimeBookmarked​(java.lang.String timeBookmarkId)  
      void onTrackBeatTimeBookmarkRequested​(java.lang.String timeBookmarkId)  
      void onTrackBeatTimeRequested​(double time)  
      void onTrackChanged​(byte track)
      Called when the parser encounters a new track (also known as a channel; previously in JFugue, known as a Voice).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MusicXmlParserListener

        public MusicXmlParserListener()
    • Method Detail

      • getMusicXMLString

        public java.lang.String getMusicXMLString()
        creates the internal Document with the top-level Element and then creates the MusicXML file (as a string) from the internal Document
        Returns:
        the completed MusicXML file as a String
      • getMusicXMLDoc

        public nu.xom.Document getMusicXMLDoc()
        creates the internal Document with the top-level Element.
        Returns:
        the completed MusicXML file as a Document
      • beforeParsingStarts

        public void beforeParsingStarts()
        Description copied from interface: ParserListener
        Called 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:
        beforeParsingStarts in interface ParserListener
      • afterParsingFinished

        public void afterParsingFinished()
        Description copied from interface: ParserListener
        Called when the parser has parsed its last item. Provides listeners with a chance to clean up.
        Specified by:
        afterParsingFinished in interface ParserListener
      • onTrackChanged

        public void onTrackChanged​(byte track)
        Description copied from interface: ParserListener
        Called 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:
        onTrackChanged in interface ParserListener
        Parameters:
        track - the new track event that has been parsed
      • onLayerChanged

        public void onLayerChanged​(byte layer)
        Description copied from interface: ParserListener
        Called 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:
        onLayerChanged in interface ParserListener
      • onInstrumentParsed

        public void onInstrumentParsed​(byte instrument)
        Description copied from interface: ParserListener
        Called when the parser encounters a new instrument selection.
        Specified by:
        onInstrumentParsed in interface ParserListener
        Parameters:
        instrument - the MIDI instrument value that has been parsed
      • onTempoChanged

        public void onTempoChanged​(int tempoBPM)
        Description copied from interface: ParserListener
        Called when the parser encounters a new tempo selection.
        Specified by:
        onTempoChanged in interface ParserListener
        Parameters:
        tempoBPM - The new tempo value
      • onTimeSignatureParsed

        public void onTimeSignatureParsed​(byte numerator,
                                          byte denominator)
        Description copied from interface: ParserListener
        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. 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:
        onTimeSignatureParsed in interface ParserListener
      • onBarLineParsed

        public void onBarLineParsed​(long id)
        Description copied from interface: ParserListener
        The 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:
        onBarLineParsed in interface ParserListener
        Parameters:
        id - This is the id of the measure, which is an optional numeric value following the bar character.
      • onFunctionParsed

        public void onFunctionParsed​(java.lang.String id,
                                     java.lang.Object message)
        Specified by:
        onFunctionParsed in interface ParserListener
      • onNotePressed

        public void onNotePressed​(Note note)
        Description copied from interface: ParserListener
        Used 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:
        onNotePressed in interface ParserListener
      • onNoteReleased

        public void onNoteReleased​(Note note)
        Description copied from interface: ParserListener
        Used 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:
        onNoteReleased in interface ParserListener
      • onNoteParsed

        public void onNoteParsed​(Note note)
        Description copied from interface: ParserListener
        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.
        Specified by:
        onNoteParsed in interface ParserListener
        Parameters:
        note - The note that was parsed. Please see the Note class for more details about notes!
        See Also:
        Note