+ /**
+ * Quantizes the given list of MIDI events
+ * @param notes a list of the notes to quantize
+ * @param resolution the note size to round each note to
+ * @param location whether the quantize should affect the location of the note
+ * @param duration whether the quantize should affect the duration of the note
+ */
+ public static List quantize(List notes, int resolution, boolean location, boolean duration) {
+ Iterator it = notes.iterator();
+ int noteSize = resolution * seq.getResolution() / 4;
+ while(it.hasNext()) {
+ MidiEvent note = (MidiEvent)it.next();
+ if (note instanceof MooNote) {
+ MooNote mn = (MooNote)note;
+ if (location) mn.setTick(Math.round(mn.getTick() / noteSize) * noteSize);
+ if (duration) {
+ int length = Math.round(mn.getDuration() / noteSize) * noteSize;
+ if (length < noteSize) length = noteSize;
+ mn.setDuration(length);
+ }
+ }
+ }
+ return notes;
+ }
+
+ /**
+ * Reinitializes sequence-specific collections.
+ */
+ private static void reinitializeLists() {
+ emptyTracks = new ArrayList();
+ timeSignatures = new ArrayList();
+ tempoChanges = new ArrayList();
+ copyBuffer = new ArrayList();
+ trackSolo = new HashMap();
+ trackMute = new HashMap();
+ selection = new TreeSet();
+ }
+
+ /**
+ * Loads the user preferences.
+ */
+ public static void loadPreferences() {
+
+ }
+
+ /**
+ * Saves the user preferences.
+ */
+ public static void savePreferences() {
+
+ }
+
+ /**
+ * Prompts the user to save any unsaved changes.
+ */
+ public static boolean promptOnUnsavedChanges() {
+ if (!edited) return false;
+ int exitOption = JOptionPane.showConfirmDialog(gui,
+ "The current sequence has been edited, but not saved.\nDo you wish to continue anyway?",
+ "File not saved - continue?",
+ JOptionPane.OK_CANCEL_OPTION,
+ JOptionPane.WARNING_MESSAGE);
+ if (exitOption == JOptionPane.CANCEL_OPTION || exitOption == JOptionPane.CLOSED_OPTION) return true;
+ return false;
+ }
+
+ /**
+ * Saves the current sequence to the previously given filename.
+ */
+ public static boolean save() {
+ if (file == null) return false;
+ else {
+ saveAs(file);
+ return true;
+ }
+ }
+