From: Einar Pehrson Date: Wed, 14 May 2003 13:03:33 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: https://ruin.nu/git/?p=moosique.git;a=commitdiff_plain;h=f852147b2a61dcfebc065b38dff854f609899ff0 *** empty log message *** --- diff --git a/MooGUI.java b/MooGUI.java index 9f171a3..b1bbf0d 100644 --- a/MooGUI.java +++ b/MooGUI.java @@ -2,6 +2,7 @@ import javax.sound.midi.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; +import java.util.*; /** * Moosique's graphical user interface. @@ -16,6 +17,8 @@ public class MooGUI extends JFrame { 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); @@ -55,6 +58,9 @@ public class MooGUI extends JFrame { statusBar.setBackground(bgColor); view.setBackground(bgColor); + // Creates timer. + timer = new java.util.Timer(); + // Sets up global key listener ActionMap am = getRootPane().getActionMap(); @@ -109,6 +115,7 @@ public class MooGUI extends JFrame { */ public void setStatus(String text) { statusBar.setText(text); + timer.schedule(new StatusResetTask(), statusResetDelay); } /** @@ -125,4 +132,10 @@ public class MooGUI extends JFrame { Moosique.quit(); } } + + class StatusResetTask extends TimerTask { + public void run() { + setStatus(" "); + } + } } diff --git a/MooNoteElement.java b/MooNoteElement.java index 1729f4a..e1bcfb0 100644 --- a/MooNoteElement.java +++ b/MooNoteElement.java @@ -138,8 +138,7 @@ public class MooNoteElement extends JPanel { calculateString(); } e.getComponent().repaint(); - } - else if (e.isPopupTrigger()) { + } else if (e.isPopupTrigger()) { popup.show(e.getComponent(), e.getX(), e.getY()); } } diff --git a/MooTrackTitle.java b/MooTrackTitle.java index b921926..a71b361 100644 --- a/MooTrackTitle.java +++ b/MooTrackTitle.java @@ -49,16 +49,6 @@ public class MooTrackTitle extends JPanel { } } -/* // Finds channel number. - MidiEvent event; - for (int i = 0; i < track.size(); i++) { - event = track.get(i); - if (event instanceof MooNote) { - channel = ((MooNote)event).getChannel(); - break; - } - } -*/ // Creates and places components. setLayout(new GridLayout(4,1)); setBorder(BorderFactory.createLineBorder(Color.black)); diff --git a/MooViewCounter.java b/MooViewCounter.java index de745d2..2775027 100644 --- a/MooViewCounter.java +++ b/MooViewCounter.java @@ -13,7 +13,7 @@ public class MooViewCounter extends JPanel { /** * Creates */ - public MooViewCounter (int beatsPerMeasure1,int beatsPerMeasure2) { + public MooViewCounter (int beatsPerMeasure1, int beatsPerMeasure2) { } diff --git a/Moosique.java b/Moosique.java index e72cdf5..33381f1 100644 --- a/Moosique.java +++ b/Moosique.java @@ -19,6 +19,7 @@ public class Moosique { 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; @@ -222,6 +223,40 @@ public class Moosique { 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 @@ -268,9 +303,26 @@ public class Moosique { 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; @@ -326,6 +378,7 @@ public class Moosique { MidiSystem.write(seq, 1, new File(filename)); } catch (IOException e) {} filename = file; + gui.setStatus("Saved " + file); } /** diff --git a/To Do.txt b/To Do.txt index a1038ea..cabc038 100644 --- a/To Do.txt +++ b/To Do.txt @@ -19,20 +19,6 @@ x Spara konfiguration? Fem senast öppnade filerna Valda MIDI-enheter - -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; - MooNote / MootrackView / MooNoteElement diff --git a/midi/test3.mid b/midi/test3.mid index baedc67..5080a16 100644 Binary files a/midi/test3.mid and b/midi/test3.mid differ