Module xRuleset
This is a supporting class for xRules .
See also
Functions
| __init (xrules, ruleset_def) | |
| rename (new_name) | rename a ruleset - will attempt to rename the file itself |
| remove_rule (idx) | remove a rule from this set |
| get_rule_name (rule_idx) | |
| get_rule_by_name (str_name) | get rule by name, including display names |
| match_message (xmsg, ruleset_idx, rule_idx, force_midi) | pass message into rules, invoke callback when matched |
| compile () | compile each of the rules within this set |
| parse_definition (ruleset_def) | |
| load_definition (file_path) | |
| serialize () | serialize entire ruleset |
| save_definition (file_path) | save the definition to a file note: saving the definition will NOT update the file_path property, so you can safely use this method to export a ruleset |
| looks_like_definition (str_def) | Static methods |
| get_suggested_name (str_name) | ensure that the name is unique (among the saved files) |
| get_normalized_file_path (str_name) | return the path to the internal models |
Tables
| self.rules | array containing xRule instances |
Fields
| self.xrules | xRules |
| self.name | string, name of this ruleset (derived from file_path) |
| self.description | string, description of this ruleset |
| self.osc_enabled | boolean, make rules able to specify an osc pattern |
| self.manage_voices | boolean, when true the voice-manager is enabled for this set |
| self.suppress_notifier | boolean, suppress while adding/removing/swapping |
| self.modified | boolean |
| self.active | boolean, when false the ruleset should be ignored |
| self.selected_rule_index | int, selected rule |
| self.file_path | string, full path to location on disk |
Functions
- __init (xrules, ruleset_def)
-
Parameters:
- xrules (xRules) owner
- ruleset_def
(table), optional
{
name = "Name of Ruleset", active = false, osc_enabled = false, {rule_def},{rule_def},{...} -- see xRule}
- rename (new_name)
-
rename a ruleset - will attempt to rename the file itself
Parameters:
- new_name (string)
Returns:
-
boolean,string
- remove_rule (idx)
-
remove a rule from this set
Parameters:
- idx
Returns:
-
string, a display name such as "Rule #01"
- get_rule_name (rule_idx)
-
Parameters:
- rule_idx
Returns:
-
string, a display name such as "Rule #01"
- get_rule_by_name (str_name)
-
get rule by name, including display names
Parameters:
- str_name
Returns:
-
xRule,int(index) or nil
- match_message (xmsg, ruleset_idx, rule_idx, force_midi)
-
pass message into rules, invoke callback when matched
Parameters:
- xmsg (xMidiMessage or xOscMessage)
- ruleset_idx (int), passed back to callback
- rule_idx (int), only check this rule (optional)
- force_midi (boolean) force match (used by routings)
Returns:
-
table
xMidiMessage or xOscMessage (original message) - compile ()
-
compile each of the rules within this set
Returns:
- boolean, true when passed
- string, error message when failed
- boolean, true when file was succesfully loaded
- err, string containing error message
- parse_definition (ruleset_def)
-
Parameters:
- ruleset_def (table)
Returns:
- boolean, true when passed
- string, error message when failed
- boolean, true when file was succesfully loaded
- err, string containing error message
- load_definition (file_path)
-
Parameters:
- file_path
Returns:
- boolean, true when file was succesfully loaded
- err, string containing error message
- serialize ()
-
serialize entire ruleset
Returns:
-
string
- save_definition (file_path)
-
save the definition to a file
note: saving the definition will NOT update the file_path property,
so you can safely use this method to export a ruleset
Parameters:
- file_path , path to file (optional)
Returns:
- boolean, true when succesfully saved
- string, error message when failed
- looks_like_definition (str_def)
-
Static methods ensure that a definition is "likely" valid before loading
Parameters:
- str_def
Returns:
-
boolean
- get_suggested_name (str_name)
-
ensure that the name is unique (among the saved files)
Parameters:
- str_name
- get_normalized_file_path (str_name)
-
return the path to the internal models
Parameters:
- str_name
Tables
Fields
- self.xrules
- xRules
- self.name
- string, name of this ruleset (derived from file_path)
- self.description
- string, description of this ruleset
- self.osc_enabled
- boolean, make rules able to specify an osc pattern
- self.manage_voices
- boolean, when true the voice-manager is enabled for this set
- self.suppress_notifier
- boolean, suppress while adding/removing/swapping
- self.modified
- boolean
- self.active
- boolean, when false the ruleset should be ignored
- self.selected_rule_index
- int, selected rule
- self.file_path
- string, full path to location on disk