public class AldaExporter extends Decompiler
This class is used to export the currently loaded MIDI sequence as an ALDA source file.
Modifier and Type | Field and Description |
---|---|
private Instrument |
currentInstrument |
private java.lang.String |
currentKeySig |
private int |
currentSliceNumber |
static java.util.ArrayList<java.lang.String> |
instrumentNames |
static java.util.ArrayList<java.lang.String> |
noteNames |
static java.util.ArrayList<java.lang.Byte> |
noteOctaves |
private static java.util.regex.Pattern |
tripletPattern |
private java.util.TreeSet<Instrument> |
usedInSlice |
ALDA, ALL_SYLLABLES_ORPHANED, CHORD_NOTE_OFF_TOLERANCE, CHORD_NOTE_ON_TOLERANCE, CHORD_VELOCITY_TOLERANCE, chordCount, chords, chordsByBaseNote, commentHistory, CTRL_CHANGE_MODE, DEFAULT_ALL_SYLLABLES_ORPHANED, DEFAULT_CHORD_NOTE_OFF_TOLERANCE, DEFAULT_CHORD_NOTE_ON_TOLERANCE, DEFAULT_CHORD_VELOCITY_TOLERANCE, DEFAULT_CTRL_CHANGE_MODE, DEFAULT_DURATION_RATIO_TOLERANCE, DEFAULT_EXTRA_GLOBALS_STR, DEFAULT_KARAOKE_ONE_CHANNEL, DEFAULT_LENGTH_STRATEGY, DEFAULT_LENGTH_TICK_TOLERANCE, DEFAULT_MAX_DURATION_TO_KEEP, DEFAULT_MAX_TARGET_TICKS_ON, DEFAULT_MIN_DURATION_TO_KEEP, DEFAULT_MIN_TARGET_TICKS_ON, DEFAULT_MUST_ADD_CONFIG, DEFAULT_MUST_ADD_QUALITY_SCORE, DEFAULT_MUST_ADD_STATISTICS, DEFAULT_MUST_ADD_STRATEGY_STAT, DEFAULT_MUST_ADD_TICK_COMMENTS, DEFAULT_ORPHANED_SYLLABLES, DEFAULT_USE_DOTTED_NOTES, DEFAULT_USE_DOTTED_RESTS, DEFAULT_USE_KARAOKE, DEFAULT_USE_PRE_DEFINED_CHORDS, DEFAULT_USE_TRIPLETTED_NOTES, DEFAULT_USE_TRIPLETTED_RESTS, DURATION_RATIO_TOLERANCE, ET_INLINE_BLK, ET_INSTR, ET_NOTES, exportResult, EXTRA_GLOBALS, format, INLINE_BLOCK, instrumentHistory, instrumentsByChannel, instrumentsByName, isSoftKaraoke, KARAOKE_ONE_CHANNEL, LENGTH_STRATEGY, LENGTH_TICK_TOLERANCE, lyricsChannels, lyricsSyllables, MAX_DURATION_TO_KEEP, MAX_SOURCE_TICKS_ON, MAX_TARGET_TICKS_ON, MIDICA, MIN_DURATION_TO_KEEP, MIN_SOURCE_TICKS_ON, MIN_TARGET_TICKS_ON, MUST_ADD_CONFIG, MUST_ADD_QUALITY_SCORE, MUST_ADD_STATISTICS, MUST_ADD_STRATEGY_STAT, MUST_ADD_TICK_COMMENTS, NEW_LINE, noteHistory, noteLength, noteOnOff, NP_DURATION, NP_END_TICK, NP_LENGTH, NP_LYRICS, NP_MULTIPLE, NP_NOTE_NUM, NP_OFF_TICK, NP_VELOCITY, ORPHANED_SYLLABLES, restLength, SLICE_BEGIN_BLOCK, slices, sourceResolution, STAT_NOTE_DURATIONS, STAT_NOTE_MULTIPLE, STAT_NOTE_SUMMANDS, STAT_NOTE_TRIPLETS, STAT_NOTE_VELOCITIES, STAT_NOTES, STAT_REST_SKIPPED, STAT_REST_SUMMANDS, STAT_REST_TRIPLETS, STAT_RESTS, STAT_TOTAL, STRATEGY_DURATION_NEXT_PRESS, STRATEGY_DURATION_PRESS, STRATEGY_NEXT_DURATION_PRESS, STRATEGY_NEXT_PRESS, STRATEGY_PRESS, targetResolution, USE_DOTTED_NOTES, USE_DOTTED_RESTS, USE_KARAOKE, USE_PRE_DEFINED_CHORDS, USE_TRIPLETTED_NOTES, USE_TRIPLETTED_RESTS
Constructor and Description |
---|
AldaExporter()
Creates a new MidicaPL exporter.
|
Modifier and Type | Method and Description |
---|---|
private java.lang.String |
createChordNotes(Slice slice,
byte channel,
long tick,
java.util.TreeMap<java.lang.String,java.util.TreeMap<java.lang.Byte,java.lang.String>> events)
Creates a chord - all notes beginning in the same tick in the same channel.
|
private java.lang.String |
createCommandsFromTimeline(Slice slice,
byte channel)
Creates notes and instrument changes from a slice’s timeline.
|
private java.lang.String |
createGlobalAttributes(Slice slice)
Creates a string with global attributes for the given slice.
|
private java.lang.String |
createInstrumentChange(byte channel,
long tick)
Creates one instrument line for an instrument change in the given channel and tick.
|
protected java.lang.String |
createMarker()
Creates a marker in the current instrument to mark the end of a slice.
|
private java.lang.String |
createNote(byte channel,
java.util.TreeMap<java.lang.Byte,java.lang.String> properties)
Prints a single note.
|
java.lang.String |
createOutput()
Creates the MidicaPL string to be written into the export file.
|
protected java.lang.String |
createRest(byte channel,
long ticks,
long beginTick,
java.lang.String syllable)
Creates a channel command with a rest.
|
private java.lang.String |
getKeySignature()
Calculates and returns the value for the key signature attribute.
|
private java.lang.String |
getTriplet(long base)
Calculates and returns a (rounded) triplet note length.
|
void |
init()
Initializes MidicaPL specific data structures.
|
private void |
initInstrumentNames()
Initializes all possible MIDI instrument numbers with an ALDA instrument name.
|
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 |
initNoteNames()
Initializes all possible MIDI note numbers with an ALDA instrument and octave name.
|
addWarningRestSkipped, calculateTicks, createConfig, createQualityStats, createRestBeforeSlice, createStrategyStats, createTickDescription, export, getCommentSymbol, getFurthestInstrument, getLengthsForSum, getNoteLengthProperties, incrementStats
createFile
public static java.util.ArrayList<java.lang.String> instrumentNames
public static java.util.ArrayList<java.lang.String> noteNames
public static java.util.ArrayList<java.lang.Byte> noteOctaves
private int currentSliceNumber
private Instrument currentInstrument
private java.util.TreeSet<Instrument> usedInSlice
private java.lang.String currentKeySig
private static java.util.regex.Pattern tripletPattern
public void init()
Initializes MidicaPL specific data structures.
init
in class Decompiler
public java.lang.String createOutput()
Creates the MidicaPL string to be written into the export file.
createOutput
in class Decompiler
private java.lang.String createCommandsFromTimeline(Slice slice, byte channel)
Creates notes and instrument changes from a slice’s timeline.
Steps:
slice
- the sequence slicechannel
- MIDI channelprivate java.lang.String createInstrumentChange(byte channel, long tick)
Creates one instrument line for an instrument change in the given channel and tick. If there is no instrument change event found in the MIDI sequence, the default instrument (piano) is used.
channel
- MIDI channeltick
- MIDI tickprivate java.lang.String createGlobalAttributes(Slice slice)
Creates a string with global attributes for the given slice.
Global attributes are:
slice
- the sequence sliceprivate java.lang.String createChordNotes(Slice slice, byte channel, long tick, java.util.TreeMap<java.lang.String,java.util.TreeMap<java.lang.Byte,java.lang.String>> events)
Creates a chord - all notes beginning in the same tick in the same channel.
Steps:
slice
- the sequence slicechannel
- MIDI channeltick
- MIDI tickevents
- All notes/chords with the same note-ON tick in the same channel (comes from the slice’s timeline)private java.lang.String createNote(byte channel, java.util.TreeMap<java.lang.Byte,java.lang.String> properties)
Prints a single note.
The note may be a part of a chord or a single note.
Parts of the note are:
channel
- MIDI channelproperties
- note properties (from the slice’s timeline)protected java.lang.String createRest(byte channel, long ticks, long beginTick, java.lang.String syllable)
Creates a channel command with a rest.
createRest
in class Decompiler
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 java.lang.String createMarker()
Creates a marker in the current instrument to mark the end of a slice.
public 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.
The created rest lengths will contain a view more very short lengths. This is needed because rests should be less tolerant than notes.
This enables us to use more common lengths for notes but let the exported sequence be still as close as possible to the original one.
initLengths
in class Decompiler
rest
- true to initialize REST lengths, false for NOTE lengthsprivate java.lang.String getTriplet(long base)
Calculates and returns a (rounded) triplet note length.
base
- the base note length to be tripletedprivate void initInstrumentNames()
Initializes all possible MIDI instrument numbers with an ALDA instrument name.
private void initNoteNames()
Initializes all possible MIDI note numbers with an ALDA instrument and octave name. Takes the current key signature into account.
private java.lang.String getKeySignature()
Calculates and returns the value for the key signature attribute.