]> ruin.nu Git - moosique.git/commitdiff
*** empty log message ***
authorEinar Pehrson <einarp@itstud.chalmers.se>
Wed, 14 May 2003 13:03:33 +0000 (13:03 +0000)
committerEinar Pehrson <einarp@itstud.chalmers.se>
Wed, 14 May 2003 13:03:33 +0000 (13:03 +0000)
MooGUI.java
MooNoteElement.java
MooTrackTitle.java
MooViewCounter.java
Moosique.java
To Do.txt
midi/test3.mid

index 9f171a3a8c6a11965eb118a2b3e044af17d483eb..b1bbf0d8b3e6aafed3dbee05570346fcdc7859f8 100644 (file)
@@ -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(" ");
+               }
+       }
 }
index 1729f4aeeed79d06196fc4bb2a504de3e208b1c0..e1bcfb019d55c756867942c0c006b9110cbebe7b 100644 (file)
@@ -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());
                        }
                }
index b921926bd8dc9527b99ebe7825fe7816ab981f23..a71b3619f3a909c2d302ca41f7ed2ec47f55aa87 100644 (file)
@@ -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));
index de745d2e94c6b163d53351170b5d1a5c1f10c672..2775027b2e0d1f64702ebad376c6a29ee3c4756b 100644 (file)
@@ -13,7 +13,7 @@ public class MooViewCounter extends JPanel {
        /** 
         * Creates 
         */
-       public MooViewCounter (int beatsPerMeasure1,int beatsPerMeasure2) {
+       public MooViewCounter (int beatsPerMeasure1, int beatsPerMeasure2) {
        
        }
 
index e72cdf560d3df1e1b2e55dbdefb6ae0aecaad323..33381f1b99b7193af0e147e63b7fd61a0216ce99 100644 (file)
@@ -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);
        }
 
        /** 
index a1038eae92cbe27c974751c0095777b9f02a4e7b..cabc038fe5d0bf6fab66c184ed177e7cefe9967c 100644 (file)
--- a/To Do.txt
+++ b/To Do.txt
@@ -19,20 +19,6 @@ x Spara konfiguration?
        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
 
index baedc6704278bca7643e7acb22389272df5ab732..5080a168667b4ddab24e5788104b7967b583cdd3 100644 (file)
Binary files a/midi/test3.mid and b/midi/test3.mid differ