public abstract class Decompiler extends Exporter
This is the base class of all decompiling exporters, translating MIDI into something else.
Modifier and Type | Field and Description |
---|---|
protected static byte |
ALDA |
protected static boolean |
ALL_SYLLABLES_ORPHANED |
protected static long |
CHORD_NOTE_OFF_TOLERANCE |
protected static long |
CHORD_NOTE_ON_TOLERANCE |
protected static long |
CHORD_VELOCITY_TOLERANCE |
protected static java.util.TreeMap<java.lang.String,java.lang.Integer> |
chordCount
lowest note – chord count
|
protected static java.util.TreeMap<java.lang.String,java.lang.String> |
chords
comma-separated note bytes – chord name
|
protected static java.util.TreeMap<java.lang.String,java.util.ArrayList<java.lang.String>> |
chordsByBaseNote
lowest note – comma-separated note bytes (This structure is only needed for the sorting: lowest note first, then chord name)
|
protected java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Long,java.lang.String>> |
commentHistory |
protected static byte |
CTRL_CHANGE_MODE |
static boolean |
DEFAULT_ALL_SYLLABLES_ORPHANED |
static long |
DEFAULT_CHORD_NOTE_OFF_TOLERANCE |
static long |
DEFAULT_CHORD_NOTE_ON_TOLERANCE |
static long |
DEFAULT_CHORD_VELOCITY_TOLERANCE |
static byte |
DEFAULT_CTRL_CHANGE_MODE |
static float |
DEFAULT_DURATION_RATIO_TOLERANCE |
static java.lang.String |
DEFAULT_EXTRA_GLOBALS_STR |
static boolean |
DEFAULT_KARAOKE_ONE_CHANNEL |
static byte |
DEFAULT_LENGTH_STRATEGY |
static long |
DEFAULT_LENGTH_TICK_TOLERANCE |
static float |
DEFAULT_MAX_DURATION_TO_KEEP |
static long |
DEFAULT_MAX_TARGET_TICKS_ON |
static float |
DEFAULT_MIN_DURATION_TO_KEEP |
static long |
DEFAULT_MIN_TARGET_TICKS_ON |
static boolean |
DEFAULT_MUST_ADD_CONFIG |
static boolean |
DEFAULT_MUST_ADD_QUALITY_SCORE |
static boolean |
DEFAULT_MUST_ADD_STATISTICS |
static boolean |
DEFAULT_MUST_ADD_STRATEGY_STAT |
static boolean |
DEFAULT_MUST_ADD_TICK_COMMENTS |
static byte |
DEFAULT_ORPHANED_SYLLABLES |
static boolean |
DEFAULT_USE_DOTTED_NOTES |
static boolean |
DEFAULT_USE_DOTTED_RESTS |
static boolean |
DEFAULT_USE_KARAOKE |
static boolean |
DEFAULT_USE_PRE_DEFINED_CHORDS |
static boolean |
DEFAULT_USE_TRIPLETTED_NOTES |
static boolean |
DEFAULT_USE_TRIPLETTED_RESTS |
protected static float |
DURATION_RATIO_TOLERANCE |
protected static byte |
ET_INLINE_BLK |
protected static byte |
ET_INSTR |
protected static byte |
ET_NOTES |
protected static ExportResult |
exportResult |
protected static java.util.TreeSet<java.lang.Long> |
EXTRA_GLOBALS |
protected static int |
format |
static byte |
INLINE_BLOCK |
protected java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Long,java.lang.Byte[]>> |
instrumentHistory |
protected static java.util.ArrayList<Instrument> |
instrumentsByChannel
stores the current state of each channel
|
protected static java.util.TreeMap<java.lang.String,Instrument> |
instrumentsByName |
protected static boolean |
isSoftKaraoke |
protected static boolean |
KARAOKE_ONE_CHANNEL |
protected static byte |
LENGTH_STRATEGY |
protected static long |
LENGTH_TICK_TOLERANCE |
protected java.util.ArrayList<java.lang.Byte> |
lyricsChannels
channels that can be used for lyrics, sorted by priority
|
protected java.util.TreeMap<java.lang.Long,java.lang.String> |
lyricsSyllables |
protected static float |
MAX_DURATION_TO_KEEP |
protected static long |
MAX_SOURCE_TICKS_ON |
protected static long |
MAX_TARGET_TICKS_ON |
protected static byte |
MIDICA |
protected static float |
MIN_DURATION_TO_KEEP |
protected static long |
MIN_SOURCE_TICKS_ON |
protected static long |
MIN_TARGET_TICKS_ON |
protected static boolean |
MUST_ADD_CONFIG |
protected static boolean |
MUST_ADD_QUALITY_SCORE |
protected static boolean |
MUST_ADD_STATISTICS |
protected static boolean |
MUST_ADD_STRATEGY_STAT |
protected static boolean |
MUST_ADD_TICK_COMMENTS |
protected static java.lang.String |
NEW_LINE |
protected java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Long,java.util.TreeMap<java.lang.Byte,java.lang.Byte>>> |
noteHistory |
protected static java.util.TreeMap<java.lang.Long,java.lang.String> |
noteLength |
protected java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Long,java.lang.Boolean>>> |
noteOnOff |
protected static byte |
NP_DURATION |
protected static byte |
NP_END_TICK |
protected static byte |
NP_LENGTH |
protected static byte |
NP_LYRICS |
protected static byte |
NP_MULTIPLE |
protected static byte |
NP_NOTE_NUM |
protected static byte |
NP_OFF_TICK |
protected static byte |
NP_VELOCITY |
protected static byte |
ORPHANED_SYLLABLES |
protected static java.util.TreeMap<java.lang.Long,java.lang.String> |
restLength |
static byte |
SLICE_BEGIN_BLOCK |
protected static java.util.ArrayList<Slice> |
slices
Stores each slice of the sequence.
|
protected static int |
sourceResolution |
protected static byte |
STAT_NOTE_DURATIONS |
protected static byte |
STAT_NOTE_MULTIPLE |
protected static byte |
STAT_NOTE_SUMMANDS |
protected static byte |
STAT_NOTE_TRIPLETS |
protected static byte |
STAT_NOTE_VELOCITIES |
protected static byte |
STAT_NOTES |
protected static byte |
STAT_REST_SKIPPED |
protected static byte |
STAT_REST_SUMMANDS |
protected static byte |
STAT_REST_TRIPLETS |
protected static byte |
STAT_RESTS |
private static byte |
STAT_STRATEGY_DURATION |
private static byte |
STAT_STRATEGY_NEXT_ON |
private static byte |
STAT_STRATEGY_PRESS |
protected static byte |
STAT_TOTAL |
private java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Byte,java.lang.Integer>> |
statistics
Stores statistics to estimate the decompilation quality and to count the used strategies.
|
static byte |
STRATEGY_DURATION_NEXT_PRESS |
static byte |
STRATEGY_DURATION_PRESS |
static byte |
STRATEGY_NEXT_DURATION_PRESS |
static byte |
STRATEGY_NEXT_PRESS |
static byte |
STRATEGY_PRESS |
protected static int |
targetResolution |
protected static boolean |
USE_DOTTED_NOTES |
protected static boolean |
USE_DOTTED_RESTS |
protected static boolean |
USE_KARAOKE |
protected static boolean |
USE_PRE_DEFINED_CHORDS |
protected static boolean |
USE_TRIPLETTED_NOTES |
protected static boolean |
USE_TRIPLETTED_RESTS |
Constructor and Description |
---|
Decompiler() |
Modifier and Type | Method and Description |
---|---|
private void |
addInstrumentsToSlices()
Adds all ticks to the timeline with at least one instrument change.
|
private void |
addLyricsToSlices()
Adds syllables to the slices’ timelines.
|
private void |
addNotesToSlices()
Fills the timeline structures of the slices with note-on events regarding chords and single notes.
|
private void |
addQualityDetailsLine(java.lang.StringBuilder stats,
java.lang.String name,
java.lang.String count,
double percentage,
java.lang.Double subScore)
Adds a line to the quality statistics, if configured.
|
protected void |
addWarningRestSkipped(java.lang.Long tick,
java.lang.Long ticks,
java.lang.Byte channel)
Creates a warning caused by a skipped rest.
|
private void |
adjustOffTick(java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Long,java.lang.Boolean>> channelOnOff,
byte channel,
byte note,
long offTick,
long crdOffTick)
Adjusts the Note-OFF tick of a note so that it can join a chord.
|
private static float |
calculateDuration(long noteTicks,
long pressTicks)
Calculates the duration ratio.
|
protected int |
calculateTicks(int factor,
int divisor)
Calculates the tick length of a note, based on the current MIDI sequence’s resolution and in relation to a quarter note.
|
protected java.lang.String |
createConfig()
Creates the block with configuration variables that has been used for decompilation.
|
protected abstract java.lang.String |
createOutput()
Creates the format-specific string to be written to the exported file.
|
protected java.lang.String |
createQualityStats()
Creates the quality statistics to be printed at the end of the produced file.
|
private java.lang.String |
createQualityStatsPart(java.util.TreeMap<java.lang.Byte,java.lang.Integer> subStat)
Creates the quality statistics for one part (either a channel or total).
|
protected abstract java.lang.String |
createRest(byte channel,
long ticks,
long beginTick,
java.lang.String syllable)
Creates a rest.
|
protected java.lang.String |
createRestBeforeSlice(Slice slice)
Creates a rest before a new slice begins, if necessary.
|
protected java.lang.String |
createStrategyStats()
Creates the strategy statistics to be printed at the end of the produced file.
|
private java.lang.String |
createStrategyStatsPart(java.util.TreeMap<java.lang.Byte,java.lang.Integer> subStat)
Creates the strategy statistics for one part (either a channel or total).
|
protected java.lang.String |
createTickDescription(long tick,
boolean withCommentSymbol)
Creates a tick description that can be used in tick comments.
|
ExportResult |
export(java.io.File file)
Decompiles a MIDI sequence and writes the result either into the given file or to the standard output.
|
protected java.lang.String |
getCommentSymbol()
Returns the comment symbol of the current format.
|
protected Instrument |
getFurthestInstrument()
Calculates and returns the most advanced instrument.
|
protected java.util.ArrayList<java.lang.Long> |
getLengthsForSum(long ticks,
boolean isRest)
Splits a note or rest length into several lengths that can be used for a length sum.
|
private long |
getNoteLengthByPressTicks(long ticks)
Guesses the theoretical note length just by choosing the next possible pre-defined length.
|
protected long[] |
getNoteLengthProperties(long onTick,
long offTick,
byte channel)
Calculates the note length string and duration percentage of a note (or chord).
|
private void |
groupNotes()
Groups notes with note-on/note-off/velocity differences that are smaller than the according tolerances.
|
protected void |
incrementStats(java.lang.Byte type,
java.lang.Byte channel)
Increments the statistics for the channel and total.
|
protected abstract void |
init()
Initializes format-specific data structures.
|
private void |
initInstruments()
Initializes and resets the instruments structures so that their configurations can be tracked.
|
protected abstract java.util.TreeMap<java.lang.Long,java.lang.String> |
initLengths(boolean rest)
Calculates which tick length corresponds to which note or rest length.
|
private void |
initStatistics()
Initializes data structures for statistics.
|
private java.lang.String |
makeChordName(java.util.TreeSet<java.lang.Byte> notes,
java.lang.String csvNotes)
Creates a new unique name for the chord consisting of the given notes.
|
private void |
organizeChords(java.util.TreeMap<java.lang.String,java.util.TreeMap<java.lang.Byte,java.lang.String>> notes,
boolean isPercussion)
Receives the notes that are pressed at one tick and channel.
|
private void |
postprocessLengths(java.util.TreeMap<java.lang.Long,java.lang.String> lengths)
Removes lengths that are too small to make sense according to the source resolution.
|
private java.util.ArrayList<java.lang.Byte> |
prioritizeChannelsForLyrics()
Prioritizes the channels for karaoke usage.
|
private void |
refreshConfig()
Re-reads all config variables that are relevant for decompilation.
|
private void |
splitSequence()
Splits the sequence into slices between global commands.
|
createFile
protected static final byte MIDICA
protected static final byte ALDA
protected static final byte ET_INSTR
protected static final byte ET_NOTES
protected static final byte ET_INLINE_BLK
protected static final byte NP_VELOCITY
protected static final byte NP_OFF_TICK
protected static final byte NP_END_TICK
protected static final byte NP_LENGTH
protected static final byte NP_DURATION
protected static final byte NP_MULTIPLE
protected static final byte NP_LYRICS
protected static final byte NP_NOTE_NUM
protected static final byte STAT_TOTAL
protected static final byte STAT_RESTS
protected static final byte STAT_REST_SKIPPED
protected static final byte STAT_REST_TRIPLETS
protected static final byte STAT_REST_SUMMANDS
protected static final byte STAT_NOTES
protected static final byte STAT_NOTE_VELOCITIES
protected static final byte STAT_NOTE_DURATIONS
protected static final byte STAT_NOTE_TRIPLETS
protected static final byte STAT_NOTE_SUMMANDS
protected static final byte STAT_NOTE_MULTIPLE
private static final byte STAT_STRATEGY_NEXT_ON
private static final byte STAT_STRATEGY_DURATION
private static final byte STAT_STRATEGY_PRESS
protected static final java.lang.String NEW_LINE
public static final byte INLINE_BLOCK
public static final byte SLICE_BEGIN_BLOCK
public static final byte STRATEGY_NEXT_DURATION_PRESS
public static final byte STRATEGY_DURATION_NEXT_PRESS
public static final byte STRATEGY_NEXT_PRESS
public static final byte STRATEGY_DURATION_PRESS
public static final byte STRATEGY_PRESS
public static final boolean DEFAULT_MUST_ADD_TICK_COMMENTS
public static final boolean DEFAULT_MUST_ADD_CONFIG
public static final boolean DEFAULT_MUST_ADD_QUALITY_SCORE
public static final boolean DEFAULT_MUST_ADD_STATISTICS
public static final boolean DEFAULT_MUST_ADD_STRATEGY_STAT
public static final byte DEFAULT_LENGTH_STRATEGY
public static final long DEFAULT_MIN_TARGET_TICKS_ON
public static final long DEFAULT_MAX_TARGET_TICKS_ON
public static final float DEFAULT_MIN_DURATION_TO_KEEP
public static final float DEFAULT_MAX_DURATION_TO_KEEP
public static final long DEFAULT_LENGTH_TICK_TOLERANCE
public static final float DEFAULT_DURATION_RATIO_TOLERANCE
public static final boolean DEFAULT_USE_PRE_DEFINED_CHORDS
public static final long DEFAULT_CHORD_NOTE_ON_TOLERANCE
public static final long DEFAULT_CHORD_NOTE_OFF_TOLERANCE
public static final long DEFAULT_CHORD_VELOCITY_TOLERANCE
public static final boolean DEFAULT_USE_DOTTED_NOTES
public static final boolean DEFAULT_USE_DOTTED_RESTS
public static final boolean DEFAULT_USE_TRIPLETTED_NOTES
public static final boolean DEFAULT_USE_TRIPLETTED_RESTS
public static final boolean DEFAULT_USE_KARAOKE
public static final boolean DEFAULT_ALL_SYLLABLES_ORPHANED
public static final byte DEFAULT_ORPHANED_SYLLABLES
public static final boolean DEFAULT_KARAOKE_ONE_CHANNEL
public static final byte DEFAULT_CTRL_CHANGE_MODE
public static final java.lang.String DEFAULT_EXTRA_GLOBALS_STR
protected static int format
protected static boolean MUST_ADD_TICK_COMMENTS
protected static boolean MUST_ADD_CONFIG
protected static boolean MUST_ADD_QUALITY_SCORE
protected static boolean MUST_ADD_STATISTICS
protected static boolean MUST_ADD_STRATEGY_STAT
protected static byte LENGTH_STRATEGY
protected static long MAX_TARGET_TICKS_ON
protected static long MIN_TARGET_TICKS_ON
protected static long MIN_SOURCE_TICKS_ON
protected static long MAX_SOURCE_TICKS_ON
protected static float MIN_DURATION_TO_KEEP
protected static float MAX_DURATION_TO_KEEP
protected static long LENGTH_TICK_TOLERANCE
protected static float DURATION_RATIO_TOLERANCE
protected static boolean USE_PRE_DEFINED_CHORDS
protected static long CHORD_NOTE_ON_TOLERANCE
protected static long CHORD_NOTE_OFF_TOLERANCE
protected static long CHORD_VELOCITY_TOLERANCE
protected static boolean USE_DOTTED_NOTES
protected static boolean USE_DOTTED_RESTS
protected static boolean USE_TRIPLETTED_NOTES
protected static boolean USE_TRIPLETTED_RESTS
protected static boolean USE_KARAOKE
protected static boolean ALL_SYLLABLES_ORPHANED
protected static byte ORPHANED_SYLLABLES
protected static boolean KARAOKE_ONE_CHANNEL
protected static byte CTRL_CHANGE_MODE
protected static java.util.TreeSet<java.lang.Long> EXTRA_GLOBALS
protected static int sourceResolution
protected static int targetResolution
protected static ExportResult exportResult
protected static boolean isSoftKaraoke
protected static java.util.ArrayList<Instrument> instrumentsByChannel
stores the current state of each channel
protected static java.util.TreeMap<java.lang.String,Instrument> instrumentsByName
protected static java.util.TreeMap<java.lang.Long,java.lang.String> noteLength
protected static java.util.TreeMap<java.lang.Long,java.lang.String> restLength
protected static java.util.TreeMap<java.lang.String,java.lang.String> chords
comma-separated note bytes – chord name
protected static java.util.TreeMap<java.lang.String,java.lang.Integer> chordCount
lowest note – chord count
protected static java.util.TreeMap<java.lang.String,java.util.ArrayList<java.lang.String>> chordsByBaseNote
lowest note – comma-separated note bytes (This structure is only needed for the sorting: lowest note first, then chord name)
protected java.util.ArrayList<java.lang.Byte> lyricsChannels
channels that can be used for lyrics, sorted by priority
protected java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Long,java.lang.Byte[]>> instrumentHistory
protected java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Long,java.lang.String>> commentHistory
protected java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Long,java.util.TreeMap<java.lang.Byte,java.lang.Byte>>> noteHistory
protected java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Long,java.lang.Boolean>>> noteOnOff
protected java.util.TreeMap<java.lang.Long,java.lang.String> lyricsSyllables
private java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Byte,java.lang.Integer>> statistics
Stores statistics to estimate the decompilation quality and to count the used strategies. Parts of this structure:
protected static java.util.ArrayList<Slice> slices
Stores each slice of the sequence.
A slice begins either with (one or more) global commands or at tick 0.
It ends either one tick before a global command or at the end of the sequence.
index – slice
protected abstract void init()
Initializes format-specific data structures.
protected abstract java.lang.String createOutput()
Creates the format-specific string to be written to the exported file.
protected abstract java.lang.String createRest(byte channel, long ticks, long beginTick, java.lang.String syllable)
Creates a rest.
channel
- MIDI channelticks
- tick length of the rest to createbeginTick
- used for the tick comment (negative value: don’t include a tick comment)syllable
- a lyrics syllable or (in most cases): nullprotected abstract java.util.TreeMap<java.lang.Long,java.lang.String> initLengths(boolean rest)
Calculates which tick length corresponds to which note or rest length. That depends on the resolution of the current MIDI sequence.
rest
- true to initialize REST lengths, false for NOTE lengthspublic ExportResult export(java.io.File file) throws ExportException
Decompiles a MIDI sequence and writes the result either into the given file or to the standard output.
export
in class Exporter
file
- target file to be written.ExportException
- if the file can not be exported correctly.private void refreshConfig()
Re-reads all config variables that are relevant for decompilation.
private void initStatistics()
Initializes data structures for statistics. This is used for the following statistics:
private void initInstruments()
Initializes and resets the instruments structures so that their configurations can be tracked.
private java.util.ArrayList<java.lang.Byte> prioritizeChannelsForLyrics()
Prioritizes the channels for karaoke usage.
Calculates the following values for each channel:
Sorts the channels by priority and returns them.
Reasons for this approach:
Often we have the following facts:
In this case the lead vocal channel is the best choice.
But the background vocals could have a better relevance, and the percussion channel could have the best coverage.
However the lead vocal channel has probably the highest sum (relevance + coverage). That’s why we choose this approach.
private void postprocessLengths(java.util.TreeMap<java.lang.Long,java.lang.String> lengths)
Removes lengths that are too small to make sense according to the source resolution.
The following lengths are removed:
The last step is necessary to avoid length sums like /4+256+256. Can happen due to rounding errors of very small lengths.
lengths
- note or rest lengthsprivate void splitSequence()
Splits the sequence into slices between global commands. Adds the global commands to the according slices.
The following messages are regarded as global commands:
Creates warnings for ignored short messages.
private void addInstrumentsToSlices()
Adds all ticks to the timeline with at least one instrument change.
private void groupNotes()
Groups notes with note-on/note-off/velocity differences that are smaller than the according tolerances.
private void adjustOffTick(java.util.TreeMap<java.lang.Byte,java.util.TreeMap<java.lang.Long,java.lang.Boolean>> channelOnOff, byte channel, byte note, long offTick, long crdOffTick)
Adjusts the Note-OFF tick of a note so that it can join a chord.
Checks if there is another ON/OFF between source and target OFF tick.
In this case: Doesn’t adjust the OFF tick and creates a warning instead.
channelOnOff
- noteOnOff structure for the channel in question (note, offTick, onOff)channel
- MIDI channelnote
- note numberoffTick
- current Note-OFF tickcrdOffTick
- target Note-OFF tick (Note-OFF tick of the chord)private void addNotesToSlices()
Fills the timeline structures of the slices with note-on events regarding chords and single notes.
private void organizeChords(java.util.TreeMap<java.lang.String,java.util.TreeMap<java.lang.Byte,java.lang.String>> notes, boolean isPercussion)
Receives the notes that are pressed at one tick and channel. Puts them together as chords, if possible.
In case of percussion instruments, inline chords are used. Otherwise predefined chords are used.
notes
- Notes, pressed at a certain tick in a certain channel.isPercussion
- true for channel 9, otherwise false.private java.lang.String makeChordName(java.util.TreeSet<java.lang.Byte> notes, java.lang.String csvNotes)
Creates a new unique name for the chord consisting of the given notes.
notes
- The notes of the chord.csvNotes
- Comma-separated note bytes.private void addLyricsToSlices()
Adds syllables to the slices’ timelines.
If there are any notes or chords played in the same tick as the syllable, the syllable is added to one of them (according to the channel’s priority).
If there are no notes or chords played in the syllable’s tick, the syllable is added to a special timeline as an option to a rest inside a nestable block.
protected int calculateTicks(int factor, int divisor)
Calculates the tick length of a note, based on the current MIDI sequence’s resolution and in relation to a quarter note. The given factor and divisor influences the resulting note length. If factor and divisor are the same, the resulting length is exactly one quarter note.
factor
- the factor to multiply the quarter note withdivisor
- the divisor to divide the quarter note withprotected java.util.ArrayList<java.lang.Long> getLengthsForSum(long ticks, boolean isRest)
Splits a note or rest length into several lengths that can be used for a length sum.
ticks
- total tick length of the note or rest lengthisRest
- true for a rest, false for a note.protected long[] getNoteLengthProperties(long onTick, long offTick, byte channel)
Calculates the note length string and duration percentage of a note (or chord).
For the calculation, one of the following strategies is used:
The priority of the actually chosen strategy to be used is controlled by the configuration.
onTick
- Note-ON tick of the note.offTick
- Note-OFF tick of the note.private long getNoteLengthByPressTicks(long ticks)
Guesses the theoretical note length just by choosing the next possible pre-defined length.
ticks
- tick difference between note-ON and note-OFF.private static float calculateDuration(long noteTicks, long pressTicks)
Calculates the duration ratio.
noteTicks
- full (theoretical) note length in tickspressTicks
- number of ticks that the note is pressed (from note-ON to note-OFF)protected java.lang.String createRestBeforeSlice(Slice slice)
Creates a rest before a new slice begins, if necessary.
The rest is only necessary if no channel has reached the slice’s begin tick yet.
With the slice’s beginning, all channels are synchronized. Therefore the rest is only necessary in one channel.
Steps:
slice
- the sequence sliceprotected Instrument getFurthestInstrument()
Calculates and returns the most advanced instrument. (Advanced in terms of “current ticks”).
Returns null, if no instrument is used at all.
protected void incrementStats(java.lang.Byte type, java.lang.Byte channel)
Increments the statistics for the channel and total.
type
- statistics typechannel
- MIDI channelprotected void addWarningRestSkipped(java.lang.Long tick, java.lang.Long ticks, java.lang.Byte channel)
Creates a warning caused by a skipped rest.
tick
- the tick where the rest should have occurred.ticks
- length of the skipped rest in tickschannel
- MIDI channelprotected java.lang.String createQualityStats()
Creates the quality statistics to be printed at the end of the produced file.
private java.lang.String createQualityStatsPart(java.util.TreeMap<java.lang.Byte,java.lang.Integer> subStat)
Creates the quality statistics for one part (either a channel or total).
subStat
- statistic structure for the part (channel or total)private void addQualityDetailsLine(java.lang.StringBuilder stats, java.lang.String name, java.lang.String count, double percentage, java.lang.Double subScore)
Adds a line to the quality statistics, if configured.
stats
- the statistic linename
- which kind of sub score (e.g. Summands, Triplets, …)count
- number of occurrencespercentage
- percentage of occurrencessubScore
- sub score to be added (or null, if no sub score is used)protected java.lang.String createStrategyStats()
Creates the strategy statistics to be printed at the end of the produced file.
private java.lang.String createStrategyStatsPart(java.util.TreeMap<java.lang.Byte,java.lang.Integer> subStat)
Creates the strategy statistics for one part (either a channel or total).
subStat
- statistic structure for the part (channel or total)protected java.lang.String createConfig()
Creates the block with configuration variables that has been used for decompilation.
protected java.lang.String createTickDescription(long tick, boolean withCommentSymbol)
Creates a tick description that can be used in tick comments. The description contains the given tick in source and target resolution.
tick
- MIDI tickstamp (in source resolution).withCommentSymbol
- prefixes a comment symbol, if trueprotected java.lang.String getCommentSymbol()
Returns the comment symbol of the current format.