Skip to content

Commit

Permalink
small bugfixes and improvements
Browse files Browse the repository at this point in the history
- bugfix in the MIDI exporter (fixed a rare problem with wrong midi data)
- added some key bindings
  • Loading branch information
truj committed Oct 4, 2023
1 parent 0c70f68 commit 34041b6
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 3 deletions.
Binary file modified midica.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions src/org/midica/Midica.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ public class Midica {
* After switching to a new major version, this has to be set to "-1" manually, so that
* precommit.pl starts with "0" again.
*/
private static final int VERSION_MINOR = 9;
private static final int VERSION_MINOR = 10;

/** UNIX timestamp of the last commit */
public static final int COMMIT_TIME = 1694279716;
public static final int COMMIT_TIME = 1696410911;

/** Branch name. Automatically changed by precommit.pl */
public static final String BRANCH = "master";
Expand Down
5 changes: 5 additions & 0 deletions src/org/midica/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,11 @@ private static void restoreDefaultKeyBindings() {
addDefaultKeyBinding( Dict.KEY_INFO_MIDI_BANKS_TOT_MIN, KeyEvent.VK_MINUS, ctrl );
addDefaultKeyBinding( Dict.KEY_INFO_MIDI_BANKS_TOT_MIN, KeyEvent.VK_SUBTRACT, ctrl );
addDefaultKeyBinding( Dict.KEY_INFO_MIDI_BANKS_TOT_TREE, KeyEvent.VK_T, ctrl );
addDefaultKeyBinding( Dict.KEY_INFO_MIDI_BANKS_CH_PL, KeyEvent.VK_PLUS, ctrl | shift );
addDefaultKeyBinding( Dict.KEY_INFO_MIDI_BANKS_CH_PL, KeyEvent.VK_ADD, ctrl | shift );
addDefaultKeyBinding( Dict.KEY_INFO_MIDI_BANKS_CH_MIN, KeyEvent.VK_MINUS, ctrl | shift );
addDefaultKeyBinding( Dict.KEY_INFO_MIDI_BANKS_CH_MIN, KeyEvent.VK_SUBTRACT, ctrl | shift );
addDefaultKeyBinding( Dict.KEY_INFO_MIDI_BANKS_CH_TREE, KeyEvent.VK_T, alt );
addDefaultKeyBinding( Dict.KEY_INFO_MIDI_BANKS_CH_PL, KeyEvent.VK_PLUS, alt );
addDefaultKeyBinding( Dict.KEY_INFO_MIDI_BANKS_CH_PL, KeyEvent.VK_ADD, alt );
addDefaultKeyBinding( Dict.KEY_INFO_MIDI_BANKS_CH_MIN, KeyEvent.VK_MINUS, alt );
Expand Down
6 changes: 6 additions & 0 deletions src/org/midica/config/Dict.java
Original file line number Diff line number Diff line change
Expand Up @@ -1766,6 +1766,9 @@ public class Dict {
public static final String ERROR_CHANNEL = "error_channel";
public static final String ERROR_NOTE = "error_note";

// MidiExporter
public static final String WARNING_ILLEGAL_SHORT_MESSAGE = "warning_illegal_short_message";

// MidicaPLExporter
public static final String WARNING_IGNORED_SHORT_MESSAGE = "warning_ignored_short_message";
public static final String WARNING_IGNORED_META_MESSAGE = "warning_ignored_meta_message";
Expand Down Expand Up @@ -3487,6 +3490,9 @@ private static void initLanguageEnglish() {
set( ERROR_CHANNEL, "Channel" );
set( ERROR_NOTE, "Note" );

// MidiExporter
set( WARNING_ILLEGAL_SHORT_MESSAGE, "Ignoring Short Message due to illegal data." );

// MidicaPLExporter
set( WARNING_IGNORED_SHORT_MESSAGE, "Ignored Short Message" );
set( WARNING_IGNORED_META_MESSAGE, "Ignored Meta Message" );
Expand Down
18 changes: 18 additions & 0 deletions src/org/midica/file/write/MidiExporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
import javax.sound.midi.MidiMessage;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.Sequence;
import javax.sound.midi.ShortMessage;
import javax.sound.midi.Track;

import org.midica.config.Config;
import org.midica.config.Dict;
import org.midica.file.CharsetUtils;
import org.midica.midi.MidiDevices;
import org.midica.midi.MidiListener;
Expand Down Expand Up @@ -136,6 +138,22 @@ protected Sequence cloneSequence() throws InvalidMidiDataException {
MidiEvent event = oldTrack.get(i);
MidiMessage msg = event.getMessage();

// illegal short message? - warn and ignore
if (msg instanceof ShortMessage) {
int data1 = ((ShortMessage) msg).getData1();
int data2 = ((ShortMessage) msg).getData2();
if (data1 > 0x7F || data2 > 0x7F) {
int channel = ((ShortMessage) msg).getChannel();
byte[] bytes = ((ShortMessage) msg).getMessage();
String msgStr = "";
for (byte b : bytes)
msgStr += String.format(" %02X", b);
exportResult.addWarning(trackNum, event.getTick(), (byte) channel, Dict.get(Dict.WARNING_ILLEGAL_SHORT_MESSAGE));
exportResult.setDetailsOfLastWarning(msgStr);
continue EVENT;
}
}

// manipulate some meta messages
if (msg instanceof MetaMessage) {
int type = ((MetaMessage) msg).getType();
Expand Down
3 changes: 3 additions & 0 deletions src/org/midica/ui/tablesorter/ExportResultTableSorter.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public boolean include(Entry<? extends ExportResultTableModel, ? extends Integer
String warning = (String) tableModel.getValueAt(row, 3);
if (showShortMsg && warning.equals(Dict.get(Dict.WARNING_IGNORED_SHORT_MESSAGE)))
return true;
if (showShortMsg && warning.equals(Dict.get(Dict.WARNING_ILLEGAL_SHORT_MESSAGE)))
return true;
if (showMetaMsg && warning.equals(Dict.get(Dict.WARNING_IGNORED_META_MESSAGE)))
return true;
if (showSysexMsg && warning.equals(Dict.get(Dict.WARNING_IGNORED_SYSEX_MESSAGE)))
Expand All @@ -91,6 +93,7 @@ public boolean include(Entry<? extends ExportResultTableModel, ? extends Integer
if (showCrdGrpFailed && warning.equals(Dict.get(Dict.WARNING_CHORD_GROUPING_FAILED)))
return true;
if (showOther && ! warning.equals(Dict.get(Dict.WARNING_IGNORED_SHORT_MESSAGE))
&& ! warning.equals(Dict.get(Dict.WARNING_ILLEGAL_SHORT_MESSAGE))
&& ! warning.equals(Dict.get(Dict.WARNING_IGNORED_META_MESSAGE))
&& ! warning.equals(Dict.get(Dict.WARNING_IGNORED_SYSEX_MESSAGE))
&& ! warning.equals(Dict.get(Dict.WARNING_REST_SKIPPED))
Expand Down
1 change: 0 additions & 1 deletion test/org/midica/file/write/ExporterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.midica.file.read.MidicaPLParser;
import org.midica.file.read.ParseException;
import org.midica.file.read.SequenceParser;
import org.midica.file.write.MidicaPLExporter;

/**
* This is the test class for file exporters.
Expand Down

0 comments on commit 34041b6

Please sign in to comment.