Package org.jjazz.songcontext.api
Class SongContext
java.lang.Object
org.jjazz.songcontext.api.SongContext
- Direct Known Subclasses:
SongContextCopy
,SongPartContext
Collect various data about a Song context in order to facilitate music generation.
Note that a SongContext instance should be discarded if song is structurally modified, because some SongContext methods may return data not consistent anymore with the actual Song.
-
Constructor Summary
ConstructorDescriptionSongContext
(Song s, MidiMix mm) Create a SongContext object for the whole song.SongContext
(Song s, MidiMix mm, IntRange bars) Create a SongContext object for whole or part of a song.SongContext
(SongContext sgContext, IntRange newRange) Create a SongContext which reuse sgContext's Song and MidiMix, but with the specified range. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Clone the SongContext reusing the same song and midi mix.boolean
Check if the specified spt has at least one bar in the range of this context.deepClone
(boolean register) Deep clone the SongContext : make a copy of the song and the midimix.boolean
Music should be produced only for this range of bars.The range (computed at the time of this object creation) for which music should be produced.Music should be produced for this MidiMix.getSong()
Music should be produced for this song.Get all the song parts (at the time of this object creation) which are contained in this context.getSptBarRange
(SongPart spt) Get the intersection between the song part bar range and this SongContext bar range.getSptBeatRange
(SongPart spt) Get the intersection between the song part beat range and this SongContext beat range.getSptTickRange
(SongPart spt) Get the range of ticks of spt belonging to this context.The tick range (computed at the time of this object creation) corresponding to getBarRange() or getBeatRange().Get the list of unique rhythms used in this context.Get the list of unique rhythm voices used in this context.int
hashCode()
toClsPosition
(long relativeTick) Converts a tick position relative to this context into a ChordLeadSheet Position.toPosition
(long relativeTick) Converts a tick position relative to this context into an absolute SongStructure Position.float
toPositionInBeats
(long relativeTick) Converts a tick position relative to this context into an absolute SongStructure position in beats.long
toRelativeTick
(Position pos) Compute the tick relative to this context for the given absolute position expressed in bar/beat.toString()
-
Constructor Details
-
SongContext
Create a SongContext object for the whole song.- Parameters:
s
-mm
-
-
SongContext
Create a SongContext which reuse sgContext's Song and MidiMix, but with the specified range.- Parameters:
sgContext
-newRange
-
-
SongContext
Create a SongContext object for whole or part of a song.- Parameters:
s
-mm
-bars
- If null, the range will represent the whole song from first to last bar.
-
-
Method Details
-
clone
Clone the SongContext reusing the same song and midi mix.- Returns:
-
deepClone
Deep clone the SongContext : make a copy of the song and the midimix.- Parameters:
register
- If true the created song is registered by the SongFactory- Returns:
- See Also:
-
getSong
Music should be produced for this song.- Returns:
-
getMidiMix
Music should be produced for this MidiMix.- Returns:
-
getBarRange
Music should be produced only for this range of bars.The range can start/end anywhere in the song (including in the middle of a song part).
- Returns:
-
getBeatRange
The range (computed at the time of this object creation) for which music should be produced.The range can start/end anywhere in the song (including in the middle of a song part). If getBarRange().from > 0 then toBeatRange().from is also > 0.
- Returns:
-
getTickRange
The tick range (computed at the time of this object creation) corresponding to getBarRange() or getBeatRange().The range can start/end anywhere in the song (including in the middle of a song part). If toBeatRange().from > 0 then getTickRange().from is also > 0.
- Returns:
-
getSongParts
Get all the song parts (at the time of this object creation) which are contained in this context.- Returns:
- Can be empty.
- See Also:
-
getSptBarRange
Get the intersection between the song part bar range and this SongContext bar range.- Parameters:
spt
-- Returns:
- Can be the EMPTY_RANGE if spt is not part of this context.
-
getSptBeatRange
Get the intersection between the song part beat range and this SongContext beat range.- Parameters:
spt
-- Returns:
-
getSptTickRange
Get the range of ticks of spt belonging to this context.- Parameters:
spt
-- Returns:
-
contains
Check if the specified spt has at least one bar in the range of this context.- Parameters:
spt
-- Returns:
-
getUniqueRhythms
Get the list of unique rhythms used in this context.- Returns:
-
getUniqueRhythmVoices
Get the list of unique rhythm voices used in this context.- Returns:
-
toPosition
Converts a tick position relative to this context into an absolute SongStructure Position.- Parameters:
relativeTick
- 0 for the start of this context bar range.- Returns:
- Null if tick is out of the bounds of this context.
-
toPositionInBeats
public float toPositionInBeats(long relativeTick) Converts a tick position relative to this context into an absolute SongStructure position in beats.- Parameters:
relativeTick
- 0 for the start of this context bar range.- Returns:
- -1 if tick is out of the bounds of this context.
-
toClsPosition
Converts a tick position relative to this context into a ChordLeadSheet Position.- Parameters:
relativeTick
-- Returns:
- Null if tick is out of the bounds of this context.
-
toRelativeTick
Compute the tick relative to this context for the given absolute position expressed in bar/beat.- Parameters:
pos
-- Returns:
- -1 if pos is outside this context range. Returns 0 for the first bar/beat of the context range.
-
hashCode
public int hashCode() -
equals
-
toString
-