From f852147b2a61dcfebc065b38dff854f609899ff0 Mon Sep 17 00:00:00 2001 From: Einar Pehrson Date: Wed, 14 May 2003 13:03:33 +0000 Subject: [PATCH] *** empty log message *** --- MooGUI.java | 13 ++++++++++ MooNoteElement.java | 3 +-- MooTrackTitle.java | 10 -------- MooViewCounter.java | 2 +- Moosique.java | 57 ++++++++++++++++++++++++++++++++++++++++++-- To Do.txt | 14 ----------- midi/test3.mid | Bin 3541 -> 3247 bytes 7 files changed, 70 insertions(+), 29 deletions(-) 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 baedc6704278bca7643e7acb22389272df5ab732..5080a168667b4ddab24e5788104b7967b583cdd3 100644 GIT binary patch literal 3247 zcmd5;OK%%h7(Gd+$Z8ij%L*12M%L7dGLFVFDaQ6RBt&ho(vWAHhTJ^J)2T`72pm~B z6NiL|MPst^zvzPvVgVF3Z1@kTd;UT=_uiR_4K1w^LS5Z&&UeoDx_9nOer#nCz-#D0 zSI2ICY-^oQQJhX09i1YC)9N|kDo#hvUEF+7ldz#+3!2*bJswc-<0YKl>NKzyIqu6R zcKd+i^qqt`j!X&3Nn+y`cFyAO%=5%Q!57RDp>Oon6LfG|!dWgf*d5^M6xK!CFRY4Vk-tRk2`}ot&hE z(R2;X1(V-WaAp(9+b}0IpIuOL+;Ss(~Ko)@f)eHOJ{zcCMX>LhcX)?nV9~;B$}8segpe z-^6!3!oNZuVc4~JvY!i`>G?TD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