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.ArrayList<java.util.TreeMap<java.lang.Long,java.util.TreeMap<java.lang.Long,java.lang.String>>> |
inlineBlockTimelines
Timeline for inline blocks for events other than notes/chords.
|
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.lang.String>> |
sliceBeginBlockTimelines
Timelines for blocks at a slice’s beginnning with events other than notes/chords.
|
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 an orphaned syllable to a special timeline.
|
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.
|
java.util.TreeMap<java.lang.Long,java.lang.String> |
getInlineBlockTimeline(byte channel,
long tick)
Returns the timeline for the requested inline block.
|
java.util.TreeMap<java.lang.Long,java.lang.String> |
getSliceBeginBlockTimeline(byte channel)
Returns the timeline for the slice begin block for the given channel.
|
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.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 |
hasSliceBeginBlock(byte channel)
Determins if the slice contains a slice begin block for the given channel.
|
void |
setEndTick(long endTick)
Sets the end tick of the slice.
|
java.lang.String |
toString()
Contains begin and 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.ArrayList<java.util.TreeMap<java.lang.Long,java.lang.String>> sliceBeginBlockTimelines
Timelines for blocks at a slice’s beginnning with events other than notes/chords.
Used for orphaned syllables (and in the future control changes).
private java.util.ArrayList<java.util.TreeMap<java.lang.Long,java.util.TreeMap<java.lang.Long,java.lang.String>>> inlineBlockTimelines
Timeline for inline blocks for events other than notes/chords.
Used for orphaned syllables (and in the future control changes).
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 hasSliceBeginBlock(byte channel)
Determins if the slice contains a slice begin block for the given channel.
That means, there are orphaned syllables or control changes, related to the channel.
channel
- MIDI channelpublic 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 an orphaned syllable to a special timeline.
This will later be used as an option to a rest command inside a nestable block.
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_BLOCK
or Decompiler.SLICE_BEGIN_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> getSliceBeginBlockTimeline(byte channel)
Returns the timeline for the slice begin block for the given channel.
This timeline may contain orphaned syllables or control changes, related to the channel.
channel
- MIDI channelpublic java.util.TreeMap<java.lang.Long,java.lang.String> getInlineBlockTimeline(byte channel, long tick)
Returns the timeline for the requested inline block.
channel
- MIDI channeltick
- begin tick of the inline blockpublic 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)public java.lang.String toString()
Contains begin and end tick of the slice.
Only used for debugging purposes.
toString
in class java.lang.Object