From 4e7d6f8b7dd7fbcef2282674b5442d78cf220489 Mon Sep 17 00:00:00 2001 From: Einar Pehrson Date: Thu, 10 Apr 2003 09:28:30 +0000 Subject: [PATCH] Started on Moosique and MooNote. Changed comment in the others. --- MooGUI.java | 6 +++--- MooMenu.java | 6 +++--- MooNote.java | 36 +++++++++++++++++++------------ MooNoteElement.java | 6 +++--- MooSequence.java | 21 +++++++++--------- MooStatus.java | 6 +++--- MooToolbar.java | 6 +++--- MooTrack.java | 47 +++++++++++++++++++++++----------------- MooTrackTitle.java | 6 +++--- MooTrackView.java | 6 +++--- MooView.java | 6 +++--- MooViewCounter.java | 6 +++--- Moosique.java | 52 ++++++++++++++++++++++++++++----------------- 13 files changed, 121 insertions(+), 89 deletions(-) diff --git a/MooGUI.java b/MooGUI.java index 22ccb53..dcb52da 100644 --- a/MooGUI.java +++ b/MooGUI.java @@ -1,6 +1,6 @@ import javax.swing.*; -/** +/* * Moosique's graphical user interface. * * @author Andersson, Andreen, Lanneskog, Pehrson @@ -9,14 +9,14 @@ import javax.swing.*; public class MooGUI { - /** + /* * Creates the GUI. */ public MooGUI () { } - /** + /* * */ public void () { diff --git a/MooMenu.java b/MooMenu.java index 2d5c20a..cac3be4 100644 --- a/MooMenu.java +++ b/MooMenu.java @@ -1,6 +1,6 @@ import javax.swing.*; -/** +/* * * * @author Andersson, Andreen, Lanneskog, Pehrson @@ -9,14 +9,14 @@ import javax.swing.*; public class MooMenu { - /** + /* * Creates the menus. */ public MooMenu () { } - /** + /* * */ public void () { diff --git a/MooNote.java b/MooNote.java index edd8159..826b4c3 100644 --- a/MooNote.java +++ b/MooNote.java @@ -1,6 +1,6 @@ import javax.sound.midi.*; -/** +/* * Functional representation of a MIDI note, which contains two MIDI events, note on and note off. * * @author Andersson, Andreen, Lanneskog, Pehrson @@ -9,16 +9,26 @@ import javax.sound.midi.*; public class MooNote { - private MidiEvent noteOn, noteOff; + private MidiEvent noteOnEvent, noteOffEvent; + private ShortMessage noteOnMsg, noteOffMsg; + private long noteOnTime, noteOffTime; - /** + /* * Creates a MooNote of the given pitch, velocity and length in the current track. */ public MooNote (int pitch, int velocity, int length) { - + // MidiEvent(MidiMessage message, long tick) + noteOnMsg = new ShortMessage(); + noteOffMsg = new ShortMessage(); + noteOnMsg.setMessage(ShortMessage.NOTE_ON, top.getChannel(), pitch, velocity); + noteOffMsg.setMessage(ShortMessage.NOTE_OFF, top.getChannel(), pitch, velocity); +// noteOnTime = ???; + noteOffTime = noteOnTime + length; + noteOnEvent = new MidiEvent(noteOnMsg, noteOnTime) + noteOffEvent = new MidiEvent(noteOffMsg, noteOffTime) } - /** + /* * Sets the pitch of the current note. + @param pitch the pitch of the note (0-127) */ @@ -26,7 +36,7 @@ public class MooNote { } - /** + /* * Sets the velocity of the current note. + @param vel the velocity of the note (0-127) */ @@ -34,7 +44,7 @@ public class MooNote { } - /** + /* * Sets the length of the current note (or rather moves the note off event). + @param n the length of the note in ticks (100 per beat) */ @@ -42,7 +52,7 @@ public class MooNote { } - /** + /* * Returns the note on event of the current note. * @return the note on MidiEvent */ @@ -50,7 +60,7 @@ public class MooNote { } - /** + /* * Returns the note off event of the current note. * @return the note off MidiEvent */ @@ -58,7 +68,7 @@ public class MooNote { } - /** + /* * Returns the pitch of the current note. * @return the pitch of the note */ @@ -66,7 +76,7 @@ public class MooNote { } - /** + /* * Returns the velocity of the current note. * @return the velocity of the note */ @@ -74,11 +84,11 @@ public class MooNote { } - /** + /* * Returns the length of the current note. * @return the length of the note */ public int getLength() { } -} +} \ No newline at end of file diff --git a/MooNoteElement.java b/MooNoteElement.java index 60f153a..8471b53 100644 --- a/MooNoteElement.java +++ b/MooNoteElement.java @@ -1,6 +1,6 @@ import javax.swing.*; -/** +/* * Graphical representation of a MIDI note. * * @author Andersson, Andreen, Lanneskog, Pehrson @@ -9,14 +9,14 @@ import javax.swing.*; public class MooNoteElement { - /** + /* * Creates a new note element. */ public MooNoteElement () { } - /** + /* * */ public void () { diff --git a/MooSequence.java b/MooSequence.java index 8b4c4e7..b37424e 100644 --- a/MooSequence.java +++ b/MooSequence.java @@ -1,23 +1,24 @@ import javax.sound.midi.*; -/** +/* * Functional representation of a MIDI sequence. + * * @author Andersson, Andreen, Lanneskog, Pehrson - * @version 1.1 + * @version 1 */ public class MooSequence { private Collection tracks; - /** + /* * Creates a MooSequence with three tracks. */ public MooSequence () { } - /** + /* * Returns a pointer to the specified track. * @param track the number of the track (0-31) * @return the specified track @@ -26,7 +27,7 @@ public class MooSequence { } - /** + /* * Returns the number of tracks in the current sequence. * @return the number of the tracks */ @@ -34,7 +35,7 @@ public class MooSequence { } - /** + /* * Creates a new track after the specified track. * @param track the number of the track (0-31) */ @@ -42,7 +43,7 @@ public class MooSequence { } - /** + /* * Deletes the specified track. * @param track the number of the track (0-31) */ @@ -50,7 +51,7 @@ public class MooSequence { } - /** + /* * Returns the Java Sequence object of the current sequence. * @return a Sequence */ @@ -58,10 +59,10 @@ public class MooSequence { } - /** + /* * Resets the solo and mute settings of all tracks. */ public void activateTracks() { } -} +} \ No newline at end of file diff --git a/MooStatus.java b/MooStatus.java index 101dd72..0f70b6c 100644 --- a/MooStatus.java +++ b/MooStatus.java @@ -1,6 +1,6 @@ import javax.swing.*; -/** +/* * * * @author Andersson, Andreen, Lanneskog, Pehrson @@ -9,14 +9,14 @@ import javax.swing.*; public class MooStatus { - /** + /* * Creates the status bar. */ public MooStatus () { } - /** + /* * */ public void () { diff --git a/MooToolbar.java b/MooToolbar.java index 887fd8e..7ba77d6 100644 --- a/MooToolbar.java +++ b/MooToolbar.java @@ -1,6 +1,6 @@ import javax.swing.*; -/** +/* * * * @author Andersson, Andreen, Lanneskog, Pehrson @@ -9,14 +9,14 @@ import javax.swing.*; public class Moo { - /** + /* * Creates the toolbar. */ public MooToolbar () { } - /** + /* * */ public void () { diff --git a/MooTrack.java b/MooTrack.java index f9d51f3..df542a6 100644 --- a/MooTrack.java +++ b/MooTrack.java @@ -1,6 +1,6 @@ import javax.sound.midi.*; -/** +/* * Functional representation of a MIDI track. * * @author Andersson, Andreen, Lanneskog, Pehrson @@ -12,18 +12,25 @@ public class MooTrack { private Collection notes; private int channel; private int instrument; - private boolean solo; - private boolean mute; + private boolean solo = false; + private boolean mute = false; - - /** + /* * Creates an empty MooTrack. */ public MooTrack () { } - /** + /* + * Sets the MIDI instrument of the current track. + * @param instr the number of the MIDI instrument (0-127) + */ + public void setInstrument(int instr) { + + } + + /* * Sets the MIDI channel of the current track. * @param chan the number of the MIDI channel (1-16) */ @@ -31,23 +38,23 @@ public class MooTrack { } - /** - * Sets the MIDI instrument of the current track. - * @param instr the number of the MIDI instrument (0-127) + /* + * Returns the MIDI channel of the current track. + * @return the number of the channel */ - public void setInstrument(int instr) { + public int getChannel() { } - /** + /* * Returns the number of notes in the current track. * @return the number of notes */ - public void getNumberOfNotes() { + public int getNumberOfNotes() { } - /** + /* * Adds the given note to the current track. * @param note the MooNote to add */ @@ -55,7 +62,7 @@ public class MooTrack { } - /** + /* * Deletes the given note to the current track. * @param note the MooNote to delete */ @@ -63,7 +70,7 @@ public class MooTrack { } - /** + /* * Returns the note of the given index. * @param note the index of the note */ @@ -71,7 +78,7 @@ public class MooTrack { } - /** + /* * Makes the current track solo. * @param set if the track should be solo */ @@ -79,7 +86,7 @@ public class MooTrack { } - /** + /* * Mutes the current track. * @param set if the track should be muted */ @@ -87,7 +94,7 @@ public class MooTrack { } - /** + /* * Checks if the current track is solo. * @return if the track is solo */ @@ -96,11 +103,11 @@ public class MooTrack { } - /** + /* * Checks if the current track is muted. * @return if the track is muted */ public boolean isMute() { } -} +} \ No newline at end of file diff --git a/MooTrackTitle.java b/MooTrackTitle.java index 3090852..4908267 100644 --- a/MooTrackTitle.java +++ b/MooTrackTitle.java @@ -1,6 +1,6 @@ import javax.swing.*; -/** +/* * The title bar for each track with track name, channel, instrument etc. * * @author Andersson, Andreen, Lanneskog, Pehrson @@ -9,14 +9,14 @@ import javax.swing.*; public class MooTrackTitle { - /** + /* * Creates the title bar. */ public MooTrackTitle () { } - /** + /* * */ public void () { diff --git a/MooTrackView.java b/MooTrackView.java index 83ef2f5..92a662b 100644 --- a/MooTrackView.java +++ b/MooTrackView.java @@ -1,6 +1,6 @@ import javax.swing.*; -/** +/* * * * @author Andersson, Andreen, Lanneskog, Pehrson @@ -9,14 +9,14 @@ import javax.swing.*; public class MooTrackView { - /** + /* * Creates */ public MooTrackView () { } - /** + /* * */ public void () { diff --git a/MooView.java b/MooView.java index c5cc49d..55bea7f 100644 --- a/MooView.java +++ b/MooView.java @@ -1,6 +1,6 @@ import javax.swing.*; -/** +/* * * * @author Andersson, Andreen, Lanneskog, Pehrson @@ -9,14 +9,14 @@ import javax.swing.*; public class MooView { - /** + /* * Creates */ public MooView () { } - /** + /* * */ public void () { diff --git a/MooViewCounter.java b/MooViewCounter.java index 45a9280..db6a036 100644 --- a/MooViewCounter.java +++ b/MooViewCounter.java @@ -1,6 +1,6 @@ import javax.swing.*; -/** +/* * * * @author Andersson, Andreen, Lanneskog, Pehrson @@ -9,14 +9,14 @@ import javax.swing.*; public class MooViewCounter { - /** + /* * Creates */ public MooViewCounter () { } - /** + /* * */ public void () { diff --git a/Moosique.java b/Moosique.java index 720d0c8..8edc142 100644 --- a/Moosique.java +++ b/Moosique.java @@ -1,8 +1,8 @@ import javax.sound.midi.*; import java.io.*; -/** - * Moosique - The trackers approach to MIDI +/* + * Moosique - The MIDI Tracker * * Main class that handles initiation, IO and sound FX. * @@ -13,46 +13,60 @@ import java.io.*; public class Moosique { private static MooGUI gui; - private static MooSequence seq; + private static MooSequence mooSeq; + private static Sequence seq; + private static Sequencer sequencer = null; private static String filename; - /** - * Runs the application. + /* + * Starts the application. */ public static void main (String[] args) { + // Creates song and GUI + seq = new MooSequence(); + gui = new MooGUI(mooSeq); + // Initializes MIDI sequencer + try { + sequencer = MidiSystem.getSequencer(); + sequencer.open(); + } catch (MidiUnavailableException e) { + System.exit(0); + } } - /** + /* * Returns a pointer to the current sequence. * @return the current sequence */ public static MooSequence getSequence() { - + return mooSeq; } - /** + /* * Starts playback of the current sequence. */ public static void play() { - + seq = mooSeq.getSequence(); + sequencer.setSequence(seq); + sequencer.start(); } - /** + /* * Pauses playback of the current sequence. */ public static void pause() { } - /** + /* * Stops playback of the current sequence. */ public static void stop() { - + sequencer.stop(); } - /** + /* * Rewinds the current sequence the given number of measures. * @param measures the number of measures to rewind */ @@ -60,7 +74,7 @@ public class Moosique { } - /** + /* * Fast forwards the current sequence the given number of measures. * @param measures the number of measures to fast forward */ @@ -68,7 +82,7 @@ public class Moosique { } - /** + /* * Loads the MooSequence in the given file. * @param filename the filename to use */ @@ -76,7 +90,7 @@ public class Moosique { } - /** + /* * Saves the current sequence to the given filename * @param filename the filename to use */ @@ -84,18 +98,18 @@ public class Moosique { } - /** + /* * Saves the current sequence to the previously given filename. */ public static void save() throws IOException { } - /** + /* * Exports the current sequence to a standard MIDI file. * @param filename the filename to use */ public static void exportMIDI(String filename) throws IOException { } -} +} \ No newline at end of file -- 2.39.2