Skip to content

Commit

Permalink
enhanced decompiler
Browse files Browse the repository at this point in the history
- allowing less note/rest lengths
- enabled warnings
- creating a warning for ignored messages
- creating a warning for skipped rests
- creating a warning for missing Note-OFF messages
- added filters to the warning table
- added key bindings to the export result view
- #58
  • Loading branch information
truj committed Jun 25, 2020
1 parent 20e58ed commit 6652f83
Show file tree
Hide file tree
Showing 21 changed files with 1,167 additions and 687 deletions.
Binary file modified midica.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion src/org/midica/Midica.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class Midica {
public static final int VERSION_MINOR = 1;

/** UNIX timestamp of the last commit */
public static final int COMMIT_TIME = 1590729348;
public static final int COMMIT_TIME = 1593109036;

/** Branch name. Automatically changed by precommit.pl */
public static final String BRANCH = "decompile-optimization";
Expand Down
8 changes: 8 additions & 0 deletions src/org/midica/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,14 @@ private static void restoreDefaultKeyBindings() {
addDefaultKeyBinding( Dict.KEY_DC_RESTORE_SAVED, KeyEvent.VK_R, InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK );
addDefaultKeyBinding( Dict.KEY_DC_RESTORE_DEFAULT, KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK );
addDefaultKeyBinding( Dict.KEY_DC_SAVE, KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK );
addDefaultKeyBinding( Dict.KEY_EXPORT_RESULT_CLOSE, KeyEvent.VK_ESCAPE, 0 );
addDefaultKeyBinding( Dict.KEY_EXPORT_RESULT_SHORT, KeyEvent.VK_S, 0 );
addDefaultKeyBinding( Dict.KEY_EXPORT_RESULT_META, KeyEvent.VK_M, 0 );
addDefaultKeyBinding( Dict.KEY_EXPORT_RESULT_SYSEX, KeyEvent.VK_X, 0 );
addDefaultKeyBinding( Dict.KEY_EXPORT_RESULT_SKIPPED_RESTS, KeyEvent.VK_R, 0 );
addDefaultKeyBinding( Dict.KEY_EXPORT_RESULT_OFF_NOT_FOUND, KeyEvent.VK_N, 0 );
addDefaultKeyBinding( Dict.KEY_EXPORT_RESULT_OTHER, KeyEvent.VK_O, 0 );
addDefaultKeyBinding( Dict.KEY_EXPORT_RESULT_FILTER, KeyEvent.VK_F, 0 );

// init key bindings with defaults
keyBindings = new TreeMap<>();
Expand Down
52 changes: 46 additions & 6 deletions src/org/midica/config/Dict.java
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ public class Dict {
public static final String KEYCAT_MSG = "key_msg";
public static final String KEYCAT_FILE_SELECT = "key_file_select";
public static final String KEYCAT_DC_CONF = "key_dc_conf";
public static final String KEYCAT_EXPORT_RESULT = "key_export_result";
public static final String KEYCAT_STRING_FILTER = "key_string_filter";

// key binding IDs
Expand Down Expand Up @@ -728,6 +729,14 @@ public class Dict {
public static final String KEY_DC_RESTORE_SAVED = "key_dc_restore_saved";
public static final String KEY_DC_RESTORE_DEFAULT = "key_dc_restore_default";
public static final String KEY_DC_SAVE = "key_dc_save";
public static final String KEY_EXPORT_RESULT_CLOSE = "key_export_result_close";
public static final String KEY_EXPORT_RESULT_SHORT = "key_export_result_short";
public static final String KEY_EXPORT_RESULT_META = "key_export_result_meta";
public static final String KEY_EXPORT_RESULT_SYSEX = "key_export_result_sysex";
public static final String KEY_EXPORT_RESULT_SKIPPED_RESTS = "key_export_result_skipped_rests";
public static final String KEY_EXPORT_RESULT_OFF_NOT_FOUND = "key_export_result_off_not_found";
public static final String KEY_EXPORT_RESULT_OTHER = "key_export_result_other";
public static final String KEY_EXPORT_RESULT_FILTER = "key_export_result_filter";

// UiView
public static final String TITLE_MAIN_WINDOW = "title_main";
Expand Down Expand Up @@ -1627,8 +1636,14 @@ public class Dict {
public static final String WARNING_COL_TRACK = "warning_col_track";
public static final String WARNING_COL_TICK = "warning_col_tick";
public static final String WARNING_COL_CHANNEL = "warning_col_channel";
public static final String WARNING_COL_NOTE = "warning_col_note";
public static final String WARNING_COL_MESSAGE = "warning_col_message";
public static final String WARNING_COL_DETAILS = "warning_col_details";
public static final String SHOW_IGN_SHORT_MSG = "show_ign_short_msg";
public static final String SHOW_IGN_META_MSG = "show_ign_meta_msg";
public static final String SHOW_IGN_SYSEX_MSG = "show_ign_sysex_msg";
public static final String SHOW_SKIPPED_RESTS = "show_skipped_rests";
public static final String SHOW_OFF_NOT_FOUND = "show_off_not_found";
public static final String SHOW_OTHER_WARNINGS = "show_other_warnings";

// ExportException
public static final String ERROR_TICK = "error_tick";
Expand All @@ -1638,6 +1653,11 @@ public class Dict {
// MidicaPLExporter
public static final String WARNING_SAME_NOTE_IN_SAME_TICK = "warning_same_note_in_same_tick";
public static final String WARNING_IGNORED_SHORT_MESSAGE = "warning_ignored_short_message";
public static final String WARNING_IGNORED_META_MESSAGE = "warning_ignored_meta_message";
public static final String WARNING_IGNORED_SYSEX_MESSAGE = "warning_ignored_sysex_message";
public static final String WARNING_REST_SKIPPED = "warning_rest_skipped";
public static final String WARNING_REST_SKIPPED_TICKS = "warning_rest_skipped_ticks";
public static final String WARNING_OFF_NOT_FOUND = "warning_off_not_found";

// MidiDevices
public static final String DEFAULT_CHANNEL_COMMENT = "default_channel_comment";
Expand Down Expand Up @@ -1769,6 +1789,7 @@ public static void init() {
keyBindingCategories.add(KEYCAT_MSG);
keyBindingCategories.add(KEYCAT_FILE_SELECT);
keyBindingCategories.add(KEYCAT_DC_CONF);
keyBindingCategories.add(KEYCAT_EXPORT_RESULT);
keyBindingCategories.add(KEYCAT_STRING_FILTER);
}

Expand Down Expand Up @@ -1850,6 +1871,7 @@ private static void initLanguageEnglish() {
set( KEYCAT_MSG, "Message Window" );
set( KEYCAT_FILE_SELECT, "File Selector" );
set( KEYCAT_DC_CONF, "Decompile Config Window" );
set( KEYCAT_EXPORT_RESULT, "Export Result Window" );
set( KEYCAT_STRING_FILTER, "Table Filter" );

// key binding IDs
Expand Down Expand Up @@ -2093,6 +2115,14 @@ private static void initLanguageEnglish() {
set( KEY_DC_RESTORE_SAVED, "Press the button to restore saved decompile config" );
set( KEY_DC_RESTORE_DEFAULT, "Press the button to restore default decompile config" );
set( KEY_DC_SAVE, "Press the button to save the decompile config" );
set( KEY_EXPORT_RESULT_CLOSE, "Close the Export Result Window" );
set( KEY_EXPORT_RESULT_SHORT, "Toggle Checkbox: Show Ignored Short Message" );
set( KEY_EXPORT_RESULT_META, "Toggle Checkbox: Show Ignored Meta Message" );
set( KEY_EXPORT_RESULT_SYSEX, "Toggle Checkbox: Show Ignored SysEx Message" );
set( KEY_EXPORT_RESULT_SKIPPED_RESTS, "Toggle Checkbox: Show Skipped Rests" );
set( KEY_EXPORT_RESULT_OFF_NOT_FOUND, "Toggle Checkbox: Show Note-OFF not found" );
set( KEY_EXPORT_RESULT_OTHER, "Toggle Checkbox: Show other warnings" );
set( KEY_EXPORT_RESULT_FILTER, "Open the Table Filter" );

// UiView
set( CONFIGURATION, "Configuration" );
Expand Down Expand Up @@ -3123,8 +3153,14 @@ private static void initLanguageEnglish() {
set( WARNING_COL_TRACK, "Track" );
set( WARNING_COL_TICK, "Tick" );
set( WARNING_COL_CHANNEL, "Channel" );
set( WARNING_COL_NOTE, "Note" );
set( WARNING_COL_MESSAGE, "Warning" );
set( WARNING_COL_DETAILS, "Details" );
set( SHOW_IGN_SHORT_MSG, "Show Ignored Short Messages" );
set( SHOW_IGN_META_MSG, "Show Ignored Meta Messages" );
set( SHOW_IGN_SYSEX_MSG, "Show Ignored SysEx Messages" );
set( SHOW_SKIPPED_RESTS, "Show Skipped Rests" );
set( SHOW_OFF_NOT_FOUND, "Show Note-OFF not found" );
set( SHOW_OTHER_WARNINGS, "Show other warnings" );

// ExportException
set( ERROR_TICK, "Tick" );
Expand All @@ -3134,7 +3170,12 @@ private static void initLanguageEnglish() {
// MidicaPLExporter
set( WARNING_SAME_NOTE_IN_SAME_TICK, "The same note has been addressed more than once"
+ " at the same time and channel (current/old velocity: %s/%s)" );
set( WARNING_IGNORED_SHORT_MESSAGE, "Ignored ShortMessage - command: %s, data1: %s, data2: %s" );
set( WARNING_IGNORED_SHORT_MESSAGE, "Ignored Short Message" );
set( WARNING_IGNORED_META_MESSAGE, "Ignored Meta Message" );
set( WARNING_IGNORED_SYSEX_MESSAGE, "Ignored SysEx Message" );
set( WARNING_REST_SKIPPED, "Rest skipped (too small)" );
set( WARNING_REST_SKIPPED_TICKS, "ticks" );
set( WARNING_OFF_NOT_FOUND, "Note-Off not found" );

// MidiDevices
set( PERCUSSION_CHANNEL, "Percussion Channel" );
Expand All @@ -3146,9 +3187,8 @@ private static void initLanguageEnglish() {
set( ERROR_SOUNDFONT_LOADING_FAILED, "Soundfont failed to load" );

// SequenceNotSetException
set( ERROR_SEQUENCE_NOT_SET, "<html>A Sequence is not yet set<br>"
+ "You have to open either a MIDI file (.mid)<br>"
+ "or a score file (.midica) from the import area<br>"
set( ERROR_SEQUENCE_NOT_SET, "<html>A MIDI Sequence is not yet loaded.<br>"
+ "You have to import a file (no matter which format)<br>"
+ "before you can use the player or export a file." );

// ErrorMessage
Expand Down
22 changes: 12 additions & 10 deletions src/org/midica/config/Laf.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,18 @@ public class Laf {
public static final Color COLOR_TREE_NODE_INACTIVE = new Color( 180, 180, 180 );

// message table and tree colors
public static final Color COLOR_MSG_TABLE_HEADER_BG = COLOR_TABLE_HEADER_BG;
public static final Color COLOR_MSG_TABLE_HEADER_TXT = COLOR_TABLE_HEADER_TXT;
public static final Color COLOR_MSG_TABLE = COLOR_SECONDARY_LIGHT;
public static final Color COLOR_MSG_TABLE_SELECTED = COLOR_SECONDARY; // new Color( 255, 243, 220 );
public static final Color COLOR_MSG_TABLE_SELECTED_TXT = COLOR_BLACK;
public static final Color COLOR_MSG_TREE = COLOR_PRIMARY_LIGHT;
private static final Color COLOR_MSG_TREE_SELECTED_BG = COLOR_PRIMARY;
private static final Color COLOR_MSG_TREE_SELECTED_TXT = COLOR_BLACK;
public static final Color COLOR_MSG_DEFAULT = UIManager.getColor( "Panel.background" );
public static final Color COLOR_MSG_TABLE_GRID = COLOR_SECONDARY;
public static final Color COLOR_MSG_TABLE_HEADER_BG = COLOR_TABLE_HEADER_BG;
public static final Color COLOR_MSG_TABLE_HEADER_TXT = COLOR_TABLE_HEADER_TXT;
public static final Color COLOR_MSG_TABLE = COLOR_SECONDARY_LIGHT;
public static final Color COLOR_MSG_TABLE_SELECTED = COLOR_SECONDARY; // new Color( 255, 243, 220 );
public static final Color COLOR_MSG_TABLE_SELECTED_TXT = COLOR_BLACK;
public static final Color COLOR_MSG_TREE = COLOR_PRIMARY_LIGHT;
private static final Color COLOR_MSG_TREE_SELECTED_BG = COLOR_PRIMARY;
private static final Color COLOR_MSG_TREE_SELECTED_TXT = COLOR_BLACK;
public static final Color COLOR_MSG_DEFAULT = UIManager.getColor( "Panel.background" );
public static final Color COLOR_MSG_TABLE_GRID = COLOR_SECONDARY;
private static final Color COLOR_MSG_ARROW = new Color( 221, 0, 0 );
public static final String COLOR_MSG_ARROW_HTML = Integer.toHexString(COLOR_MSG_ARROW.getRGB()).substring(2); // arrows in the message and warnings tables

// colors for key binding configuration
public static final Color COLOR_KEYBINDING_DEFAULT = UIManager.getColor( "Panel.background" );
Expand Down
18 changes: 3 additions & 15 deletions src/org/midica/file/write/AldaExporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -533,9 +533,7 @@ protected String createRest(byte channel, long ticks, long beginTick, String syl
incrementStats(STAT_RESTS, channel);
}
else {
// TODO: Dict
// TODO: add warning
System.err.println("rest too small to be handled: " + ticks + " ticks");
addWarningRestSkipped(beginTick, ticks, channel);
incrementStats(STAT_REST_SKIPPED, channel);
}

Expand Down Expand Up @@ -589,14 +587,6 @@ public TreeMap<Long, String> initLengths(boolean rest) {

// use very small lengths only for rests
if (rest) {
// 1/512
long length512 = calculateTicks(1, 128);
lengthToSymbol.put(length512, 512 + "");

// 1/256
long length256 = calculateTicks(1, 64);
lengthToSymbol.put(length256, 256 + "");

// 1/128
long length128 = calculateTicks(1, 32);
lengthToSymbol.put(length128, 128 + "");
Expand Down Expand Up @@ -652,10 +642,8 @@ public TreeMap<Long, String> initLengths(boolean rest) {
if (useDots) lengthToSymbol.put( length2d, base + "." );

// full
long length1 = calculateTicks( 4, 1 );
long length1d = calculateTicks( 4 * 3, 2 );
lengthToSymbol.put( length1, "1" );
if (useDots) lengthToSymbol.put( length1d, "1." );
long length1 = calculateTicks(4, 1);
lengthToSymbol.put(length1, "1");

return lengthToSymbol;
}
Expand Down
Loading

0 comments on commit 6652f83

Please sign in to comment.