Class RemoteAction

java.lang.Object
org.jjazz.musiccontrolactions.api.RemoteAction

public class RemoteAction extends Object
A remote action stores the list of MidiMessages which can trigger an action.
  • Constructor Details

    • RemoteAction

      public RemoteAction(String actionCategory, String actionId)
      Create a RemoteAction with no MidiMessage.
      Parameters:
      actionCategory - Must be a valid JJazzLab/Netbeans action category.
      actionId - Must be a valid JJazzLab/Netbeans action id.
      Throws:
      IllegalArgumentException - If parameters do not represent a valid JJazzLab action, or if the action does not have a NAME property defined.
  • Method Details

    • getAction

      public Action getAction()
      The associated action.
      Returns:
      Can't be null
    • saveAsPreference

      public void saveAsPreference()
      Save this RemoteAction as a preference.

      Do nothing of this instance has no MidiMessages defined.

    • loadFromPreference

      public static RemoteAction loadFromPreference(String actionCategory, String actionId)
      Try to create an instance from the saved preferences.
      Parameters:
      actionCategory -
      actionId -
      Returns:
      Null if no instance found for the specified parameters.
    • startMidiLearnSession

      public boolean startMidiLearnSession(int timeOutMs)
      Start a Midi learn session.

      Listen during timeOutMs Midi input to acquire MidiMessages that will trigger this action.

      Parameters:
      timeOutMs - In milliseconds.
      Returns:
      True If new MidiMessages were learnt.
    • getControlNotePitch

      public int getControlNotePitch()
      Returns:
      The control note pitch if MidiMessages correspond to a single Note_ON ShortMessage. -1 otherwise.
      See Also:
      • #setMidiMessages(int, int)
    • getControlNoteChannel

      public int getControlNoteChannel()
      Returns:
      The control note channel if MidiMessages correspond to a single Note_ON ShortMessage. -1 otherwise.
      See Also:
      • #setMidiMessages(int, int)
    • getActionCategory

      public String getActionCategory()
    • getActionId

      public String getActionId()
    • getMidiMessages

      public List<MidiMessage> getMidiMessages()
    • setDefaultMidiMessages

      public void setDefaultMidiMessages(List<MidiMessage> messages)
      Set the default Midi messages to be used when this RemoteAction is reset.
      Parameters:
      messages - Must be non null and non empty
    • reset

      public void reset()
      If valid default Midi messages are defined, use them as Midi messages.
    • setMidiMessages

      public void setMidiMessages(List<MidiMessage> messages)
      Set the MidiMessages which trigger this action when received.

      Parameters:
      messages -
    • isEnabled

      public boolean isEnabled()
    • setEnabled

      public void setEnabled(boolean enabled)
    • check

      public boolean check(MidiMessage mm)
      Check if this MidiMessage should trigger this RemoteAction.

      Comparison is done according to the following rules:
      - The number and the order of messages order must match.
      - Velocity is ignored on Note_ON/OFF messages comparison.

      Return false if RemoteAction is not enabled.

      Parameters:
      mm -
      Returns:
      True if this message comparison is the last successful comparison with each of the reference MidiMessages of this RemoteAction.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • noteOnMidiMessages

      public static List<MidiMessage> noteOnMidiMessages(int channel, int pitch)
      Get the MidiMessages for a command which is a note pressed on the specified channel.
      Parameters:
      channel -
      pitch -
      Returns: