|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.groovemanager.midi.MIDIManager
A MIDIManager can be used as a central instance for controlling MIDI data flow. A MIDIManager is connected to a ConfigManager instance from which it retreives the in- and output device to use.
| Field Summary | |
|---|---|
private ConfigManager |
configManager
The ConfigManager used to retreive selected in- and output devices |
static MIDIManager |
DEFAULT_MIDI_MANAGER
The default MIDIManager implementaiton |
protected long |
eventid
increasing number used for creating event ids that can be assigned to note on events so that a note off event can be assigned to a previously sent note on event |
private java.util.HashMap |
events
set of events that have been created with an event id and have not yet been finished. |
protected javax.sound.midi.MidiDevice |
inDevice
The current output device |
protected MIDIInReceiver |
inReceiver
The MIDI In Receiver used by this MIDIManager |
protected javax.sound.midi.MidiDevice |
outDevice
The current output device |
| Constructor Summary | |
|---|---|
MIDIManager()
Construct a new MIDIManager using the default ConfigManager |
|
MIDIManager(ConfigManager configManager)
Construct a new MIDIManager instance using the specified ConfigManager |
|
| Method Summary | |
|---|---|
void |
addMIDIListener(MIDIListener listener,
int[] acceptedStatus)
Add a MIDIListener to this MIDIManager. |
protected MIDIInReceiver |
createInReceiver()
Create and return the MIDIInReceiver. |
(package private) void |
disableInListener()
This method is called from a MIDIInReceiver to indicate that he can be disconnected from the input device |
void |
dispose()
Mark this MIDIManager as out of use |
(package private) void |
enableInListener()
This method is called from a MIDIInReceiver to indicate that he needs to be connected to the input device |
protected void |
finalize()
|
static MIDIManager |
getDefault()
Get the default MIDIManager implemetation |
protected javax.sound.midi.MidiDevice |
getInDevice()
Get the current input device |
protected long |
getNewEventId()
Get a new unique even id |
javax.sound.midi.MidiDevice |
getOutDevice()
Get the current output device |
void |
initMidi()
Initialize input and output device |
private void |
initMidiIn()
Initialize the input device |
private void |
initMidiOut()
Initialize the output device |
void |
propertyChange(org.eclipse.jface.util.PropertyChangeEvent event)
|
void |
removeMIDIListener(MIDIListener listener)
Remove a MIDIListener from this MIDIManager |
void |
sendController(int channel,
byte controllerNr,
byte value)
Send a single controller event |
protected void |
sendMidiMessage(javax.sound.midi.MidiMessage message,
long evid,
boolean start)
Send a MidiMessage to the output device |
void |
sendProgramChange(int channel,
byte program)
Send a single program change event |
void |
sendSingleNoteOff(long eventid,
int channel,
int key)
Send a single note off event |
long |
sendSingleNoteOn(int channel,
int velocity,
int key)
Send a single note on event |
void |
sendSysEx(int[] data)
Send a single SysEx message |
protected void |
startEvent(long evid)
Internal method for starting an event that expects another event in the future for completition (like note on and note off). the event id will be remembered until the expected event is sent. |
protected void |
stopEvent(long evid)
Internal method indicating that the corresponding event to the one that created the given event id has been sent. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private final ConfigManager configManager
public static final MIDIManager DEFAULT_MIDI_MANAGER
protected long eventid
private java.util.HashMap events
protected javax.sound.midi.MidiDevice inDevice
protected final MIDIInReceiver inReceiver
protected javax.sound.midi.MidiDevice outDevice
| Constructor Detail |
|---|
public MIDIManager()
public MIDIManager(ConfigManager configManager)
configManager - The ConfigManager to use| Method Detail |
|---|
public void addMIDIListener(MIDIListener listener,
int[] acceptedStatus)
listener - The MIDIListener to addacceptedStatus - Array of status bytes this listener accepts. Can be
any of MetaMessage.META,
SysexMessage.SYSTEM_EXCLUSIVE,
SysexMessage.SPECIAL_SYSTEM_EXCLUSIVE or
ShortMessage.*.
The array may also be null to indicate that all types of messages are
accepted.protected MIDIInReceiver createInReceiver()
void disableInListener()
public void dispose()
void enableInListener()
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.ThrowableObject.finalize()public static MIDIManager getDefault()
protected javax.sound.midi.MidiDevice getInDevice()
throws javax.sound.midi.MidiUnavailableException
javax.sound.midi.MidiUnavailableException - If the device could not be found or if
no device is selectedprotected long getNewEventId()
public javax.sound.midi.MidiDevice getOutDevice()
throws javax.sound.midi.MidiUnavailableException
javax.sound.midi.MidiUnavailableException - If the device could not be found or if
no device is selectedpublic void initMidi()
private void initMidiIn()
private void initMidiOut()
public void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event)
propertyChange in interface org.eclipse.jface.util.IPropertyChangeListenerIPropertyChangeListener.propertyChange(org.eclipse.jface.util.PropertyChangeEvent)public void removeMIDIListener(MIDIListener listener)
listener - The MIDIListener to remove
public void sendController(int channel,
byte controllerNr,
byte value)
throws javax.sound.midi.InvalidMidiDataException,
javax.sound.midi.MidiUnavailableException
channel - The channel on which the controller should be sentcontrollerNr - The controller number from 0 to 127value - The controller value from 0 to 127
javax.sound.midi.InvalidMidiDataException - Should not happen
javax.sound.midi.MidiUnavailableException - If the message could not be sent
protected void sendMidiMessage(javax.sound.midi.MidiMessage message,
long evid,
boolean start)
throws javax.sound.midi.MidiUnavailableException
message - The MidiMessage to sendevid - The event id of the message. If this message expects another
message in the future for completing, this event id must be other than
-1. Or if this message is the expected follow-up message to a previous
one it the event id should contain the event id with which the previous
message was sent. Otherwise -1 should be used as event id.start - Inidcates whether this event is a start event that expects
a follow-up message (true) or if it is the follow-up message to a
previous message (false). This value is only recognized if eventid != -1.
javax.sound.midi.MidiUnavailableException - If the message could not be sent
public void sendProgramChange(int channel,
byte program)
throws javax.sound.midi.InvalidMidiDataException,
javax.sound.midi.MidiUnavailableException
channel - The channel on which the event should be sent (from 0
to 15)program - The program number to change to (from 0 to 127)
javax.sound.midi.InvalidMidiDataException - Should not happen
javax.sound.midi.MidiUnavailableException - If the message could not be sent
public void sendSingleNoteOff(long eventid,
int channel,
int key)
throws javax.sound.midi.InvalidMidiDataException,
javax.sound.midi.MidiUnavailableException
eventid - The event id of the note on event to which this note event
belongs. If this event is independent of any note on event, -1 should be
used.channel - The channel on which the event should be sent (between
0 and 15)key - The note value of the note on event (between 0 and 127)
javax.sound.midi.InvalidMidiDataException - Should not happen
javax.sound.midi.MidiUnavailableException - If the message could not be sent
public long sendSingleNoteOn(int channel,
int velocity,
int key)
throws javax.sound.midi.InvalidMidiDataException,
javax.sound.midi.MidiUnavailableException
channel - The channel on which the event should be sent (between
0 and 15)velocity - The velocity of the note on event (between 0 and 127)key - The note value of the note on event (between 0 and 127)
javax.sound.midi.InvalidMidiDataException - Should not happen
javax.sound.midi.MidiUnavailableException - If the message could not be sent
public void sendSysEx(int[] data)
throws javax.sound.midi.InvalidMidiDataException,
javax.sound.midi.MidiUnavailableException
data - The whole message data of the sysex message
javax.sound.midi.InvalidMidiDataException - If the provided data is not a valid MIDI
data
javax.sound.midi.MidiUnavailableException - If the message could not be sentprotected void startEvent(long evid)
evid - The event idprotected void stopEvent(long evid)
evid -
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||