mozaic_tips_and_tricks

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
mozaic_tips_and_tricks [2020/03/01 22:05] – Added ~~NOTOC~~ _kimozaic_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>Mozaic midi_scripting}}+~~NOTOC~~ {{tag>Mozaic midi_scripting}}
  
 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 224: Line 224:
  
  
-If a knob is only used to toggle between two states like a switch, the code for double-tap detection would look like:+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:
 <code> <code>
 +@OnKnobChange
 +  _knob = LastKnob
 +  _val  = GetKnobValue _knob
 +  
 +  if _knob = TOGGLE_KNOB
 +    if _val = 64
 +      isOn = not isOn
 +      SetKnobValue TOGGLE_KNOB,48 + 32*isOn
 +    else
 +      isOn = _val > 64  
 +    endif
 +    
 +    if isOn
 +      LabelKnob TOGGLE_KNOB,  {ON}
 +    else
 +      LabelKnob TOGGLE_KNOB,  {OFF}
 +    endif
 +  endif
 +@End
 +
 @OnLoad @OnLoad
   ShowLayout 2   ShowLayout 2
Line 246: Line 266:
   else   else
     LabelKnob TOGGLE_KNOB,  {OFF}     LabelKnob TOGGLE_KNOB,  {OFF}
-  endif 
-@End 
- 
-@OnKnobChange 
-  _knob = LastKnob 
-  _val  = GetKnobValue _knob 
-   
-  if _knob = TOGGLE_KNOB 
-    if _val = 64 
-      isOn = not isOn 
-      SetKnobValue TOGGLE_KNOB,48 + 32*isOn 
-    else 
-      isOn = _val > 64   
-    endif 
-     
-    if isOn 
-      LabelKnob TOGGLE_KNOB,  {ON} 
-    else 
-      LabelKnob TOGGLE_KNOB,  {OFF} 
-    endif 
   endif   endif
 @End @End
  • mozaic_tips_and_tricks.txt
  • Last modified: 2024/04/23 19:07
  • by _ki