Package heronarts.lx.midi
Class LXMidiEngine
java.lang.Object
heronarts.lx.LXComponent
heronarts.lx.midi.LXMidiEngine
- All Implemented Interfaces:
LXPath
,LXSerializable
,LXOscComponent
,LXParameterListener
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
static interface
static interface
static interface
Nested classes/interfaces inherited from class heronarts.lx.LXComponent
LXComponent.Description, LXComponent.Hidden, LXComponent.Name, LXComponent.Placeholder, LXComponent.PluginRequired, LXComponent.Renamable
Nested classes/interfaces inherited from interface heronarts.lx.LXSerializable
LXSerializable.Utils
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal DiscreteParameter
final BooleanParameter
final DiscreteParameter
final ObjectParameter
<Integer> final List
<LXMidiInput> final List
<LXMidiMapping> final List
<LXMidiOutput> final List
<LXMidiSurface> static final String
final List
<LXMidiTemplate> Fields inherited from class heronarts.lx.LXComponent
childArrays, children, internalParameters, KEY_CHILDREN, KEY_CLASS, KEY_COMPONENT_ID, KEY_ID, KEY_INTERNAL, KEY_PARAMETER_PATH, KEY_PARAMETERS, KEY_PATH, KEY_RESET, label, legacyInternalParameters, legacyParameters, lx, modulationColor, modulationControlsExpanded, modulationsExpanded, parameters, presetFile
Fields inherited from interface heronarts.lx.LXPath
DEFAULT_SEPARATOR, ROOT, ROOT_PREFIX, ROOT_SLASH
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddDeviceListener
(LXMidiEngine.DeviceListener listener) addListener
(LXMidiListener listener) addMapping
(LXMidiMapping mapping) addSurface
(LXMidiSurface surface) addSurface
(Class<? extends LXMidiSurface> surfaceClass) Add an instance of the given midi surface class typevoid
addTemplate
(LXMidiTemplate template) void
dispatch()
Invoked by the main engine to dispatch all midi messages on the input queue.void
dispatch
(LXShortMessage message) void
dispose()
Invoked when a component is being removed from the system and will no longer be used at all.void
static final void
static final void
void
exportMappings
(File file) findInput
(MidiDevice device) findMappings
(LXComponent component) findOutput
(String name) findOutput
(MidiDevice device) findSurface
(LXMidiInput input) findSurface
(String deviceName) findSurface
(String deviceName, int index) findSurfaceClass
(String className, int index) static String
getDeviceName
(MidiDevice.Info deviceInfo) List
<Class<? extends LXMidiSurface>> List
<Class<? extends LXMidiTemplate>> boolean
handleOscMessage
(OscMessage message, String[] parts, int index) Handles an OSC message sent to this component.importMappings
(File file) void
<T extends LXMidiSurface>
TinstantiateSurface
(Class<T> surfaceClass, LXMidiInput input, LXMidiOutput output) Instantiate a MIDI surface of the given classvoid
load
(LX lx, JsonObject object) Loads the LX component.void
loadMappings
(LX lx, JsonObject obj) static final void
matchInput
(String name) matchInput
(String[] names) matchOutput
(String name) matchOutput
(String[] names) void
moveTemplate
(LXMidiTemplate template, int index) void
panic()
registerSurface
(Class<? extends LXMidiSurface> surfaceClass) Registers a new MIDI surface implementation with the MIDI engineregisterSurface
(String deviceName, Class<? extends LXMidiSurface> surfaceClass) Deprecated.void
registerTemplate
(Class<? extends LXMidiTemplate> templateClass) removeListener
(LXMidiListener listener) removeMapping
(LXMidiMapping mapping) Removes a midi mappingvoid
removeMappings
(LXComponent component) Called when a component is disposed.removeParameterMappings
(LXParameter parameter) Called when an individual parameter is disposed.removeSurface
(LXMidiSurface surface) void
removeTemplate
(LXMidiTemplate template) void
save
(LX lx, JsonObject object) Serializes the LX component.void
void
Executes the given code only after the MIDI engine initialization is done.Methods inherited from class heronarts.lx.LXComponent
addArray, addChild, addInternalParameter, addLegacyInternalParameter, addLegacyParameter, addParameter, addParameter, addParameters, assertDisposed, contains, copyParameters, getCategory, getChild, getComponentDescription, getComponentName, getComponentName, getComponentName, getDescription, getId, getLabel, getLX, getOscAddress, getOscLabel, getOscPath, getParameter, getParameters, getParent, getPath, hasParameter, isValidOscParameter, loadParameters, loadPreset, onParameterChanged, removeParameter, removeParameter, removeParameter, removeParameter, savePreset, setDescription, setParent, toOscQuery, toOscQuery, toOscQuery, toString, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface heronarts.lx.osc.LXOscComponent
getOscAddress
Methods inherited from interface heronarts.lx.LXPath
getCanonicalLabel, getCanonicalLabel, getCanonicalLabel, getCanonicalLabel, getCanonicalLabel, getCanonicalPath, getCanonicalPath, isDescendant
-
Field Details
-
TEMPLATE_PATH
- See Also:
-
inputs
-
outputs
-
surfaces
-
templates
-
mappings
-
computerKeyboardEnabled
-
computerKeyboardOctave
-
computerKeyboardVelocity
-
computerKeyboardChannel
-
-
Constructor Details
-
LXMidiEngine
-
-
Method Details
-
registerTemplate
-
getRegisteredTemplateClasses
-
registerSurface
@Deprecated public LXMidiEngine registerSurface(String deviceName, Class<? extends LXMidiSurface> surfaceClass) Deprecated. -
registerSurface
Registers a new MIDI surface implementation with the MIDI engine- Parameters:
surfaceClass
- MIDI surface class name- Returns:
- this
-
getRegisteredSurfaceClasses
-
initialize
public void initialize() -
disposeSurfaces
public void disposeSurfaces() -
dispose
public void dispose()Description copied from class:LXComponent
Invoked when a component is being removed from the system and will no longer be used at all. This unregisters the component and should free up any resources and parameter listeners. Ideally after this method is called the object should be eligible for garbage collection. Subclasses are generally expected to override this method to handle their particular cleanup work. They should also generally callsuper.dispose()
at the appropriate time to perform the basic cleanup, which may need to happen either before or after cleaning up other objects.- Overrides:
dispose
in classLXComponent
-
getDeviceName
-
addSurface
-
removeSurface
-
instantiateSurface
public <T extends LXMidiSurface> T instantiateSurface(Class<T> surfaceClass, LXMidiInput input, LXMidiOutput output) Instantiate a MIDI surface of the given class- Type Parameters:
T
- MIDI surface class type- Parameters:
surfaceClass
- Class- Returns:
- Surface instance
-
addSurface
Add an instance of the given midi surface class type- Parameters:
surfaceClass
- Midi surface class- Returns:
- this
-
whenReady
Executes the given code only after the MIDI engine initialization is done. If it's done, then this will be run immediately on the thread that called it. If it is not done, then this will be run later on the LX engine thread in the sequential order of all calls made to whenReady- Parameters:
runnable
- Code to run when MIDI engine is ready
-
getInputs
-
getOutputs
-
matchInput
-
matchInput
-
matchOutput
-
matchOutput
-
findSurface
-
findSurface
-
findSurface
-
findSurfaceClass
-
findOutput
-
findOutput
-
findInput
-
findInput
-
findInput
-
addListener
-
removeListener
-
addDeviceListener
-
removeDeviceListener
-
addTemplateListener
-
removeTemplateListener
-
addMappingListener
-
removeMappingListener
-
handleOscMessage
Description copied from class:LXComponent
Handles an OSC message sent to this component. By default this method handles registered components and parameters, but subclasses may override this method to handle different types of OSC messages.- Specified by:
handleOscMessage
in interfaceLXOscComponent
- Overrides:
handleOscMessage
in classLXComponent
- Parameters:
message
- Full OSC message objectparts
- The OSC address pattern, broken into an array of partsindex
- Which index into the parts array corresponds to this component's children- Returns:
true
if the OSC message was handled and should be considered consumed,false
otherwise
-
addMapping
-
removeMapping
Removes a midi mapping- Parameters:
mapping
- The mapping to remove- Returns:
- this
-
findMappings
-
removeParameterMappings
Called when an individual parameter is disposed. Remove any midi mappings pointing to the now-nonexistent parameter.- Parameters:
parameter
- Parameter that doesn't exist anymore- Returns:
- this
-
removeMappings
Called when a component is disposed. Remove any midi mappings pointing to the now-nonexistent component.- Parameters:
component
- Component to remove any midi mappings from- Returns:
- this
-
dispatch
public void dispatch()Invoked by the main engine to dispatch all midi messages on the input queue. -
dispatch
-
addTemplate
-
removeTemplate
-
moveTemplate
-
panic
public void panic() -
saveDevices
public void saveDevices() -
save
Description copied from class:LXComponent
Serializes the LX component. By default, all internal and user-facing parameters are serialized, as well as any explicitly registered child components. Note that child arrays are not serialized, or any other dynamic components. Subclasses may override to perform more saving, and are expected to callsuper.save(lx, obj)
at the appropriate time.- Specified by:
save
in interfaceLXSerializable
- Overrides:
save
in classLXComponent
- Parameters:
lx
- LX instanceobject
- Object to serialize into
-
load
Description copied from class:LXComponent
Loads the LX component. Restores the ID of the component, as well as its internal and user-facing parameters. Any explicitly registered children will be automatically loaded, so long as they are direct descendants. Dynamic arrays will not be automatically loaded, this is left to subclasses to implement.- Specified by:
load
in interfaceLXSerializable
- Overrides:
load
in classLXComponent
- Parameters:
lx
- LX instanceobject
- Object to deserialize
-
loadMappings
-
removeMappings
public void removeMappings() -
exportMappings
-
importMappings
-
log
-
error
-
error
-