Module Duplex.Globals
Various global constants, functions and methods for tracing output
- To enable tracing of output, see TRACE()
Functions
compare (val1, val2, precision) | compare two numbers with variable precision |
table_compare (t1, t2) | quick'n'dirty table compare, compares values (not keys) |
table_count (t) | count table entries, including mixed types |
table_find (t, val) | look for value within table |
table_has_equal_values (t) | check if values are the same (useful for detecting if a color is tinted) |
split_filename (filename) | split_filename |
replace_char (pos, str, r) | replace character in string |
note_pitch_to_value (val) | convert note-column pitch number into string value |
value_to_midi_pitch (str_val) | interpret note-string some examples of input: C#5 C--1 C-1 C#-1 note that wildcard will return a fixed octave (1) |
extract_cc_num (str_val) | extract cc number from a parameter |
get_playing_pattern () | getplayingpattern |
get_master_track () | getmastertrack |
get_master_track_index () | getmastertrack_index |
send_track (send_index) | get send track |
get_color_average (color) | get average from color |
is_monochrome (colorspace) | check if colorspace is monochromatic |
strip_channel_info (str) | remove channel info from value-string |
strip_note_info (str) | remove note info from value-string |
has_note_info (str) | remove note info from value-string |
determine_track_type (track_index) | get the type of track: sequencer/master/send |
round_value (num) | round_value (from http://lua-users.org/wiki/SimpleRound) |
clamp_value (value, min_value, max_value) | clamp_value: ensure value is within min/max |
wrap_value (value, min_value, max_value) | wrap_value: 'rotate' value within specified range (with a range of 0-127, a value of 150 will output 22 |
scale_value (value, in_min, in_max, out_min, out_max) | scale_value: scale a value to a range within a range |
log_scale (ceiling, val) | logarithmic scaling within a fixed space |
inv_log_scale (ceiling, val) | inverse logarithmic scaling (exponential) |
fraction (val) | return the fractional part of a number |
is_whole_number (n) | check for whole number, using format() |
sign (x) | determine the sign of a number |
average (...) | get average of supplied numbers |
gcd (m, n) | greatest common divisor |
lcm (m, n) | least common multiplier (2 args) |
least_common (t) | find least common multiplier |
TRACE (vararg) | TRACE impl |
LOG (str) | call this to avoid using "print" statements in source code |
LOG_FILE (str) | append text to log.txt in the tool's root folder (warning: this is slow! only use when examining startup sequence, before it is possible to view output in the console window) |
Tables
ORIENTATION | (Enum) used for layout purposes |
NOTE_ARRAY | Table of note names |
DEVICE_PROTOCOL | (Enum) |
DEVICE_MESSAGE | (Enum) |
DEVICE_EVENT | (Enum) the type of event (pressed, held etc.) |
PARAM_MODE | (Enum) valid mode attributes for nodes |
INPUT_TYPE | (Enum) valid type attributes for nodes |
Fields
MODULE_PATH | The main folder |
LOWER_NOTE | Lowest possible note |
UPPER_NOTE | Highest possible note |
RENOISE_DECIBEL | Decibel constant |
Functions
- compare (val1, val2, precision)
-
compare two numbers with variable precision
Parameters:
- val1
- val2
- precision
- table_compare (t1, t2)
-
quick'n'dirty table compare, compares values (not keys)
Parameters:
- t1
- t2
Returns:
-
boolean, true if identical
- table_count (t)
-
count table entries, including mixed types
Parameters:
- t
Returns:
-
int or nil
- table_find (t, val)
-
look for value within table
Parameters:
- t
- val
Returns:
-
boolean
- table_has_equal_values (t)
-
check if values are the same
(useful for detecting if a color is tinted)
Parameters:
- t
Returns:
-
boolean
- split_filename (filename)
-
split_filename
Parameters:
- filename
- replace_char (pos, str, r)
-
replace character in string
Parameters:
- pos
- str
- r
- note_pitch_to_value (val)
-
convert note-column pitch number into string value
Parameters:
- val
- NoteColumn note-value, e.g. 120
Returns:
-
nil or NoteColumn note-string, e.g. "OFF"
- val
- value_to_midi_pitch (str_val)
-
interpret note-string
some examples of input: C#5 C--1 C-1 C#-1
note that wildcard will return a fixed octave (1)
Parameters:
- str_val
Returns:
-
int
- extract_cc_num (str_val)
-
extract cc number from a parameter
Parameters:
- str_val
- get_playing_pattern ()
- getplayingpattern
- get_master_track ()
- getmastertrack
- get_master_track_index ()
- getmastertrack_index
- send_track (send_index)
-
get send track
Parameters:
- send_index
- get_color_average (color)
-
get average from color
Parameters:
- color
- is_monochrome (colorspace)
-
check if colorspace is monochromatic
Parameters:
- colorspace
- strip_channel_info (str)
-
remove channel info from value-string
Parameters:
- str
- strip_note_info (str)
-
remove note info from value-string
Parameters:
- str
- has_note_info (str)
-
remove note info from value-string
Parameters:
- str
- determine_track_type (track_index)
-
get the type of track: sequencer/master/send
Parameters:
- track_index
- round_value (num)
-
round_value (from http://lua-users.org/wiki/SimpleRound)
Parameters:
- num
- clamp_value (value, min_value, max_value)
-
clamp_value: ensure value is within min/max
Parameters:
- value
- min_value
- max_value
- wrap_value (value, min_value, max_value)
-
wrap_value: 'rotate' value within specified range
(with a range of 0-127, a value of 150 will output 22
Parameters:
- value
- min_value
- max_value
- scale_value (value, in_min, in_max, out_min, out_max)
-
scale_value: scale a value to a range within a range
Parameters:
- value (number) the value we wish to scale
- in_min (number)
- in_max (number)
- out_min (number)
- out_max (number)
Returns:
-
number
- log_scale (ceiling, val)
-
logarithmic scaling within a fixed space
Parameters:
- ceiling (number) the upper boundary
- val (number) the value to scale
- inv_log_scale (ceiling, val)
-
inverse logarithmic scaling (exponential)
Parameters:
- ceiling
- val
- fraction (val)
-
return the fractional part of a number
Parameters:
- val
- is_whole_number (n)
-
check for whole number, using format()
Parameters:
- n
- sign (x)
-
determine the sign of a number
Parameters:
- x
- average (...)
-
get average of supplied numbers
Parameters:
- ...
- gcd (m, n)
-
greatest common divisor
Parameters:
- m
- n
- lcm (m, n)
-
least common multiplier (2 args)
Parameters:
- m
- n
- least_common (t)
-
find least common multiplier
Parameters:
- t (table), use values in table as argument
- TRACE (vararg)
-
TRACE impl
Parameters:
- vararg )
- LOG (str)
-
call this to avoid using "print" statements in source code
Parameters:
- str
- LOG_FILE (str)
-
append text to log.txt in the tool's root folder
(warning: this is slow! only use when examining startup sequence,
before it is possible to view output in the console window)
Parameters:
- str
Tables
- ORIENTATION
-
(Enum) used for layout purposes
Fields:
- VERTICAL
- HORIZONTAL
- NONE
- NOTE_ARRAY
-
Table of note names
Fields:
- C-
- C#
- D-
- D#
- E-
- F-
- F#
- G-
- G#
- A-
- A#
- B-
- DEVICE_PROTOCOL
-
(Enum)
Fields:
- OSC
- MIDI
- DEVICE_MESSAGE
-
(Enum)
Fields:
- OSC Osc Message
- MIDI_CC Midi CC Message
- MIDI_NOTE Midi Note Message
- MIDI_PITCH_BEND Midi Pitch Bend Message
- MIDI_CHANNEL_PRESSURE Midi Channel Pressure
- MIDI_KEY Midi Note Message (unspecific)
- MIDI_PROGRAM_CHANGE Midi Program Change Event
- MIDI_NRPN Midi Non-Registered Parameter Number
- DEVICE_EVENT
-
(Enum) the type of event (pressed, held etc.)
Fields:
- BUTTON_PRESSED button event
- BUTTON_RELEASED button event
- BUTTON_HELD button event
- VALUE_CHANGED slider, encoder event
- KEY_PRESSED key event
- KEY_RELEASED key event
- KEY_HELD key event
- PITCH_CHANGED key event
- CHANNEL_PRESSURE key event
- PARAM_MODE
-
(Enum) valid
mode
attributes for nodesFields:
- abs absolute value (the default, will accept floating point values)
- abs_7 7 bit absolute value (quantize to 7 bit range before output)
- abs_14 14 bit absolute value
- rel_7_signed
7 bit relative signed value
-- Increase at [065 - 127], decrease at [001 - 063]
- rel_7_signed2
7 bit relative signed value
-- Increase at [001 - 063], decrease at [065 - 127]
--
(known as "Relative 3" in the Behringer B-Control series) - rel_7_offset
7 bit relative value
-- Increase at [065 - 127], decrease at [063 - 000]
-- (known as "Relative 2" in the Behringer B-Control series) - rel_7_twos_comp
7 bit relative value
-- Increase at [001 - 64], decrease at [127 - 065]
-- (known as "Relative 1" in the Behringer B-Control series) - rel_14_msb
14 bit relative value
-- CC increase at [0x01 - 0x7F] when MSB is 0x00, decrease at [0x7F - 0x01] when MSB is 0x7F
-- NRPN increase at [0x01 - 0x7F] when MSB is 0x00, decrease at [0x01 - 0x7F] when MSB is 0x40
-- (known as "Relative 1" in the Behringer B-Control series) - rel_14_offset
14 bit relative value
-- CC increase at [0x01 - 0x7F] when MSB is 0x40, decrease at [0x7F - 0x01] when MSB is 0x3F
-- NRPN increase at [0x01 - 0x7F] when MSB is 0x40, decrease at [0x7F - 0x00] when MSB is 0x3F
-- (known as "Relative 2" in the Behringer B-Control series) - rel_14_twos_comp
14 bit relative value
-- CC increase at [0x01 - 0x7F] when MSB is 0x00, decrease at [0x01 - 0x7F] when MSB is 0x40
-- NRPN increase at [0x01 - 0x7F] when MSB is 0x00, decrease at [0x7F - 0x00] when MSB is 0x7F
-- (known as "Relative 3" in the Behringer B-Control series)
- INPUT_TYPE
-
(Enum) valid type attributes for nodes
Fields:
- button standard bidirectional button which output a value on press & release, but does not control it's internal state
- togglebutton bidirectional button which toggles the state internally - this type of control does not support release & hold events (examples are buttons on the BCF/BCR controller)
- pushbutton bidirectional button which will output values on press & release while controlling it's state internally. Some examples are Automap "momentary" buttons, or TouchOSC pushbuttons
- fader manual fader
- dial basic rotary encoder
- xypad XY pad
- keyboard keyboard
- key key (drum-pad)
- label text display