Class LXMidiEngine

java.lang.Object
heronarts.lx.LXComponent
heronarts.lx.midi.LXMidiEngine
All Implemented Interfaces:
LXPath, LXSerializable, LXOscComponent, LXParameterListener

public class LXMidiEngine extends LXComponent implements LXOscComponent
  • Field Details

  • Constructor Details

    • LXMidiEngine

      public LXMidiEngine(LX lx)
  • Method Details

    • registerSurface

      public LXMidiEngine registerSurface(String deviceName, Class<? extends LXMidiSurface> surfaceClass)
    • 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 call super.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 class LXComponent
    • getDeviceName

      public static String getDeviceName(MidiDevice.Info deviceInfo)
    • whenReady

      public void whenReady(Runnable runnable)
      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

      public List<LXMidiInput> getInputs()
    • getOutputs

      public List<LXMidiOutput> getOutputs()
    • matchInput

      public LXMidiInput matchInput(String name)
    • matchInput

      public LXMidiInput matchInput(String[] names)
    • matchOutput

      public LXMidiOutput matchOutput(String name)
    • matchOutput

      public LXMidiOutput matchOutput(String[] names)
    • findSurface

      public LXMidiSurface findSurface(LXMidiInput input)
    • findSurface

      public LXMidiSurface findSurface(String name)
    • findSurface

      public LXMidiSurface findSurface(String name, int index)
    • findOutput

      public LXMidiOutput findOutput(String name)
    • findOutput

      public LXMidiOutput findOutput(MidiDevice device)
    • findInput

      public LXMidiInput findInput(String name)
    • findInput

      public LXMidiInput findInput(MidiDevice device)
    • addListener

      public LXMidiEngine addListener(LXMidiListener listener)
    • removeListener

      public LXMidiEngine removeListener(LXMidiListener listener)
    • addDeviceListener

      public LXMidiEngine addDeviceListener(LXMidiEngine.DeviceListener listener)
    • removeDeviceListener

      public LXMidiEngine removeDeviceListener(LXMidiEngine.DeviceListener listener)
    • addMappingListener

      public LXMidiEngine addMappingListener(LXMidiEngine.MappingListener listener)
    • removeMappingListener

      public LXMidiEngine removeMappingListener(LXMidiEngine.MappingListener listener)
    • handleOscMessage

      public boolean handleOscMessage(OscMessage message, String[] parts, int index)
      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 interface LXOscComponent
      Overrides:
      handleOscMessage in class LXComponent
      Parameters:
      message - Full OSC message object
      parts - The OSC address pattern, broken into an array of parts
      index - 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

      public LXMidiEngine addMapping(LXMidiMapping mapping)
    • removeMapping

      public LXMidiEngine removeMapping(LXMidiMapping mapping)
      Removes a midi mapping
      Parameters:
      mapping - The mapping to remove
      Returns:
      this
    • findMappings

      public List<LXMidiMapping> findMappings(LXComponent component)
    • removeParameterMappings

      public LXMidiEngine removeParameterMappings(LXParameter parameter)
      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

      public LXMidiEngine removeMappings(LXComponent component)
      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

      public void dispatch(LXShortMessage message)
    • save

      public void save(LX lx, JsonObject object)
      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 call super.save(lx, obj) at the appropriate time.
      Specified by:
      save in interface LXSerializable
      Overrides:
      save in class LXComponent
      Parameters:
      lx - LX instance
      object - Object to serialize into
    • load

      public void load(LX lx, JsonObject object)
      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 interface LXSerializable
      Overrides:
      load in class LXComponent
      Parameters:
      lx - LX instance
      object - Object to deserialize
    • log

      public static final void log(String message)
    • error

      public static final void error(String message)
    • error

      public static final void error(Exception x, String message)