Class RemoteAction
java.lang.Object
org.jjazz.musiccontrolactions.api.RemoteAction
A remote action stores the list of MidiMessages which can trigger an action.
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionRemoteAction
(String actionCategory, String actionId) Create a RemoteAction with no MidiMessage. -
Method Summary
Modifier and TypeMethodDescriptionboolean
check
(MidiMessage mm) Check if this MidiMessage should trigger this RemoteAction.The associated action.int
int
boolean
static RemoteAction
loadFromPreference
(String actionCategory, String actionId) Try to create an instance from the saved preferences.static List<MidiMessage>
noteOnMidiMessages
(int channel, int pitch) Get the MidiMessages for a command which is a note pressed on the specified channel.void
reset()
If valid default Midi messages are defined, use them as Midi messages.void
Save this RemoteAction as a preference.void
setDefaultMidiMessages
(List<MidiMessage> messages) Set the default Midi messages to be used when this RemoteAction is reset.void
setEnabled
(boolean enabled) void
setMidiMessages
(List<MidiMessage> messages) Set the MidiMessages which trigger this action when received.boolean
startMidiLearnSession
(int timeOutMs) Start a Midi learn session.toString()
-
Constructor Details
-
RemoteAction
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
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
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
-
getActionId
-
getMidiMessages
-
setDefaultMidiMessages
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
Set the MidiMessages which trigger this action when received.- Parameters:
messages
-
-
isEnabled
public boolean isEnabled() -
setEnabled
public void setEnabled(boolean enabled) -
check
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
-
noteOnMidiMessages
Get the MidiMessages for a command which is a note pressed on the specified channel.- Parameters:
channel
-pitch
-- Returns:
-