import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
+import java.util.*;
/**
* Moosique's graphical user interface.
private MooToolbar toolbar;
private MooView view;
private JLabel statusBar;
+ private java.util.Timer timer;
+ public static final int statusResetDelay = 3000;
public static final Font FONT = new Font("Helvetica", Font.PLAIN, 10);
public static final Color bgColor = new Color(192, 224, 255);
statusBar.setBackground(bgColor);
view.setBackground(bgColor);
+ // Creates timer.
+ timer = new java.util.Timer();
+
// Sets up global key listener
ActionMap am = getRootPane().getActionMap();
*/
public void setStatus(String text) {
statusBar.setText(text);
+ timer.schedule(new StatusResetTask(), statusResetDelay);
}
/**
Moosique.quit();
}
}
+
+ class StatusResetTask extends TimerTask {
+ public void run() {
+ setStatus(" ");
+ }
+ }
}
private static Synthesizer synthesizer;
private static MidiChannel[] channels;
private static MidiChannel activeChannel;
+ private static MetaMessage tempoMsg, timeSigMsg;
private static String filename, fileArg;
private static long editPosition;
editPosition = ticks;
}
+ /**
+ * Returns the tempo of the current sequence.
+ * @return the tick position
+ */
+ public static int getTempo() {
+ if (tempoMsg == null) return 0;
+ return 120;
+ }
+
+ /**
+ * Sets the current editing position of the sequencer.
+ * @param ticks the tick position
+ */
+ public static void setTempo(int bpm) {
+ // tempoMsg, timeSigMsg
+ }
+
+ /**
+ * Returns the tempo of the current sequence.
+ * @return the tick position
+ */
+ public static int getTimeSig() {
+ if (timeSigMsg == null) return 0;
+ return 120;
+ }
+
+ /**
+ * Sets the current editing position of the sequencer.
+ * @param ticks the tick position
+ */
+ public static void setTimeSig(int bpm) {
+ // tempoMsg, timeSigMsg
+ }
+
/**
* Returns true if the current sequence has been edited.
* @return the tick position
return false;
}
isEdited = false;
-
- // Searches the sequence for NoteOn events
+
Track[] tracks = seq.getTracks();
+
+ // Stores tempo and time signature.
+ MidiMessage msg;
+ MetaMessage metaMsg;
+ for (int i = 0; i < tracks[0].size(); i++) {
+ msg = tracks[0].get(i).getMessage();
+ if (msg.getStatus() == MetaMessage.META) {
+ metaMsg = (MetaMessage)msg;
+ if (metaMsg.getType() == 81) {
+ tempoMsg = metaMsg;
+ } else if (metaMsg.getType() == 88) {
+ timeSigMsg = (MetaMessage)msg;
+ }
+
+ }
+ }
+
+ // Searches the sequence for NoteOn events
MidiEvent noteOn, noteOff = null, nextEvent;
MidiMessage nextMsg;
ShortMessage shortMsg;
MidiSystem.write(seq, 1, new File(filename));
} catch (IOException e) {}
filename = file;
+ gui.setStatus("Saved " + file);
}
/**
Fem senast öppnade filerna
Valda MIDI-enheter
-\f
-MIDI Messages
-
-FF 58 Time signature: [0] / [1], [2] MIDI clocks per metronome tick, [3] / 32 per 24 MIDI clocks
-FF 51 Tempo
-FF 03 Track Name String name = new String(getData());
-C0 Program change int pc = getData1();
-
-
-Sequence
- private ShortMessage timeSignature, tempo;
-Track
- private ShortMessage trackName, programChange;
-
\f
MooNote / MootrackView / MooNoteElement