import javax.sound.midi.*;
-import javax.swing.*;
import java.io.*;
+import javax.swing.*;
+import java.util.*;
/**
* Moosique - The MIDI Tracker
//If a filename is given as the command-line argument, attempts to load a sequence from the file.
if (fileArg != null) {
System.out.print("Loading MIDI sequence from " + fileArg + "...");
- if (!load(fileArg)) clearSequence();
- System.out.println("Done");
+ if (!load(fileArg)) {
+ System.out.println("Failed");
+ clearSequence();
+ } else {
+ System.out.println("Done");
+ }
} else {
// Otherwise creates a new empty one.
clearSequence();
}
- // If n-flag is set, plays song and then exits. Otherwise builds GUI.
+ // Builds GUI, unless n-flag is set.
if (makeGUI) {
System.out.print("Building GUI...");
+ try {
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ } catch (Exception e) {}
gui = new MooGUI(seq);
System.out.println("Done");
} else {
}
}
+ /**
+ * Returns the GUI.
+ * @return the GUI
+ */
+ public static MooGUI getGUI() {
+ return gui;
+ }
+
/**
* Returns the current sequence.
* @return the current sequence
} catch (InvalidMidiDataException e) {
return false;
} catch (IOException e) {
- JOptionPane.showMessageDialog(null, "Error 404", "File Not Found", JOptionPane.ERROR_MESSAGE);
return false;
}
MidiMessage nextMsg;
ShortMessage shortMsg;
for (int i = 0; i < tracks.length; i++) {
+ /*
+ Collections.sort(track[i].events, new Comparator() {
+ public int compare(Object o1, Object o2) {
+ return ((MidiEvent)o2).getTick() - ((MidiEvent)o1).getTick();
+ }
+ });
+ */
for (int j = 0; j < tracks[i].size(); j++) {
noteOn = tracks[i].get(j);
if (noteOn.getMessage() instanceof ShortMessage) {
if (synthesizer.isOpen()) synthesizer.close();
System.exit(0);
}
-}
\ No newline at end of file
+}