Package org.jfugue.pattern
Class Pattern
java.lang.Object
org.jfugue.pattern.Pattern
- All Implemented Interfaces:
PatternProducer
,TokenProducer
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd
(PatternProducer... producers) add
(PatternProducer producer, int repetitions) addToEachNoteToken
(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.atomize()
Turns the given pattern into a pattern of Voice-Instrument-Note atomsclear()
Returns a patternstatic Pattern
measure
(ParserListener listener) Parse this pattern and have the given ParserListener listen to it.Inserts the given string to the beginning of this 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".repeat
(int n) 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.setInstrument
(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.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.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.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.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.toString()
transform
(ParserListener listener) Parse this pattern and have the given ParserListener listen to it.
-
Field Details
-
patternSB
-
-
Constructor Details
-
Pattern
public Pattern() -
Pattern
-
Pattern
-
Pattern
-
-
Method Details
-
add
-
add
-
add
-
add
-
prepend
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
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. -
clear
-
repeat
-
atomize
Turns the given pattern into a pattern of Voice-Instrument-Note atoms- Returns:
- this pattern for method chaining
-
getPattern
Description copied from interface:PatternProducer
Returns a pattern- Specified by:
getPattern
in interfacePatternProducer
-
getTokens
- Specified by:
getTokens
in interfaceTokenProducer
-
toString
-
setTempo
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
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
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
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
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
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
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
- Throws:
IOException
-
save
- Throws:
IOException
-
load
- Throws:
IOException
-
transform
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
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.
-