Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision | ||
mozaic_tips_and_tricks [2020/03/01 21:24] – Added tip author _ki | mozaic_tips_and_tricks [2020/03/01 22:12] – Minor addition to Knob Double-Tap _ki | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Mozaic: Scripting Tips & Tricks ====== | ====== Mozaic: Scripting Tips & Tricks ====== | ||
+ | ~~NOTOC~~ {{tag> | ||
This wiki page contains programming tips & tricks for [[mozaic_plugin_engine|Mozaic]] | This wiki page contains programming tips & tricks for [[mozaic_plugin_engine|Mozaic]] | ||
Line 12: | Line 13: | ||
* [[#Use the SHIFT Button to toggle to HELP View]] | * [[#Use the SHIFT Button to toggle to HELP View]] | ||
* [[#Use a Knob to toggle 16 Pads View to HELP View]] | * [[#Use a Knob to toggle 16 Pads View to HELP View]] | ||
+ | * [[#Knob double-tap Support]] | ||
* [[# | * [[# | ||
Line 213: | Line 215: | ||
@End | @End | ||
</ | </ | ||
- | {{tag> | ||
+ | \\ | ||
+ | ===== Knob double-tap Support ===== | ||
+ | < | ||
+ | |||
+ | The value returned from // | ||
+ | This tip exploits the fact, that is very unlikely to manually dial in exactly 64.0000 - if such a knob value is returned, then the knob has probably been double-tapped. | ||
+ | |||
+ | |||
+ | If a knob is only used to toggle between two states like a switch (like the variable //isOn// in the example), the code for double-tap detection would look like: | ||
+ | < | ||
+ | @OnKnobChange | ||
+ | _knob = LastKnob | ||
+ | _val = GetKnobValue _knob | ||
+ | | ||
+ | if _knob = TOGGLE_KNOB | ||
+ | if _val = 64 | ||
+ | isOn = not isOn | ||
+ | SetKnobValue TOGGLE_KNOB, | ||
+ | else | ||
+ | isOn = _val > 64 | ||
+ | endif | ||
+ | | ||
+ | if isOn | ||
+ | LabelKnob TOGGLE_KNOB, | ||
+ | else | ||
+ | LabelKnob TOGGLE_KNOB, | ||
+ | endif | ||
+ | endif | ||
+ | @End | ||
+ | |||
+ | @OnLoad | ||
+ | ShowLayout 2 | ||
+ | LabelPads {Knob Double-Tap Demo } | ||
+ | LabelKnobs {Toggle with Double-Tap} | ||
+ | for _knob = 0 to 3 | ||
+ | SetKnobValue _knob,0 | ||
+ | LabelKnob _knob, | ||
+ | endfor | ||
+ | | ||
+ | if Unassigned isOn | ||
+ | isOn = NO | ||
+ | endif | ||
+ | | ||
+ | TOGGLE_KNOB = 1 | ||
+ | | ||
+ | SetKnobValue TOGGLE_KNOB, | ||
+ | if isOn | ||
+ | LabelKnob TOGGLE_KNOB, | ||
+ | else | ||
+ | LabelKnob TOGGLE_KNOB, | ||
+ | endif | ||
+ | @End | ||
+ | </ | ||
+ | The script snippet also features | ||
+ | * State saving of the toggle variable isOn | ||
+ | * Conditional expressions: | ||
+ | * //48 + 32*isOn// is either 48 or 80 depending on the state of //isOn// | ||
+ | * //isOn = _val > 64// assigns either 0 or 1 to //isOn// depending on _val | ||
+ | |||
+ | |||
+ | \\ | ||
===== Calculate Standard Chords from a Root Note ==== | ===== Calculate Standard Chords from a Root Note ==== | ||
< | < |