public class Slice
extends java.lang.Object
This class is used by the MidicaPlExporter to store a sequence slice.
A slice is a part of a sequence, beginning either in tick 0 or with a global command.
It ends either with the next global command or at the end of the sequence.
Modifier and Type | Field and Description |
---|---|
private long |
beginTick |
private long |
endTick |
private java.util.TreeMap<java.lang.String,java.lang.String> |
globalCommands |
private java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Long,java.util.TreeMap<java.lang.Byte,java.lang.Byte>>> |
noteHistory |
private java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Long,java.lang.Boolean>>> |
noteOnOff |
private java.util.TreeMap<java.lang.Long,java.lang.String> |
syllableRestTimeline
Timeline for rests that are only there for syllables.
|
private java.util.ArrayList<java.util.TreeMap<java.lang.Long,java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.String,java.util.TreeMap<java.lang.Byte,java.lang.String>>>>> |
timelines
The timelines have the following structure:
channel – tick – type – name – property – value
For instrument changes:
channel
tick
type = ET_INSTR
name = null
For notes or chords:
channel
tick
type: ET_INSTR or ET_NOTES
name: note or chord name
property: VELOCITY, OFF_TICK, LENGTH, …
value
|
Constructor and Description |
---|
Slice(long beginTick)
Creates a new sequence slice.
|
Modifier and Type | Method and Description |
---|---|
void |
addGlobalCmd(java.lang.String key,
java.lang.String value)
Adds a global command to be put at the begin tick of the slice.
|
void |
addInstrChange(long tick,
int channel)
Adds an instrument change to the given channel’s timeline.
|
void |
addNotesToTimeline(long tick,
byte channel,
java.util.TreeMap<java.lang.String,java.util.TreeMap<java.lang.Byte,java.lang.String>> notesOrChords)
Adds the given notes and/or chords to the channel’s timeline.
|
void |
addSyllableRest(long tick,
java.lang.String syllable,
byte channel,
byte orphaned,
long resolution)
Adds a lyrics syllable as an option to a rest command.
|
private void |
addToTimeline(long tick,
int channel,
byte key,
java.util.TreeMap<java.lang.String,java.util.TreeMap<java.lang.Byte,java.lang.String>> notesOrChords)
Adds something to a channel’s timeline.
|
java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Long,java.util.TreeMap<java.lang.Byte,java.lang.Byte>>> |
filterNotes(java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Long,java.util.TreeMap<java.lang.Byte,java.lang.Byte>>> noteHistory)
Copies the given structure to the slice, omitting all entries that are not related to the slice’s tick scope.
|
java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Long,java.lang.Boolean>>> |
filterOnOff(java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Long,java.lang.Boolean>>> noteOnOff)
Copies the given structure to the slice, omitting all entries that are not related to the slice’s tick scope.
|
long |
getBeginTick()
Returns the begin tick of the slice.
|
long |
getEndTick()
Returns the end tick of the slice, or -1, if an end tick has not yet been set.
|
java.util.TreeMap<java.lang.String,java.lang.String> |
getGlobalCommands()
Returns the global commands from the beginning of the slice.
|
static Slice |
getSliceByTick(java.util.ArrayList<Slice> slices,
long tick)
Returns the slice belonging to the given tick.
|
java.util.TreeMap<java.lang.Long,java.lang.String> |
getSyllableRestTimeline()
Returns the special timeline only for rests with syllables.
|
java.util.TreeMap<java.lang.Long,java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.String,java.util.TreeMap<java.lang.Byte,java.lang.String>>>> |
getTimeline(int channel)
Returns the timeline for the given channel.
|
boolean |
hasSyllableRests()
Determins if the slice contains rests with syllables.
|
void |
setEndTick(long endTick)
Sets the end tick of the slice.
|
private long beginTick
private long endTick
private java.util.TreeMap<java.lang.String,java.lang.String> globalCommands
private java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Long,java.util.TreeMap<java.lang.Byte,java.lang.Byte>>> noteHistory
private java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Long,java.lang.Boolean>>> noteOnOff
private java.util.ArrayList<java.util.TreeMap<java.lang.Long,java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.String,java.util.TreeMap<java.lang.Byte,java.lang.String>>>>> timelines
The timelines have the following structure:
channel – tick – type – name – property – value
For instrument changes:
For notes or chords:
private java.util.TreeMap<java.lang.Long,java.lang.String> syllableRestTimeline
Timeline for rests that are only there for syllables.
public Slice(long beginTick)
Creates a new sequence slice.
beginTick
- MIDI tick where the slice begins.public static Slice getSliceByTick(java.util.ArrayList<Slice> slices, long tick)
Returns the slice belonging to the given tick.
slices
- all slicestick
- MIDI tickpublic long getBeginTick()
Returns the begin tick of the slice.
public void setEndTick(long endTick)
Sets the end tick of the slice.
endTick
- the end tick of the slice.public long getEndTick()
Returns the end tick of the slice, or -1, if an end tick has not yet been set.
public boolean hasSyllableRests()
Determins if the slice contains rests with syllables.
public void addGlobalCmd(java.lang.String key, java.lang.String value)
Adds a global command to be put at the begin tick of the slice.
key
- ID of the global command.value
- value of the global command.public java.util.TreeMap<java.lang.String,java.lang.String> getGlobalCommands()
Returns the global commands from the beginning of the slice.
public void addInstrChange(long tick, int channel)
Adds an instrument change to the given channel’s timeline.
tick
- MIDI tickchannel
- MIDI channelpublic void addNotesToTimeline(long tick, byte channel, java.util.TreeMap<java.lang.String,java.util.TreeMap<java.lang.Byte,java.lang.String>> notesOrChords)
Adds the given notes and/or chords to the channel’s timeline.
tick
- MIDI tickchannel
- MIDI channelnotesOrChords
- all notes and chords that begin at this channel and tickpublic void addSyllableRest(long tick, java.lang.String syllable, byte channel, byte orphaned, long resolution)
Adds a lyrics syllable as an option to a rest command. This is needed if there is no note/chord being played at the tick when the syllable appears.
According to the orphaned parameter one of the following strategies is used to add the rest:
tick
- MIDI ticksyllable
- Lyrics syllable for Karaokechannel
- MIDI channelorphaned
- either Decompiler.INLINE
or Decompiler.BLOCK
resolution
- source resolution of the sequencepublic java.util.TreeMap<java.lang.Long,java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.String,java.util.TreeMap<java.lang.Byte,java.lang.String>>>> getTimeline(int channel)
Returns the timeline for the given channel.
channel
- MIDI channelpublic java.util.TreeMap<java.lang.Long,java.lang.String> getSyllableRestTimeline()
Returns the special timeline only for rests with syllables.
public java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Long,java.util.TreeMap<java.lang.Byte,java.lang.Byte>>> filterNotes(java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Long,java.util.TreeMap<java.lang.Byte,java.lang.Byte>>> noteHistory)
Copies the given structure to the slice, omitting all entries that are not related to the slice’s tick scope. Returns the copied (filtered) structure.
An entry is copied, if:
noteHistory
- structure containing channel, tick, note and velocitypublic java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Long,java.lang.Boolean>>> filterOnOff(java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Long,java.lang.Boolean>>> noteOnOff)
Copies the given structure to the slice, omitting all entries that are not related to the slice’s tick scope. Returns the copied (filtered) structure.
An entry is copied, if:
noteOnOff
- structure containing channel, tick, note and on/offprivate void addToTimeline(long tick, int channel, byte key, java.util.TreeMap<java.lang.String,java.util.TreeMap<java.lang.Byte,java.lang.String>> notesOrChords)
Adds something to a channel’s timeline. This ‘something’ can be one of:
tick
- MIDI tickchannel
- MIDI channelkey
- ID of the eventnotesOrChords
- all notes and chords that begin at this channel and tick (or null in case of an instrument change marker)