-Synthesizer
+\f
+Synthesizer
+
Instrument[] getAvailableInstruments()
-Obtains a list of instruments that come with the synthesizer.
+ Obtains a list of instruments that come with the synthesizer.
MidiChannel[] getChannels()
-Obtains the set of MIDI channels controlled by this synthesizer.
+ Obtains the set of MIDI channels controlled by this synthesizer.
Soundbank getDefaultSoundbank()
-Obtains the default soundbank for the synthesizer, if one exists.
+ Obtains the default soundbank for the synthesizer, if one exists.
long getLatency()
-Obtains the processing latency incurred by this synthesizer, expressed in microseconds.
+ Obtains the processing latency incurred by this synthesizer, expressed in microseconds.
Instrument[] getLoadedInstruments()
-Obtains a list of the instruments that are currently loaded onto this Synthesizer.
+ Obtains a list of the instruments that are currently loaded onto this Synthesizer.
int getMaxPolyphony()
-Obtains the maximum number of notes that this synthesizer can sound simultaneously.
+ Obtains the maximum number of notes that this synthesizer can sound simultaneously.
VoiceStatus[] getVoiceStatus()
-Obtains the current status of the voices produced by this synthesizer.
+ Obtains the current status of the voices produced by this synthesizer.
boolean isSoundbankSupported(Soundbank soundbank)
-Informs the caller whether this synthesizer is capable of loading instruments from the specified soundbank.
+ Informs the caller whether this synthesizer is capable of loading instruments from the specified soundbank.
boolean loadAllInstruments(Soundbank soundbank)
-Loads onto the Synthesizer all instruments contained in the specified Soundbank.
+ Loads onto the Synthesizer all instruments contained in the specified Soundbank.
boolean loadInstrument(Instrument instrument)
-Makes a particular instrument available for synthesis.
+ Makes a particular instrument available for synthesis.
boolean loadInstruments(Soundbank soundbank, Patch[] patchList)
-Loads the instruments referenced by the specified patches, from the specified Soundbank.
+ Loads the instruments referenced by the specified patches, from the specified Soundbank.
boolean remapInstrument(Instrument from, Instrument to)
-Remaps an instrument.
+ Remaps an instrument.
void unloadAllInstruments(Soundbank soundbank)
-Unloads all instruments contained in the specified Soundbank.
+ Unloads all instruments contained in the specified Soundbank.
void unloadInstrument(Instrument instrument)
-Unloads a particular instrument.
+ Unloads a particular instrument.
void unloadInstruments(Soundbank soundbank, Patch[] patchList)
-Unloads the instruments referenced by the specified patches, from the MIDI sound bank specified.
+ Unloads the instruments referenced by the specified patches, from the MIDI sound bank specified.
\f
Sequencer
-
+
int[] addControllerEventListener(ControllerEventListener listener, int[] controllers)
-Registers a controller event listener to receive notification whenever the sequencer processes a control-change event of the requested type or types.
+ Registers a controller event listener to receive notification whenever
+ the sequencer processes a control-change event of the requested type or types.
boolean addMetaEventListener(MetaEventListener listener)
-Registers a meta-event listener to receive notification whenever a meta-event is encountered in the sequence and processed by the sequencer.
+ Registers a meta-event listener to receive notification whenever
+ a meta-event is encountered in the sequence and processed by the sequencer.
Sequencer.SyncMode getMasterSyncMode()
-Obtains the current master synchronization mode for this sequencer.
+ Obtains the current master synchronization mode for this sequencer.
Sequencer.SyncMode[] getMasterSyncModes()
-Obtains the set of master synchronization modes supported by this sequencer.
+ Obtains the set of master synchronization modes supported by this sequencer.
long getMicrosecondLength()
-Obtains the length of the current sequence, expressed in microseconds.
+ Obtains the length of the current sequence, expressed in microseconds.
long getMicrosecondPosition()
-Obtains the current position in the sequence, expressed in microseconds.
+ Obtains the current position in the sequence, expressed in microseconds.
Sequence getSequence()
-Obtains the sequence on which the Sequencer is currently operating.
+ Obtains the sequence on which the Sequencer is currently operating.
Sequencer.SyncMode getSlaveSyncMode()
-Obtains the current slave synchronization mode for this sequencer.
+ Obtains the current slave synchronization mode for this sequencer.
Sequencer.SyncMode[] getSlaveSyncModes()
-Obtains the set of slave synchronization modes supported by the sequencer.
+ Obtains the set of slave synchronization modes supported by the sequencer.
float getTempoFactor()
-Returns the current tempo factor for the sequencer.
+ Returns the current tempo factor for the sequencer.
float getTempoInBPM()
-Obtains the current tempo, expressed in beats per minute.
+ Obtains the current tempo, expressed in beats per minute.
float getTempoInMPQ()
-Obtains the current tempo, expressed in microseconds per quarter note.
+ Obtains the current tempo, expressed in microseconds per quarter note.
long getTickLength()
-Obtains the length of the current sequence, expressed in MIDI ticks.
+ Obtains the length of the current sequence, expressed in MIDI ticks.
long getTickPosition()
-Obtains the current position in the sequence, expressed in MIDI ticks.
+ Obtains the current position in the sequence, expressed in MIDI ticks.
boolean getTrackMute(int track)
-Obtains the current mute state for a track.
+ Obtains the current mute state for a track.
boolean getTrackSolo(int track)
-Obtains the current solo state for a track.
+ Obtains the current solo state for a track.
boolean isRecording()
-Indicates whether the Sequencer is currently recording.
+ Indicates whether the Sequencer is currently recording.
boolean isRunning()
-Indicates whether the Sequencer is currently running.
+ Indicates whether the Sequencer is currently running.
void recordDisable(Track track)
-Disables recording to the specified track.
+ Disables recording to the specified track.
void recordEnable(Track track, int channel)
-Prepares the specified track for recording events received on a particular channel.
+ Prepares the specified track for recording events received on a particular channel.
int[] removeControllerEventListener(ControllerEventListener listener, int[] controllers)
-Removes a controller event listener's interest in one or more types of controller event.
+ Removes a controller event listener's interest in one or more types of controller event.
void removeMetaEventListener(MetaEventListener listener)
-Removes the specified meta-event listener from this sequencer's list of registered listeners, if in fact the listener is registered.
+ Removes the specified meta-event listener from this sequencer's
+ list of registered listeners, if in fact the listener is registered.
void setMasterSyncMode(Sequencer.SyncMode sync)
-Sets the source of timing information used by this sequencer.
+ Sets the source of timing information used by this sequencer.
void setMicrosecondPosition(long microseconds)
-Sets the current position in the sequence, expressed in microseconds
+ Sets the current position in the sequence, expressed in microseconds
void setSequence(InputStream stream)
-Sets the current sequence on which the sequencer operates.
+ Sets the current sequence on which the sequencer operates.
void setSequence(Sequence sequence)
-Sets the current sequence on which the sequencer operates.
+ Sets the current sequence on which the sequencer operates.
void setSlaveSyncMode(Sequencer.SyncMode sync)
-Sets the slave synchronization mode for the sequencer.
+ Sets the slave synchronization mode for the sequencer.
void setTempoFactor(float factor)
-Scales the sequencer's actual playback tempo by the factor provided.
+ Scales the sequencer's actual playback tempo by the factor provided.
void setTempoInBPM(float bpm)
-Sets the tempo in beats per minute.
+ Sets the tempo in beats per minute.
void setTempoInMPQ(float mpq)
-Sets the tempo in microseconds per quarter note.
+ Sets the tempo in microseconds per quarter note.
void setTickPosition(long tick)
-Sets the current sequencer position in MIDI ticks
+ Sets the current sequencer position in MIDI ticks
void setTrackMute(int track, boolean mute)
-Sets the mute state for a track.
+ Sets the mute state for a track.
void setTrackSolo(int track, boolean solo)
-Sets the solo state for a track.
+ Sets the solo state for a track.
void start()
-Starts playback of the MIDI data in the currently loaded sequence.
+ Starts playback of the MIDI data in the currently loaded sequence.
void startRecording()
-Starts recording and playback of MIDI data.
+ Starts recording and playback of MIDI data.
void stop()
-Stops recording, if active, and playback of the currently loaded sequence, if any.
+ Stops recording, if active, and playback of the currently loaded sequence, if any.
void stopRecording()
-Stops recording, if active.
+ Stops recording, if active.
\f
MidiChannel
-
+
void allNotesOff()
-Turns off all notes that are currently sounding on this channel.
+ Turns off all notes that are currently sounding on this channel.
void allSoundOff()
-Immediately turns off all sounding notes on this channel, ignoring the state of the Hold Pedal and the internal decay rate of the current Instrument.
+ Immediately turns off all sounding notes on this channel,
+ ignoring the state of the Hold Pedal and the internal decay rate of the current Instrument.
void controlChange(int controller, int value)
-Reacts to a change in the specified controller's value.
+ Reacts to a change in the specified controller's value.
int getChannelPressure()
-Obtains the channel's keyboard pressure.
+ Obtains the channel's keyboard pressure.
int getController(int controller)
-Obtains the current value of the specified controller.
+ Obtains the current value of the specified controller.
boolean getMono()
-Obtains the current mono/poly mode.
+ Obtains the current mono/poly mode.
boolean getMute()
-Obtains the current mute state for this channel.
+ Obtains the current mute state for this channel.
boolean getOmni()
-Obtains the current omni mode status.
+ Obtains the current omni mode status.
int getPitchBend()
-Obtains the upward of downward pitch offset for this channel.
+ Obtains the upward of downward pitch offset for this channel.
int getPolyPressure(int noteNumber)
-Obtains the pressure with which the specified key is being depressed.
+ Obtains the pressure with which the specified key is being depressed.
int getProgram()
-Obtains the current program number for this channel.
+ Obtains the current program number for this channel.
boolean getSolo()
-Obtains the current solo state for this channel.
+ Obtains the current solo state for this channel.
boolean localControl(boolean on)
-Turns local control on or off.
+ Turns local control on or off.
void noteOff(int noteNumber)
-Turns the specified note off.
+ Turns the specified note off.
void noteOff(int noteNumber, int velocity)
-Turns the specified note off.
+ Turns the specified note off.
void noteOn(int noteNumber, int velocity)
-Starts the specified note sounding.
+ Starts the specified note sounding.
void programChange(int program)
-Changes a program (patch).
+ Changes a program (patch).
void programChange(int bank, int program)
-Changes the program using bank and program (patch) numbers.
+ Changes the program using bank and program (patch) numbers.
void resetAllControllers()
-Resets all the implemented controllers to their default values.
+ Resets all the implemented controllers to their default values.
void setChannelPressure(int pressure)
-Reacts to a change in the keyboard pressure.
+ Reacts to a change in the keyboard pressure.
void setMono(boolean on)
-Turns mono mode on or off.
+ Turns mono mode on or off.
void setMute(boolean mute)
-Sets the mute state for this channel.
+ Sets the mute state for this channel.
void setOmni(boolean on)
-Turns omni mode on or off.
+ Turns omni mode on or off.
void setPitchBend(int bend)
-Changes the pitch offset for all notes on this channel.
+ Changes the pitch offset for all notes on this channel.
void setPolyPressure(int noteNumber, int pressure)
-Reacts to a change in the specified note's key pressure.
+ Reacts to a change in the specified note's key pressure.
void setSolo(boolean soloState)
-Sets the solo state for this channel.
+ Sets the solo state for this channel.
\f
Sequence
-
+
Track createTrack()
-Creates a new, initially empty track as part of this sequence.
+ Creates a new, initially empty track as part of this sequence.
boolean deleteTrack(Track track)
-Removes the specified track from the sequence.
+ Removes the specified track from the sequence.
float getDivisionType()
-Obtains the timing division type for this sequence.
+ Obtains the timing division type for this sequence.
long getMicrosecondLength()
-Obtains the duration of this sequence, expressed in microseconds.
+ Obtains the duration of this sequence, expressed in microseconds.
Patch[] getPatchList()
-Obtains a list of patches referenced in this sequence.
+ Obtains a list of patches referenced in this sequence.
int getResolution()
-Obtains the timing resolution for this sequence.
+ Obtains the timing resolution for this sequence.
long getTickLength()
-Obtains the duration of this sequence, expressed in MIDI ticks.
+ Obtains the duration of this sequence, expressed in MIDI ticks.
Track[] getTracks()
-Obtains an array containing all the tracks in this sequence.
+ Obtains an array containing all the tracks in this sequence.
\f
Track
-
+
boolean add(MidiEvent event)
-Adds a new event to the track.
+ Adds a new event to the track.
MidiEvent get(int index)
-Obtains the event at the specified index.
+ Obtains the event at the specified index.
boolean remove(MidiEvent event)
-Removes the specified event from the track.
+ Removes the specified event from the track.
int size()
-Obtains the number of events in this track.
+ Obtains the number of events in this track.
long ticks()
-Obtains the length of the track, expressed in MIDI ticks.
+ Obtains the length of the track, expressed in MIDI ticks.
\f
MidiEvent
-
+
MidiMessage getMessage()
-Obtains the MIDI message contained in the event.
+ Obtains the MIDI message contained in the event.
long getTick()
-Obtains the time-stamp for the event, in MIDI ticks
+ Obtains the time-stamp for the event, in MIDI ticks
void setTick(long tick)
-Sets the time-stamp for the event, in MIDI ticks
+ Sets the time-stamp for the event, in MIDI ticks
\f
MidiMessage
-
+
abstract Object clone()
-Creates a new object of the same class and with the same contents as this object.
+ Creates a new object of the same class and with the same contents as this object.
int getLength()
-Obtains the total length of the MIDI message in bytes.
+ Obtains the total length of the MIDI message in bytes.
byte[] getMessage()
-Obtains the MIDI message data.
+ Obtains the MIDI message data.
int getStatus()
-Obtains the status byte for the MIDI message.
+ Obtains the status byte for the MIDI message.
protected void setMessage(byte[] data, int length)
-Sets the data for the MIDI message.
+ Sets the data for the MIDI message.
-\f
+\f\f
ShortMessage
-
+
Object clone()
-Creates a new object of the same class and with the same contents as this object.
+ Creates a new object of the same class and with the same contents as this object.
int getChannel()
-Obtains the MIDI channel associated with this event.
+ Obtains the MIDI channel associated with this event.
int getCommand()
-Obtains the MIDI command associated with this event.
+ Obtains the MIDI command associated with this event.
int getData1()
-Obtains the first data byte in the message.
+ Obtains the first data byte in the message.
int getData2()
-Obtains the second data byte in the message.
+ Obtains the second data byte in the message.
protected int getDataLength(int status)
-Retrieves the number of data bytes associated with a particular status byte value.
+ Retrieves the number of data bytes associated with a particular status byte value.
void setMessage(int status)
-Sets the parameters for a MIDI message that takes no data bytes.
+ Sets the parameters for a MIDI message that takes no data bytes.
void setMessage(int status, int data1, int data2)
-Sets the parameters for a MIDI message that takes one or two data bytes.
+ Sets the parameters for a MIDI message that takes one or two data bytes.
void setMessage(int command, int channel, int data1, int data2)
-Sets the short message parameters for a channel message which takes one or two data bytes.
+ Sets the short message parameters for a channel message which takes one or two data bytes.
+
+\f
\ No newline at end of file
public class Moosique {
- protected static MooGUI gui;
- protected static Sequence seq;
+ private static MooGUI gui;
+ private static Sequence seq;
+ private static Sequencer sequencer;
+ private static Synthesizer synthesizer;
+ private static MidiChannel[] channels;
+ private static MidiChannel activeChannel;
- protected static Sequencer sequencer;
- protected static Synthesizer synthesizer;
- protected static MidiChannel[] channels;
- protected static MidiChannel activeChannel;
-
- protected static String filename;
- protected static long position;
+ private static String filename, fileArg;
+ private static long position;
+ private static boolean makeGUI = true;
/**
* Starts the application.
*/
public static void main (String[] args) {
System.out.println("\nMoosique version 1.0\n");
+
+ // Parses command-line arguments.
+ for (int i = 0; i < args.length; i++) {
+ if (args[i].equals("-n")) {makeGUI = false;}
+ else if (fileArg == null) {fileArg = args[i];}
+ }
+
// Acquires MIDI devices and connects them.
System.out.print("Initializing MIDI devices.");
try {
System.out.println("Done");
//If a filename is given as the command-line argument, attempts to load a sequence from the file.
- System.out.print("Loading MIDI sequence...");
- if (args.length == 1) {
- if (!load(args[0])) clearSequence();
+ if (fileArg != null) {
+ System.out.print("Loading MIDI sequence from " + fileArg + "...");
+ if (!load(fileArg)) clearSequence();
+ System.out.println("Done");
} else {
// Otherwise creates a new empty one.
clearSequence();
}
- System.out.println("Done");
- // Sets up channels and GUI.
- System.out.print("Creating GUI...");
- gui = new MooGUI(seq);
- System.out.println("Done");
+ // If n-flag is set, plays song and then exits. Otherwise builds GUI.
+ if (makeGUI) {
+ System.out.print("Building GUI...");
+ gui = new MooGUI(seq);
+ System.out.println("Done");
+ } else {
+ System.out.print("Playing...");
+ play();
+ while (sequencer.isRunning()) {}
+ System.out.println("Done");
+ quit();
+ }
}
/**
* Replaces the current sequence with a new one, holding three empty tracks.
*/
public static void clearSequence() {
- // Creates sequence.
+ // Creates a new sequence and sends it to the sequencer.
try {
seq = new Sequence(Sequence.PPQ, 96, 3);
+ sequencer.setSequence(seq);
} catch (InvalidMidiDataException e) {}
// Sends sequence to GUI.
if (gui != null) gui.setSequence(seq);
-
}
/**
* Starts playback of the current sequence.
*/
public static void play() {
- try {
- sequencer.setSequence(seq);
- sequencer.setTickPosition(position);
- } catch (InvalidMidiDataException e) {}
+ sequencer.setTickPosition(position);
sequencer.start();
}
return false;
}
- // Sends sequence to GUI
+ // Sends sequence to GUI and sequencer
if (gui != null) gui.setSequence(seq);
+ try {
+ sequencer.setSequence(seq);
+ } catch (InvalidMidiDataException e) {}
// Searches the sequence for NoteOn events
Track[] tracks = seq.getTracks();