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
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionRemoteAction(String actionCategory, String actionId) Create a RemoteAction with no MidiMessage. -
Method Summary
Modifier and TypeMethodDescriptionbooleancheck(MidiMessage mm) Check if this MidiMessage should trigger this RemoteAction.The associated action.intintbooleanstatic RemoteActionloadFromPreference(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.voidreset()If valid default Midi messages are defined, use them as Midi messages.voidSave this RemoteAction as a preference.voidsetDefaultMidiMessages(List<MidiMessage> messages) Set the default Midi messages to be used when this RemoteAction is reset.voidsetEnabled(boolean enabled) voidsetMidiMessages(List<MidiMessage> messages) Set the MidiMessages which trigger this action when received.booleanstartMidiLearnSession(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:
-