All Packages Class Hierarchy This Package Previous Next Index
Class com.nosuch.midi.MidiSystem
java.lang.Object
|
+----com.nosuch.midi.MidiSystem
- public class MidiSystem
- extends Object
MidiSystem is the main class for controlling the Midi package.
All definitions and methods are static.
To use MIDI, invoke:
MidiSystem.start();
and then you can schedule MIDI output by doing things like:
MidiSystem.schedule(new MidiNote(100)); // pitch is 100
-
MidiSystem()
-
-
allNotesOff()
- Return a phrase containing allo-notes-off messsages for all channels
Currently this is only on the default channel
-
beatToClick(long)
- Return number of clicks in a specified number of beats.
-
beatToMilli(long)
- Return number of milliseconds in a specified number of beats.
-
clicksPerBeat()
- Return number of clicks in a beat.
-
clickToMilli(long)
- Return number of milliseconds in a specified number of clicks.
-
getNumInDevices()
- return the number of input devices
-
getNumOutDevices()
- return the number of output devices
-
isStarted()
- Return true if MidiSystem has been started.
-
main(String[])
-
-
milliPerBeat()
- Return number of milliseconds in one beat.
-
milliToClick(long)
- Return number of clicks in a specified number of milliseconds.
-
nativeMidiInGetNumDevs()
- Query the system regarding the number of MIDI input devices
-
nativeMidiOutGetNumDevs()
- Query the system regarding the number of MIDI output devices
-
nativeNow()
- Return value of current time in clicks (not milliseconds).
-
nativeOpenURL(String, String)
- open a URL in a browser
-
nativeSetClicks(int)
- set the value of Clicks for the scheduler
-
nativeSetDebug(int)
- Set the debug flag for the Midi system
-
nativeSetTempo(int)
- set the internal Tempo of the scheduler
-
now()
- Return the current time in clicks.
-
schedule(byte[])
-
-
schedule(byte[], long)
-
-
schedule(MidiMsg)
- Schedule a MidiMsg for eventual output.
-
schedule(MidiPhrase)
- Schedule a MidiPhrase for eventual output
The time offset of the phrase is set to MidiSystem.now(), so that
if the time of the phrase starts at 0 (which is pretty normal),
the phrase will play immediately.
-
schedule(MidiPhrase, long)
- Schedule a MidiPhrase for eventual output.
-
setClicks(int)
- Set the number of clicks per beat.
-
setDebug(int)
- Set the debug level in the native methods.
-
setInDevice(MidiInput)
- Set the input device to a new device (this is untested)
-
setOutDevice(MidiOutput)
- Set the output device to a new device (this is untested)
-
setTempo(int)
- Set the tempo of schedule playback.
-
start()
- Initialize the MIDI system with default input and output devices.
-
start(MidiAction)
- Initialize the MIDI system with specific callback actions.
-
start(MidiAction, int, int)
- Initialize the MIDI system with specific callbacks and I/O devices.
-
stop()
- Stop the MIDI system.
MidiSystem
public MidiSystem()
getNumInDevices
public static int getNumInDevices()
- return the number of input devices
getNumOutDevices
public static int getNumOutDevices()
- return the number of output devices
isStarted
public static boolean isStarted()
- Return true if MidiSystem has been started.
start
public static boolean start()
- Initialize the MIDI system with default input and output devices.
start
public static boolean start(MidiAction act)
- Initialize the MIDI system with specific callback actions.
- Parameters:
- act - MidiAction for callbacks on MIDI input messages.
start
public static boolean start(MidiAction act,
int outId,
int inId)
- Initialize the MIDI system with specific callbacks and I/O devices.
- Parameters:
- act - MidiAction for callbacks on MIDI input messages.
- outId - Id of MIDI output device
- inId - Id of MIDI input device
setOutDevice
public static void setOutDevice(MidiOutput o)
- Set the output device to a new device (this is untested)
setInDevice
public static void setInDevice(MidiInput o)
- Set the input device to a new device (this is untested)
stop
public static void stop()
- Stop the MIDI system.
allNotesOff
public static MidiPhrase allNotesOff()
- Return a phrase containing allo-notes-off messsages for all channels
Currently this is only on the default channel
clickToMilli
public static long clickToMilli(long nclicks)
- Return number of milliseconds in a specified number of clicks.
- Parameters:
- nclicks - number of clicks
beatToMilli
public static long beatToMilli(long nbeats)
- Return number of milliseconds in a specified number of beats.
- Parameters:
- nbeats - number of beats
milliPerBeat
public static long milliPerBeat()
- Return number of milliseconds in one beat.
milliToClick
public static long milliToClick(long milli)
- Return number of clicks in a specified number of milliseconds.
- Parameters:
- milli - number of milliseconds
clicksPerBeat
public static int clicksPerBeat()
- Return number of clicks in a beat.
beatToClick
public static long beatToClick(long nbeats)
- Return number of clicks in a specified number of beats.
- Parameters:
- nbeats - number of beats
schedule
public static synchronized void schedule(MidiMsg m) throws MidiException
- Schedule a MidiMsg for eventual output.
- Parameters:
- m - MidiMsg to be scheduled
- Throws: MidiException
- If unable to schedule
schedule
public static synchronized void schedule(MidiPhrase p) throws MidiException
- Schedule a MidiPhrase for eventual output
The time offset of the phrase is set to MidiSystem.now(), so that
if the time of the phrase starts at 0 (which is pretty normal),
the phrase will play immediately.
- Parameters:
- p - MidiPhrase to be scheduled
- Throws: MidiException
- If unable to schedule
schedule
public static synchronized void schedule(MidiPhrase p,
long offset) throws MidiException
- Schedule a MidiPhrase for eventual output.
The offset value controls when the phrase will begin. If the
phrase time (i.e. the times attached to its MidiMsg objects)
starts at 0, and the offset value is set to MidiSystem.now(),
then playback will start immediately.
- Parameters:
- p - MidiPhrase to be scheduled
- offset - An offset (in clicks) to be added to the time of the phrase
- Throws: MidiException
- If unable to schedule
schedule
public static synchronized void schedule(byte b[]) throws MidiException
schedule
public static synchronized void schedule(byte b[],
long offset) throws MidiException
setTempo
public static void setTempo(int t) throws MidiException
- Set the tempo of schedule playback.
- Parameters:
- t - tempo in microseconds per beat.
- Throws: MidiException
- If something goes wrong.
setClicks
public static void setClicks(int c) throws MidiException
- Set the number of clicks per beat.
- Parameters:
- c - Number of clicks per beat.
- Throws: MidiException
- If something goes wrong.
setDebug
public static void setDebug(int d) throws MidiException
- Set the debug level in the native methods.
- Parameters:
- d - Debug level.
- Throws: MidiException
- If something goes wrong.
now
public static long now()
- Return the current time in clicks.
- Returns:
- s Current time in clicks.
nativeSetTempo
public native void nativeSetTempo(int t) throws MidiException
- set the internal Tempo of the scheduler
- Throws: MidiException
- If something goes wrong.
nativeSetClicks
public native void nativeSetClicks(int c) throws MidiException
- set the value of Clicks for the scheduler
- Throws: MidiException
- If something goes wrong.
nativeSetDebug
public native void nativeSetDebug(int d)
- Set the debug flag for the Midi system
nativeNow
public native long nativeNow()
- Return value of current time in clicks (not milliseconds).
- Returns:
- s Current time in clicks.
nativeMidiInGetNumDevs
public native int nativeMidiInGetNumDevs() throws MidiException
- Query the system regarding the number of MIDI input devices
- Returns:
- s The number of MIDI input devices.
- Throws: MidiException
- If something goes wrong.
nativeMidiOutGetNumDevs
public native int nativeMidiOutGetNumDevs() throws MidiException
- Query the system regarding the number of MIDI output devices
- Returns:
- s The number of MIDI output devices.
- Throws: MidiException
- If something goes wrong.
nativeOpenURL
public native void nativeOpenURL(String browser,
String url) throws MidiException
- open a URL in a browser
- Throws: MidiException
- If something goes wrong.
main
public static void main(String args[])
All Packages Class Hierarchy This Package Previous Next Index