Package org.jfugue.rhythm
Class Rhythm
java.lang.Object
org.jfugue.rhythm.Rhythm
- All Implemented Interfaces:
PatternProducer
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddAltLayerProvider
(int layer, RhythmAltLayerProvider altLayerProvider) Gives a RhythmAltLayerProvider, which will make its own determination about what type of alt layer to play, and when to play it.addAltLayerProvider
(int layer, RhythmAltLayerProvider altLayerProvider, int zOrder) Gives a RhythmAltLayerProvider, which will make its own determination about what type of alt layer to play, and when to play it.Adds a layer to this Rhythm, but fails silently if the rhythm already has MAX_LAYERS layers.addOneTimeAltLayer
(int layer, int oneTime, String rhythmString) Sets an alt layer that will play one time, at the given segment.addOneTimeAltLayer
(int layer, int oneTime, String rhythmString, int zOrder) Sets an alt layer that will play one time, at the given segment.addRangedAltLayer
(int layer, int start, int end, String rhythmString) Sets an alt layer that will play between and including the start and end indices.addRangedAltLayer
(int layer, int start, int end, String rhythmString, int zOrder) Sets an alt layer that will play between and including the start and end indices.addRecurringAltLayer
(int layer, int start, int end, int recurrence, String rhythmString) Sets an alt layer that will recur every recurrence times *after* the start index is reached.addRecurringAltLayer
(int layer, int start, int end, int recurrence, String rhythmString, int zOrder) Sets an alt layer that will recur every recurrence times *after* the start index is reached.boolean
Returns true if the number of layers is less than MAX_LAYERS, which is limited to 16 by the MIDI Specificationclone()
static Rhythm
Combines rhythms into multiple layers.List
<org.jfugue.rhythm.Rhythm.AltLayer> getAltLayersForLayer
(int layer) Returns all AltLayers for the given layer; the resulting list is unsorted by z-ordergetLayer
(int layer) Returns all layers that have been added with the traditional addLayer() method - but to truly find out what the layer will sound like at a given segment, use getLayersForSegment(), which takes alt layers into account.String[]
getLayersAt
(int segment) Returns all layers, including altLayers, for the given segmentint
Returns a patterngetPatternAt
(int segment) String[]
Returns the full rhythm, including alt layers, but not translated into Staccato music strings by looking up rhythm entries into the RhythmKitList
<org.jfugue.rhythm.Rhythm.AltLayer> getSortedAltLayersForLayer
(int layer) Returns all AltLayers for the given layer sorted by each AltLayer's z-ordergetStaccatoStringForRhythm
(String rhythm) Uses the RhythmKit to translate the given rhythm into a Staccato music string.Sets all of the layerssetLength
(int length) Sets the length of the rhythm, which is the number of times that a single pattern is repeated.setRhythmKit
(Map<Character, String> rhythmKit)
-
Field Details
-
DEFAULT_RHYTHM_KIT
-
-
Constructor Details
-
Rhythm
public Rhythm() -
Rhythm
-
Rhythm
-
Rhythm
-
-
Method Details
-
setRhythmKit
-
getRhythmKit
-
addLayer
Adds a layer to this Rhythm, but fails silently if the rhythm already has MAX_LAYERS layers.- Parameters:
layer
-- Returns:
-
getLayer
-
getLayers
Returns all layers that have been added with the traditional addLayer() method - but to truly find out what the layer will sound like at a given segment, use getLayersForSegment(), which takes alt layers into account.- See Also:
-
setLayers
Sets all of the layers -
getLayersAt
Returns all layers, including altLayers, for the given segment- See Also:
-
canAddLayer
public boolean canAddLayer()Returns true if the number of layers is less than MAX_LAYERS, which is limited to 16 by the MIDI Specification- Returns:
-
clone
-
getAltLayersForLayer
Returns all AltLayers for the given layer; the resulting list is unsorted by z-order- See Also:
-
getSortedAltLayersForLayer
Returns all AltLayers for the given layer sorted by each AltLayer's z-order -
addRecurringAltLayer
public Rhythm addRecurringAltLayer(int layer, int start, int end, int recurrence, String rhythmString) Sets an alt layer that will recur every recurrence times *after* the start index is reached. If the start index is 2 and the recurrence is 5, this alt layer will be used every time the segment % recurrence == start. By default, this has a Z-Order of 1. -
addRecurringAltLayer
public Rhythm addRecurringAltLayer(int layer, int start, int end, int recurrence, String rhythmString, int zOrder) Sets an alt layer that will recur every recurrence times *after* the start index is reached. If the start index is 2 and the recurrence is 5, this alt layer will be used every time the segment % recurrence == start -
addRangedAltLayer
Sets an alt layer that will play between and including the start and end indices. By default, this has a Z-Order of 2. -
addRangedAltLayer
Sets an alt layer that will play between and including the start and end indices. -
addOneTimeAltLayer
Sets an alt layer that will play one time, at the given segment. By default, this has a Z-Order of 3. -
addOneTimeAltLayer
Sets an alt layer that will play one time, at the given segment. -
addAltLayerProvider
Gives a RhythmAltLayerProvider, which will make its own determination about what type of alt layer to play, and when to play it. By default, this has a Z-Order of 4.- See Also:
-
addAltLayerProvider
Gives a RhythmAltLayerProvider, which will make its own determination about what type of alt layer to play, and when to play it.- See Also:
-
combine
Combines rhythms into multiple layers. If there are more than MAX_LAYERS layers in the provided rhythms, only the first MAX_LAYERS are used (for example, if you pass five rhythms that each have four layers, the combined rhythm will only contain the layers from the first four rhythms). This method also ensures that the Rhythm Kit for each of the provided Rhythms is added to the return value's Rhythm Kit.- Parameters:
rhythms
- the rhythms to combine- Returns:
- the combined rhythm
-
setLength
Sets the length of the rhythm, which is the number of times that a single pattern is repeated. For example, creating a layer of "S...S...S...O..." and a length of 3 would result in a Rhythm pattern of "S...S...S...O...S...S...S...O...S...S...S...O..." -
getLength
public int getLength() -
getStaccatoStringForRhythm
Uses the RhythmKit to translate the given rhythm into a Staccato music string.- See Also:
-
getPatternAt
-
getPattern
Description copied from interface:PatternProducer
Returns a pattern- Specified by:
getPattern
in interfacePatternProducer
-
getRhythm
Returns the full rhythm, including alt layers, but not translated into Staccato music strings by looking up rhythm entries into the RhythmKit- Returns:
-