Class Pattern

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.StringBuilder patternSB  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Pattern add​(java.lang.String string)  
      Pattern add​(java.lang.String string, int repetitions)  
      Pattern add​(PatternProducer... producers)  
      Pattern add​(PatternProducer producer, int repetitions)  
      Pattern addToEachNoteToken​(java.lang.String decoratorString)
      Expects a parameter of "note decorators" - i.e., things that are added to the end of a note, such as duration or attack/decay settings; splits the given parameter on spaces and applies each decorator to each note as it is encountered in the current pattern.
      Pattern atomize()
      Turns the given pattern into a pattern of Voice-Instrument-Note atoms
      Pattern clear()  
      Pattern getPattern()
      Returns a pattern
      java.util.List<Token> getTokens()  
      static Pattern load​(java.io.File file)  
      Pattern measure​(ParserListener listener)
      Parse this pattern and have the given ParserListener listen to it.
      Pattern prepend​(java.lang.String string)
      Inserts the given string to the beginning of this pattern.
      Pattern prepend​(PatternProducer... producers)
      Prepends each producer in the order it is passed in, so if you pass in "F F", "G G", and "E E", and the current pattern is "A A", you will get "F F G G E E A A".
      Pattern repeat​(int n)  
      Pattern save​(java.io.File file)  
      Pattern save​(java.io.File file, java.lang.String... comments)  
      Pattern setInstrument​(int instrument)
      Provides a way to explicitly set the instrument on a Pattern directly through the pattern rather than by adding text to the contents of the Pattern.
      Pattern setInstrument​(java.lang.String instrument)
      Provides a way to explicitly set the instrument on a Pattern directly through the pattern rather than by adding text to the contents of the Pattern.
      Pattern setLayer​(int layer)
      Provides a way to explicitly set the layer on a Pattern directly through the pattern rather than by adding text to the contents of the Pattern.
      Pattern setTempo​(int explicitTempo)
      Provides a way to explicitly set the tempo on a Pattern directly through the pattern rather than by adding text to the contents of the Pattern.
      Pattern setTempo​(java.lang.String tempo)
      Provides a way to explicitly set the tempo on a Pattern directly through the pattern rather than by adding text to the contents of the Pattern.
      Pattern setVoice​(int voice)
      Provides a way to explicitly set the voice on a Pattern directly through the pattern rather than by adding text to the contents of the Pattern.
      java.lang.String toString()  
      Pattern transform​(ParserListener listener)
      Parse this pattern and have the given ParserListener listen to it.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • patternSB

        protected java.lang.StringBuilder patternSB
    • Constructor Detail

      • Pattern

        public Pattern()
      • Pattern

        public Pattern​(java.lang.String string)
      • Pattern

        public Pattern​(java.lang.String... strings)
    • Method Detail

      • add

        public Pattern add​(java.lang.String string)
      • add

        public Pattern add​(java.lang.String string,
                           int repetitions)
      • prepend

        public Pattern prepend​(PatternProducer... producers)
        Prepends each producer in the order it is passed in, so if you pass in "F F", "G G", and "E E", and the current pattern is "A A", you will get "F F G G E E A A".
      • prepend

        public Pattern prepend​(java.lang.String string)
        Inserts the given string to the beginning of this pattern. If there is content in this pattern already, this method will insert a space between the given string and this pattern so the tokens remain separate.
      • repeat

        public Pattern repeat​(int n)
      • atomize

        public Pattern atomize()
        Turns the given pattern into a pattern of Voice-Instrument-Note atoms
        Returns:
        this pattern for method chaining
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • setTempo

        public Pattern setTempo​(int explicitTempo)
        Provides a way to explicitly set the tempo on a Pattern directly through the pattern rather than by adding text to the contents of the Pattern. When Pattern.toString() is called, the a tempo will be prepended to the beginning of the pattern in the form of "Tx", where x is the tempo number.
        Returns:
        this pattern
      • setTempo

        public Pattern setTempo​(java.lang.String tempo)
        Provides a way to explicitly set the tempo on a Pattern directly through the pattern rather than by adding text to the contents of the Pattern. When Pattern.toString() is called, the a tempo will be prepended to the beginning of the pattern in the form of "Tx", where x is the tempo number (even though this method takes a string as a parameter)
        Returns:
        this pattern
      • setVoice

        public Pattern setVoice​(int voice)
        Provides a way to explicitly set the voice on a Pattern directly through the pattern rather than by adding text to the contents of the Pattern. When Pattern.toString() is called, the a voice will be prepended to the beginning of the pattern after any explicit tempo and before any explicit layer in the form of "Vx", where x is the voice number
        Returns:
        this pattern
      • setLayer

        public Pattern setLayer​(int layer)
        Provides a way to explicitly set the layer on a Pattern directly through the pattern rather than by adding text to the contents of the Pattern. When Pattern.toString() is called, the a layer will be prepended to the beginning of the pattern after any explicit voice and before any explicit instrument in the form of "Lx", where x is the voice number
        Returns:
        this pattern
      • setInstrument

        public Pattern setInstrument​(int instrument)
        Provides a way to explicitly set the instrument on a Pattern directly through the pattern rather than by adding text to the contents of the Pattern. When Pattern.toString() is called, the a instrument will be prepended to the beginning of the pattern after any explicit voice in the form of "I[instrument-name]" (even though this method takes an integer as a parameter)
        Returns:
        this pattern
      • setInstrument

        public Pattern setInstrument​(java.lang.String instrument)
        Provides a way to explicitly set the instrument on a Pattern directly through the pattern rather than by adding text to the contents of the Pattern. When Pattern.toString() is called, the a instrument will be prepended to the beginning of the pattern after any explicit voice in the form of "I[instrument-name]"
        Returns:
        this pattern
      • addToEachNoteToken

        public Pattern addToEachNoteToken​(java.lang.String decoratorString)
        Expects a parameter of "note decorators" - i.e., things that are added to the end of a note, such as duration or attack/decay settings; splits the given parameter on spaces and applies each decorator to each note as it is encountered in the current pattern. If there is one decorator in the parameter, this method will apply that same decorator to all note in the pattern. If there are more notes than decorators, a counter resets to 0 and the decorators starting from the first are applied to the future notes. Examples: new Pattern("A B C").addToEachNoteToken("q") --> "Aq Bq Cq" new Pattern("A B C").addToEachNoteToken("q i") --> "Aq Bi Cq" (rolls back to q for third note) new Pattern("A B C").addToEachNoteToken("q i s") --> "Aq Bi Cs" new Pattern("A B C").addToEachNoteToken("q i s w") --> "Aq Bi Cs" (same as "q i s")
        Returns:
        this pattern
      • save

        public Pattern save​(java.io.File file)
                     throws java.io.IOException
        Throws:
        java.io.IOException
      • save

        public Pattern save​(java.io.File file,
                            java.lang.String... comments)
                     throws java.io.IOException
        Throws:
        java.io.IOException
      • load

        public static Pattern load​(java.io.File file)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • transform

        public Pattern transform​(ParserListener listener)
        Parse this pattern and have the given ParserListener listen to it. The user will need to call a function on the listener to get the result. This method returns its own class, the contents of which ARE NOT modified by this call.
      • measure

        public Pattern measure​(ParserListener listener)
        Parse this pattern and have the given ParserListener listen to it. The user will need to call a function on the listener to get the result. This method returns its own class, the contents of which ARE NOT modified by this call.