From e49990e17bff158ad638a16ba4aa616673b94627 Mon Sep 17 00:00:00 2001 From: Einar Pehrson Date: Thu, 15 May 2003 21:08:18 +0000 Subject: [PATCH] Readded the MooKeyboard listener to MooTrackView. Updated the project report. --- MooKeyboard.java | 2 +- MooTrackTitle.java | 9 +++++---- MooTrackView.java | 14 ++++++++++---- report.txt | 48 ++++++++++++++++++++++++++++------------------ 4 files changed, 45 insertions(+), 28 deletions(-) diff --git a/MooKeyboard.java b/MooKeyboard.java index ce110b2..90ed18f 100644 --- a/MooKeyboard.java +++ b/MooKeyboard.java @@ -2,7 +2,7 @@ import javax.sound.midi.*; 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 */ diff --git a/MooTrackTitle.java b/MooTrackTitle.java index a71b361..d3b9a8a 100644 --- a/MooTrackTitle.java +++ b/MooTrackTitle.java @@ -12,17 +12,18 @@ import javax.sound.midi.*; public class MooTrackTitle extends JPanel { + private Track track; private MetaMessage trackNameMessage; - private String trackName = ""; private ShortMessage programChangeMessage; - private int channel = 0; + 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. diff --git a/MooTrackView.java b/MooTrackView.java index e6f614b..854cfec 100644 --- a/MooTrackView.java +++ b/MooTrackView.java @@ -27,7 +27,6 @@ public class MooTrackView extends JPanel { super(true); this.track = track; - extraHeight = Toolkit.getDefaultToolkit().getScreenSize().height - 150; // 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); + extraHeight = Toolkit.getDefaultToolkit().getScreenSize().height - 150; // 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(); - menuItem = new JMenuItem("Add..."); + menuItem = new JMenuItem("Add note..."); // 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){ @@ -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 mouseEntered(MouseEvent e) { + // Moosique.setActiveChannel(track.getChannel()); + } } } diff --git a/report.txt b/report.txt index 3482277..dd967f4 100644 --- a/report.txt +++ b/report.txt @@ -4,29 +4,31 @@ OBS! [...] = Hj 1. Introduction -The main goal with our project was to design and construct a midi-software developing program. -Both for arranging and playing already existing midi-files, and for composing and saving midi-files from scratch. -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. +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. + +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. 2. Analysis ----------------------------- -2.1 Java Soundpackage -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. +2.1 The Java MIDI Package +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. ----------------------------- 2.2 Design Document -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). +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. -Under the Moosique class we designed three classes that modifies different parts of an midi-file. -MooSequence [...], MooTrack [...] and MooNote [...]. +In a hierarchy below the Moosique class, we placed three classes that represented the different parts of a MIDI file: +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 [...]. -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 [...]. +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. -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. - -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]. +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]). ------------------------------ 2.3 Time Schedule -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. +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. ------------------------------ 2.4 Implemention As we earlier realised we needed to implement the functional classes first. This to see what references the graphical representation might call. [...] @@ -34,7 +36,11 @@ As we earlier realised we needed to implement the functional classes first. This ------------------------------ 2.5 Testing ------------------------------ -2.6 Major Decissions +2.6 Major Decisions + +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. + [...] ------------------------------ 2.7 Problems @@ -44,11 +50,15 @@ As we earlier realised we needed to implement the functional classes first. This 4. References + +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 +Code Complete + +APPLICATIONS FastTracker II MidiSoft Recording Session CakeWalk 5 -Cubase SX 1.0 - -Jia -Code complete -och den första java boken \ No newline at end of file +Cubase SX 1.0 -- 2.39.2