]> ruin.nu Git - moosique.git/commitdiff
Readded the MooKeyboard listener to MooTrackView.
authorEinar Pehrson <einarp@itstud.chalmers.se>
Thu, 15 May 2003 21:08:18 +0000 (21:08 +0000)
committerEinar Pehrson <einarp@itstud.chalmers.se>
Thu, 15 May 2003 21:08:18 +0000 (21:08 +0000)
Updated the project report.

MooKeyboard.java
MooTrackTitle.java
MooTrackView.java
report.txt

index ce110b254c46b1dd0f214654b63ad9fe401887d9..90ed18fd4acf3d582b7569f08f16c23b25fc4ebc 100644 (file)
@@ -2,7 +2,7 @@ import javax.sound.midi.*;
 import java.awt.event.*;
 
 /**
 import java.awt.event.*;
 
 /**
- * Functional representation of a MIDI note, which contains two MIDI events, note on and note off.
+ * A keyboard listener emulating a synthesizer.
  * 
  * @author  Einar Pehrson
  */
  * 
  * @author  Einar Pehrson
  */
index a71b3619f3a909c2d302ca41f7ed2ec47f55aa87..d3b9a8a754ce06c328d59570b316f2366fd64725 100644 (file)
@@ -12,17 +12,18 @@ import javax.sound.midi.*;
  
 public class MooTrackTitle extends JPanel {
 
  
 public class MooTrackTitle extends JPanel {
 
+       private Track track;
        private MetaMessage trackNameMessage;
        private MetaMessage trackNameMessage;
-       private String trackName = "";
        private ShortMessage programChangeMessage;
        private ShortMessage programChangeMessage;
-       private int channel = 0;
+
        private JTextField title;
        private MooInstrumentList instruments;
        private JComboBox channelBox;
        private JCheckBox mute;
        private JCheckBox solo;
        private JTextField title;
        private MooInstrumentList instruments;
        private JComboBox channelBox;
        private JCheckBox mute;
        private JCheckBox solo;
-       private Track track;
-       private int trackNum;
+
+       private String trackName = "";
+       private int trackNum, channel = 0;
 
        /** 
         * Creates the title bar.
 
        /** 
         * Creates the title bar.
index e6f614b1b3981dcb0e664c6cebbf3a2f36728214..854cfec806308b0680360ea5a0f41c1999b4301a 100644 (file)
@@ -27,7 +27,6 @@ public class MooTrackView extends JPanel {
                super(true);
                this.track = track;
 
                super(true);
                this.track = track;
 
-               extraHeight = Toolkit.getDefaultToolkit().getScreenSize().height - 150;
                // Configures panel
                setBackground(Color.white);
                setBorder(BorderFactory.createLineBorder(Color.black));
                // Configures panel
                setBackground(Color.white);
                setBorder(BorderFactory.createLineBorder(Color.black));
@@ -38,6 +37,7 @@ public class MooTrackView extends JPanel {
                MidiEvent note;
                MooNoteElement elem;
                rects = new ArrayList(track.size() / 2);
                MidiEvent note;
                MooNoteElement elem;
                rects = new ArrayList(track.size() / 2);
+               extraHeight = Toolkit.getDefaultToolkit().getScreenSize().height - 150;
 
                // Places note elements
                for (int i = 0; i < track.size(); i++) {
 
                // Places note elements
                for (int i = 0; i < track.size(); i++) {
@@ -56,11 +56,13 @@ public class MooTrackView extends JPanel {
 
                // Creates pop-up menu.
                popup = new JPopupMenu();
 
                // Creates pop-up menu.
                popup = new JPopupMenu();
-               menuItem = new JMenuItem("Add...");
+               menuItem = new JMenuItem("Add note...");
                // menuItem.addActionListener();
                popup.add(menuItem);
 
                // menuItem.addActionListener();
                popup.add(menuItem);
 
-               addMouseListener(new PopupListener());
+               // Adds listeners for popup menu and keyboard synthesizer.
+               addMouseListener(new MAdapter());
+               addKeyListener(new MooKeyboard());
        }
 
        public void layoutElement(MooNoteElement elem, boolean old){
        }
 
        public void layoutElement(MooNoteElement elem, boolean old){
@@ -140,11 +142,15 @@ public class MooTrackView extends JPanel {
                }
        }
 
                }
        }
 
-       class PopupListener extends MouseAdapter {
+       class MAdapter extends MouseAdapter {
                public void mousePressed(MouseEvent e) {
                        if (e.isPopupTrigger()) {
                                popup.show(e.getComponent(), e.getX(), e.getY());
                        }
                }
                public void mousePressed(MouseEvent e) {
                        if (e.isPopupTrigger()) {
                                popup.show(e.getComponent(), e.getX(), e.getY());
                        }
                }
+
+               public void mouseEntered(MouseEvent e) {
+                       // Moosique.setActiveChannel(track.getChannel());
+               }
        }
 }
        }
 }
index 34822770e7ed6ff2f96dcd4020ed701d79029afa..dd967f486af2bbd7f0a052f3d3e1e185bfafa321 100644 (file)
@@ -4,29 +4,31 @@ OBS! [...] = Hj
 \r
 1. Introduction\r
 \r
 \r
 1. Introduction\r
 \r
-The main goal with our project was to design and construct a midi-software developing program.\r
-Both for arranging and playing already existing midi-files, and for composing and saving midi-files from scratch.\r
-We chose this project for mainly two reasons. First, noone of us had previous experience of working with music in the Java language, so this would be a great challenge. Second, we are all quite interested in music.\r
+The purpose of our project was to design and construct a composer's tool for the MIDI interface. The program was to be used for composing and sequencing MIDI songs from scratch, as well as for playback and visualization of existing MIDI files. We chose this project for two reasons. Firstly, none of us had previous experience of working with music in the Java language, so the task of developing an application using an API with which we had no previous experience was challenging. Secondly, we are all very interested in music. One of the developers is also an experienced MIDI composer.\r
+
+The MIDI application we were going to develop was at an early stage given the name Moosique - a name obviously derived from the word music, but with a touch of moose.
 \r
 2. Analysis\r
 -----------------------------\r
 \r
 2. Analysis\r
 -----------------------------\r
-2.1 Java Soundpackage\r
-Our first step was to look at the Java Soundpackage, and to try to find out what limits the package had. Noone of us was familiar with the package and wanted to get an overview before we started working with the design document. We also had to look at some software that supported midi to get an idea what features our application might have.\r
+2.1 The Java MIDI Package\r
+Our first step was to look at the Java MIDI package (javax.sound.midi), and to try to find out what limitations the package had. As previously stated, none of us was familiar with the package and we all wanted to get an overview before we started working on the design document. And it didn't take long to realize that the functionality and structure of our application were largely dictated by the possibilities provided by the MIDI package. We also looked at software that supported MIDI to get an idea of which features our application might have.\r
 -----------------------------\r
 2.2 Design Document \r
 -----------------------------\r
 2.2 Design Document \r
-We realeased were quickly that most of the classes we had to construct was associated with the interface. We divided the program into two major parts. The main part, the actual program, included four functional classes. Our starting point was to make one class including the 'main method', we gave this class the name Moosique (an combination of moose and music). \r
+One of the first design decisions that was made was to divide the program into two major parts. The main part, the classes providing the actual features of the program, included four functional classes. The executable class, the only one containing a main method, was given the same name as the program - Moosique.\r
 \r
 \r
-Under the Moosique class we designed three classes that modifies different parts of an midi-file. \r
-MooSequence [...], MooTrack [...] and MooNote [...]. \r
+In a hierarchy below the Moosique class, we placed three classes that represented the different parts of a MIDI file: \r
+x MooSequence  The functional representation of a MIDI sequence. Was to extend Java's Sequence class.
+x MooTrack     The functional representation of a MIDI track. Was to extend Java's Track class.
+x MooNote      The functional representation of a MIDI note. Was to encompass the two MIDI events that constitute a note: NoteOn and NoteOff.
+
+The second part of the program was the graphical user interface, including all the graphical classes. The main class of the interface was named MooGUI. Since we had decided to use Swing in building the interface, this class was naturally to extend JFrame. Here, all other GUI components were to be created. Most of these components - maintaining different kinds of data, having listeners and requiring different methods for update their content - were to be quite complex, and were therefore given their own classes. Among these are graphical classes that construct the menu, the toolbar and the view of the MIDI tracks. All these classes [...]. \r
 \r
 \r
-The second part of the program includes the graphical classes. The top-class of the interface is a class called MooGUI that [...]. Under the interface top-class MooGUI we designed some graphical classes that constructs a menu, a statusbar and a toolbar. All these classes [...]. \r
+Apart from the strictly graphical classes we decided to make a graphical representation of the functional classes, this to get an better overview of our work [...]. MooView (a graphical representation of MooSequence), MooTrackView and MooTrackTitle (MooTrack), and MooNoteElement (MooNote). Supporting these components, some other graphical classes were needed: MooViewCounter, representing a ruler that visualizes the time signature of the MIDI file; MooTrackTitle, handling the properties of a track; and MooNoteElement, supplying a way of editing the properties of a note.\r
 \r
 \r
-Beside the strictly graphical classes we decided to make a graphical representation of the functional classes, this to get an better overview of our work [...]. MooView (an graphical representation of MooSequence), MooTrackView (MooTrack) and MooNoteElement (MooNote). To support these files some other graphical classes had to be designed. MooViewCounter represents an ruler that shows the timesignature of the midi-file, MooTrackTitle handles the properties of one track and MooNoteElement the properties of one note.\r
-\r
-We constructed this design document very quickly, maybe to quickly. We werent really clear how some of the functions in the Java Soundpackage worked. Later in the project we were forced to change what we earlier had planned, se section [Major Decissions]. \r
+We design the structure of the application very quickly, perhaps to quickly. We were not entirely certain of how the Java MIDI package worked. As our work with the project progressed, we were forced to reevaluate some of these design decisions and change the system design (see section [Major Decissions]).\r
 ------------------------------\r
 2.3 Time Schedule\r
 ------------------------------\r
 2.3 Time Schedule\r
-Before we started to implement the code we made an time-schedule for each class, and divided the classes between us. Later we realeased that for a few classes this time-schedule were very optimistic. The consequences of a misleading time-schedule were that some classes was not implemented before a very long time in the project.\r
+Before we started implement the classes, we made an time-schedule for each class, and divided the classes between us. Later we realeased that for a few classes this time-schedule were very optimistic. The consequences of a misleading time-schedule were that some classes was not implemented before a very long time in the project.\r
 ------------------------------\r
 2.4 Implemention\r
 As we earlier realised we needed to implement the functional classes first. This to see what references the graphical representation might call. [...]\r
 ------------------------------\r
 2.4 Implemention\r
 As we earlier realised we needed to implement the functional classes first. This to see what references the graphical representation might call. [...]\r
@@ -34,7 +36,11 @@ As we earlier realised we needed to implement the functional classes first. This
 ------------------------------\r
 2.5 Testing\r
 ------------------------------\r
 ------------------------------\r
 2.5 Testing\r
 ------------------------------\r
-2.6 Major Decissions\r
+2.6 Major Decisions\r
+
+2.6.1 Removing some of the functional classes
+Initially, the idea behind the functional classes - MooSequence, MooTrack and MooNote - was that they would extend the classes provided by the Java MIDI API and provide additional functionality for simplifying data manipulation. Soon however, it was discovered that this was not possible because of the methods related to these classes in the API. It was then decided that these classes would imitate the data hierarchy of the MIDI file, as the Java classes do, but provide their own implementations. When the edited sequence was to be sent to the synthesizer for playback, the data would be assembled and inserted into the Java classes. At a later stage, this design was also scrapped, the reason being that creating and maintaining such a data structure would require more code than using the somewhat limited methods of the API. MooSequence and MooTrack was therefore removed.\r
+
 [...]\r
 ------------------------------\r
 2.7 Problems\r
 [...]\r
 ------------------------------\r
 2.7 Problems\r
@@ -44,11 +50,15 @@ As we earlier realised we needed to implement the functional classes first. This
 \r
 \r
 4. References\r
 \r
 \r
 4. References\r
+
+LITTERATURE
+Sun Microsystems Inc. (2002) Java Sound API Programmer's Guide [http://java.sun.com/j2se/1.4.1/docs/guide/sound/programmer_guide/]
+Horstmann, Cay (2003) Computing Concepts with Java Essentials (3rd Edition), New York: John Wiley & Sons Inc.
+Jia, Xiao-Ping\r
+Code Complete\r
+
+APPLICATIONS
 FastTracker II\r
 MidiSoft Recording Session\r
 CakeWalk 5\r
 FastTracker II\r
 MidiSoft Recording Session\r
 CakeWalk 5\r
-Cubase SX 1.0\r
-\r
-Jia\r
-Code complete\r
-och den första java boken
\ No newline at end of file
+Cubase SX 1.0