From 65ea2a43eb97459592d222ea00082e46343c9d8b Mon Sep 17 00:00:00 2001 From: Einar Pehrson Date: Fri, 16 May 2003 13:34:36 +0000 Subject: [PATCH] *** empty log message *** --- MooNote.java | 3 +-- MooNoteElement.java | 2 +- MooTrackView.java | 6 +++--- Moosique.java | 43 +++---------------------------------------- To Do.txt | 12 +----------- report.txt | 6 ++++-- 6 files changed, 13 insertions(+), 59 deletions(-) diff --git a/MooNote.java b/MooNote.java index d401aa7..cd71ffb 100644 --- a/MooNote.java +++ b/MooNote.java @@ -36,14 +36,13 @@ public class MooNote extends MidiEvent { /** * Creates a MooNote of the given pitch, velocity and duration in the current track. - * @param track the track to which the MooNote was added * @param channel the channel of the note (1-16) * @param pitch the pitch of the note (0-127) * @param velocity the velocity of the note (0-127) * @param timestamp the timestamp of the note in ticks (96 per beat) * @param duration the duration of the note in ticks (96 per beat) */ - public MooNote (int track, int channel, int pitch, int velocity, long timestamp, int duration) { + public MooNote (int channel, int pitch, int velocity, long timestamp, int duration) { super(new ShortMessage(), timestamp); noteOffEvent = new MidiEvent(new ShortMessage(), timestamp + duration); noteOnMsg = (ShortMessage)getMessage(); diff --git a/MooNoteElement.java b/MooNoteElement.java index 7488d15..e93eb29 100644 --- a/MooNoteElement.java +++ b/MooNoteElement.java @@ -154,7 +154,7 @@ public class MooNoteElement extends JPanel { } protected void remove(){ - mtv.remove(this); + mtv.removeNote(this, note); } } diff --git a/MooTrackView.java b/MooTrackView.java index b063554..1a612e4 100644 --- a/MooTrackView.java +++ b/MooTrackView.java @@ -66,7 +66,7 @@ public class MooTrackView extends JPanel { addKeyListener(new MooKeyboard()); } - public void layoutElementMooNoteElement elem, boolean old){ + public void layoutElement(MooNoteElement elem, boolean old){ // If the element is currently in the view, removes its coordinates from the list. Rectangle r = new Rectangle(); if (old){ @@ -101,7 +101,6 @@ public class MooTrackView extends JPanel { viewLength = y + height; if(old)setPreferredSize(new Dimension(VIEW_WIDTH, viewLength + extraHeight)); } - } public Track getTrack() { @@ -169,8 +168,9 @@ public class MooTrackView extends JPanel { public void actionPerformed(ActionEvent e) { Object source = e.getSource(); if (source == popupAdd) { - addNote(new MooNote()); + //addNote(new MooNote()); // int channel, int pitch, int velocity, long timestamp, int duration + } } } } \ No newline at end of file diff --git a/Moosique.java b/Moosique.java index c513364..91cf4ff 100644 --- a/Moosique.java +++ b/Moosique.java @@ -153,6 +153,7 @@ public class Moosique { try { seq = new Sequence(Sequence.PPQ, DEFAULT_RESOLUTION, DEFAULT_TRACKS); sequencer.setSequence(seq); + emptyTracks = new ArrayList(); } catch (InvalidMidiDataException e) {} // Sends sequence to GUI. if (gui != null) gui.setSequence(seq); @@ -204,7 +205,8 @@ public class Moosique { // Puts the thread to sleep for as long as it takes // the sequencer to reach the next sixteenth. try { - sleep((long)((15000 / getTempo()) * (tickDiff / ticksPerSixteenth))); + //sleep((long)((15000 / getTempo()) * (tickDiff / ticksPerSixteenth))); + sleep (10); } catch (InterruptedException e) { Moosique.stop(); } @@ -425,45 +427,6 @@ public class Moosique { } } - /* - Collections.sort(track[i].events, new Comparator() { - public int compare(Object o1, Object o2) { - return ((MidiEvent)o2).getTick() - ((MidiEvent)o1).getTick(); - } - }); - - // Searches the sequence for NoteOn events - MidiEvent noteOn, noteOff = null, nextEvent; - MidiMessage nextMsg; - ShortMessage shortMsg; - - for (int i = 0; i < tracks.length; i++) { - for (int j = 0; j < tracks[i].size(); j++) { - noteOn = tracks[i].get(j); - if (noteOn.getMessage().getStatus() == ShortMessage.NOTE_ON) { - // Finds the corresponding NoteOff event - for (int k = j + 1; k < tracks[i].size(); k++) { - nextEvent = tracks[i].get(k); - nextMsg = nextEvent.getMessage(); - if (nextMsg instanceof ShortMessage) { - shortMsg = (ShortMessage) nextMsg; - if (shortMsg.getCommand() == ShortMessage.NOTE_OFF && shortMsg.getChannel() == ((ShortMessage)noteOn.getMessage()).getChannel() && shortMsg.getData1() == ((ShortMessage)noteOn.getMessage()).getData1()) { - noteOff = nextEvent; - break; - } - } - } - // Replaces the NoteOn event with a MooNote, if possible with the corresponding NoteOff event - tracks[i].remove(noteOn); - if (noteOff != null) { - tracks[i].add(new MooNote(noteOn, noteOff)); - } else { - tracks[i].add(new MooNote(noteOn)); - } - } - } - } -*/ // Sends sequence to GUI and sequencer, then returns if (gui != null) gui.setSequence(seq); try { diff --git a/To Do.txt b/To Do.txt index 1a6bc85..b598436 100644 --- a/To Do.txt +++ b/To Do.txt @@ -21,24 +21,14 @@ x x Fixa InstrumentList. x Fixa så att toolbarens rutor sitter fast! -x Visualisera inte tomma spår! x Räkna ut tempo och taktart. Skicka (på nåt sätt) tempovektorn till MooToolbar. x Gör en ruta för tempot i MooToolbar. x Gör en ruta för taktarten i MooViews övre vänstra hörn. x Implementera klart menyn, med alla dialoger. +x Lägg till en tom panel i MooGUI för att fylla ut skärmen. Använd setBounds() x Highlighta noter som spelas? (Enligt kravspec.) - -MooNote / MooTrackView / MooNoteElement - - * Hur lägga till MooNote och NoteOff? - Internt vid skapandet - Då behövs track MooNote.addTo(Track track); - MooNote.removeFrom(Track track); - Externt new MooNote(...); - ...add(MooNote); - ...add(MooNote.getNoteOffEvent()); - MooNoteProp * Textfält som gör att man bara kan skriva in siffror? diff --git a/report.txt b/report.txt index 3ea52d1..bbdb98b 100644 --- a/report.txt +++ b/report.txt @@ -58,13 +58,15 @@ x MooKeyboard A keyboard listener emulating a synthesizer. One class, MooStatus, was also removed. It was reduced to a JLabel with a single method and was therefore merged inte the main GUI class. ------------------------------ 2.7 Problems -Of all the problems we have come across in our work with Moosique, only one has persisted and is yet unresolved. As always when working with Java, we were aware that the visualisation performance leaves more to be desired. But we did not expect the extremely low performance the program displayed. During playback, a thread updates the view port of the main scroll pane (MooView). However, the update delay on low-end hardware exceeds one second. This obviously makes the GUI unresponsive, but also affects synthesizer playback performance. In order for the application to work properly, this delay must at the very least fall below the time it takes the synthesizer to play a sixteenth note. In a sequence of standard tempo, 120 beats per minute, this would mean 1/8 of a second. +Of all the problems we have come across in our work with Moosique, only one persisted and was until very recently unresolved. As always when working with Java, we were aware that the visualisation performance leaves more to be desired. But we did not expect the extremely low performance the program displayed. During playback, a thread updates the view port of the main scroll pane (MooView). However, the update delay on low-end hardware exceeded one second. This obviously made the GUI unresponsive, but also affected synthesizer playback performance. In order for the application to work properly, this delay must at the very least fall below the time it takes the synthesizer to play a sixteenth note. In a sequence of standard tempo, 120 beats per minute, this would mean 1/8 of a second. -This problem is especially unfortunate since it was the only performance aspect that was mentioned in the requirements specification. +This problem was especially unfortunate since it was the only performance aspect that was mentioned in the requirements specification. [Ändra font och dra ner textstorlek, citat juh!] "Delays during execution should be minimized, but are allowed when loading files. Playback should be smooth and delays should not change the beat or tempo." +However, as we recently discovered, + The major changes and that not enough work design of the graphical classes resulted in that the different graphical classes couldn't be implemented on their own. Instead changes often had to take place in many different classes when some feature was added. This made the implementation slow, especially in the beginning, since there where many different ideas on how things should be implemented. This got better through time though, when the basic foundation was implemented it got easier to add the rest of the features. ------------------------------ 3. Conclusions -- 2.39.2