public class CoreMidiClient extends Object
| Modifier and Type | Field and Description |
|---|---|
private AtomicInteger |
callbackCount
Used to count the number of CoreMidi environment change callbacks we have received, so that if additional ones
come in while we are delivering callback messages to our listeners, we know to start another round at the end.
|
private int |
midiClientReference |
private CoreMidiNotification |
mostRecentDeviceProvider
Keeps track of the latest
CoreMidiDeviceProvider added to our listener list; this is the only one that
we want to call when the MIDI environment changes, since we only need to update the device map once, and Java
creates a vast number of instances of our device provider. |
private Set<CoreMidiNotification> |
notificationListeners |
private AtomicBoolean |
runningCallbacks
The message callback for receiving notifications about changes in the MIDI environment from the JNI code.
|
| Constructor and Description |
|---|
CoreMidiClient(String name)
Constructor for class
|
| Modifier and Type | Method and Description |
|---|---|
void |
addNotificationListener(CoreMidiNotification listener)
Adds a notification listener to the listener set maintained by this class
|
private int |
createClient(String clientName)
Creates the MIDI Client
|
private void |
deliverCallbackToListeners()
Check whether we are already in the process of delivering callbacks to our listeners; if not, start a background
thread to do so, and at the end of that process, see if additional callbacks were attempted while it was going on.
|
private void |
disposeClient(int clientReference)
Disposes of a CoreMIDI Client
|
CoreMidiInputPort |
inputPortCreate(String name)
Creates a new CoreMidiInputPort
|
void |
notifyCallback()
The message callback for receiving notifications about changes in the MIDI environment from the JNI code
|
CoreMidiOutputPort |
outputPortCreate(String name)
Creates a new CoreMidiOutputPort
|
void |
removeNotificationListener(CoreMidiNotification listener)
Removes a notification listener from the listener set maintained by this class
|
private final int midiClientReference
private final Set<CoreMidiNotification> notificationListeners
private CoreMidiNotification mostRecentDeviceProvider
CoreMidiDeviceProvider added to our listener list; this is the only one that
we want to call when the MIDI environment changes, since we only need to update the device map once, and Java
creates a vast number of instances of our device provider.private final AtomicBoolean runningCallbacks
A reference to this method is created by the C++ method
Java_uk_co_xfactorylibrarians_coremidi4j_CoreMidiClient_createClient
which in turn is called by createClient(String).
Used to make sure we are only running one callback delivery loop at a time without having to serialize the process in a way that will block the actual CoreMidi callback.
private final AtomicInteger callbackCount
public CoreMidiClient(String name) throws CoreMidiException
name - The name of the clientCoreMidiException - if the client cannot be initializedpublic CoreMidiInputPort inputPortCreate(String name) throws CoreMidiException
name - The name of the portCoreMidiException - if the port cannot be createdpublic CoreMidiOutputPort outputPortCreate(String name) throws CoreMidiException
name - The name of the portCoreMidiException - if the port cannot be createdprivate void deliverCallbackToListeners()
public void notifyCallback() throws CoreMidiException
CoreMidiException - if a problem occurs passing along the notificationpublic void addNotificationListener(CoreMidiNotification listener)
listener - The CoreMidiNotification listener to addpublic void removeNotificationListener(CoreMidiNotification listener)
listener - The CoreMidiNotification listener to removeprivate int createClient(String clientName) throws CoreMidiException
clientName - The name of the clientCoreMidiException - if the client cannot be createdprivate void disposeClient(int clientReference) throws CoreMidiException
clientReference - The reference of the client to dispose ofCoreMidiException - if there is a problem disposing of the clientCopyright © 2017. All rights reserved.