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
mozaic_tips_and_tricks [2021/07/01 21:41] – Added „ About State-Saving“ section _kimozaic_tips_and_tricks [2024/04/23 19:07] (current) – Fixed depricated html snippets into WRAP _ki
Line 26: Line 26:
  
 ===== NoteOn Velocity 0 Special Case===== ===== NoteOn Velocity 0 Special Case=====
-<html><p align = "right"><small><i>From -ki</i></small></p></html>+<WRAP group><WRAP right><sup>From -ki</sup></WRAP></WRAP> 
 The Midi Spec allows to use a NoteOn command with velocity zero instead of a NoteOff command. If this combination is received by Mozaic, this midi command is automatically converted to 
NoteOff vel 0 - even for the @OnMidiInput event and when checking MidiByte1.  The Midi Spec allows to use a NoteOn command with velocity zero instead of a NoteOff command. If this combination is received by Mozaic, this midi command is automatically converted to 
NoteOff vel 0 - even for the @OnMidiInput event and when checking MidiByte1. 
  
Line 33: Line 34:
  
 ===== Two dimensional Arrays ===== ===== Two dimensional Arrays =====
-<html><p align = "right"><small><i>From -ki</i></small></p></html>+<WRAP group><WRAP right><sup>From -ki</sup></WRAP></WRAP> 
 Each variable in Mozaic is in fact an array with a maximum of 1024 elements. Scripting often needs two dimensional arrays, but the variables only offer one dimensional access. Each variable in Mozaic is in fact an array with a maximum of 1024 elements. Scripting often needs two dimensional arrays, but the variables only offer one dimensional access.
  
Line 73: Line 75:
  
 ===== Multi dimensional Arrays ===== ===== Multi dimensional Arrays =====
-<html><p align = "right"><small><i>From -ki</i></small></p></html>+<WRAP group><WRAP right><sup>From -ki</sup></WRAP></WRAP>
  
 The above folding can be expanded to multiple dimension, here an example for a 3 dimensional array folded into one dimensions: The above folding can be expanded to multiple dimension, here an example for a 3 dimensional array folded into one dimensions:
Line 84: Line 86:
  
 ===== Store two positive Values into a single Variable ===== ===== Store two positive Values into a single Variable =====
-<html><p align = "right"><small><i>From -ki</i></small></p></html>+<WRAP group><WRAP right><sup>From -ki</sup></WRAP></WRAP> 
 It is possible to store two positive values in a single variable if their product is less than 16.777.216 It is possible to store two positive values in a single variable if their product is less than 16.777.216
 and they both have a known maximum value. and they both have a known maximum value.
Line 106: Line 109:
  
 ===== Store three unsigned Bytes into a single Variable ===== ===== Store three unsigned Bytes into a single Variable =====
-<html><p align = "right"><small><i>From <a href="https://forum.audiob.us/discussion/comment/724913/#Comment_724913">espiegel123 @ Audiobus Forum </a></i></small></p></html>+<WRAP group><WRAP right><sup> From [[https://forum.audiob.us/discussion/comment/724913/#Comment_724913
 +Comment of espiegel123 @ Audiobus Forum]]</sup></WRAP></WRAP>
  
 Storing of 3 unsigned bytes (J,K & L, each with the range of 0-255) into a single 24bit integer can be done by using the packing formular: Storing of 3 unsigned bytes (J,K & L, each with the range of 0-255) into a single 24bit integer can be done by using the packing formular:
Line 134: Line 138:
 \\  \\ 
 ===== Output Fixed Point Values in Labels ===== ===== Output Fixed Point Values in Labels =====
-<html><p align = "right"><small><i>From -ki</i></small></p></html>+<WRAP group><WRAP right><sup>From -ki</sup></WRAP></WRAP> 
 When outputting floating point values into labels (knobs, pads, titles) Moazic generates either a 4 digit fraction string  When outputting floating point values into labels (knobs, pads, titles) Moazic generates either a 4 digit fraction string 
 like 42.5000 (if a remainder present) or an integer value without fraction. like 42.5000 (if a remainder present) or an integer value without fraction.
Line 165: Line 170:
 \\  \\ 
 ===== Some Best Practice Tips ===== ===== Some Best Practice Tips =====
-<html><p align = "right"><small><i>From -ki</i></small></p></html>+<WRAP group><WRAP right><sup>From -ki</sup></WRAP></WRAP> 
   * Its helpfull to add the version number right into the title label. \\ And also add this version number to the script title and patchname if uploaded / updated on [[https://patchstorage.com/platform/mozaic/|PatchStorage]] so that script-users can notice the version change.   * Its helpfull to add the version number right into the title label. \\ And also add this version number to the script title and patchname if uploaded / updated on [[https://patchstorage.com/platform/mozaic/|PatchStorage]] so that script-users can notice the version change.
   * Add a short name to set the icon name. This helps when a project contains multiple Mozaic instances with different scripts   * Add a short name to set the icon name. This helps when a project contains multiple Mozaic instances with different scripts
Line 192: Line 198:
 \\  \\ 
 ===== About State-Saving ===== ===== About State-Saving =====
-<html><p align = "right"><small><i>From -ki</i></small></p></html>+<WRAP group><WRAP right><sup>From -ki</sup></WRAP></WRAP> 
 All assigned variables of a script are automatically included in a saved preset and restored when reloading. To not overwrite them, use the  All assigned variables of a script are automatically included in a saved preset and restored when reloading. To not overwrite them, use the 
 <code> <code>
Line 220: Line 227:
 \\  \\ 
 ===== Detect Long or Short Pad Taps ===== ===== Detect Long or Short Pad Taps =====
-<html><p align = "right"><small><i>From wim</i></small></p></html>+<WRAP group><WRAP right><sup>From wim</sup></WRAP></WRAP>
  
 <code> <code>
Line 245: Line 252:
  
 ===== Detect Long or Short SHIFT Button Taps ===== ===== Detect Long or Short SHIFT Button Taps =====
-<html><p align = "right"><small><i>From wim</i></small></p></html>+<WRAP group><WRAP right><sup>From wim</sup></WRAP></WRAP>
  
 <code> <code>
Line 268: Line 275:
 \\  \\ 
 ===== Multi-Line Pad Labels ===== ===== Multi-Line Pad Labels =====
-<html><p align = "right"><small><i>From -ki</i></small></p></html>+<WRAP group><WRAP right><sup>From -ki</sup></WRAP></WRAP> 
 You can force multiline pad labels by adding space-filled substrings.  You can force multiline pad labels by adding space-filled substrings. 
   * There must be enough spaces to fill the rest of the current line   * There must be enough spaces to fill the rest of the current line
Line 283: Line 291:
 \\  \\ 
 ===== Dynamic Letters for Labeling ===== ===== Dynamic Letters for Labeling =====
-<html><p align = "right"><small><i>From -ki</i></small></p></html>+<WRAP group><WRAP right><sup>From -ki</sup></WRAP></WRAP> 
 The NoteName function of Moazic can be used to dynamically output the letters A-G inside the label string definitions of Knobs, Pads or Logs. This allows to construct labels like ‚Bank A‘ to ‚Bank D‘, or ‚Preset A-1‘ to ‚Preset F-8‘. The NoteName function of Moazic can be used to dynamically output the letters A-G inside the label string definitions of Knobs, Pads or Logs. This allows to construct labels like ‚Bank A‘ to ‚Bank D‘, or ‚Preset A-1‘ to ‚Preset F-8‘.
  
Line 303: Line 312:
 \\  \\ 
 ===== Use the SHIFT Button to toggle to HELP View ===== ===== Use the SHIFT Button to toggle to HELP View =====
-<html><p align = "right"><small><i>From -ki</i></small></p></html>+<WRAP group><WRAP right><sup>From -ki</sup></WRAP></WRAP> 
 <code> <code>
 @Description @Description
Line 337: Line 347:
 \\  \\ 
 ===== Use a Knob to toggle 16 Pads View to HELP View =====  ===== Use a Knob to toggle 16 Pads View to HELP View ===== 
-<html><p align = "right"><small><i>From -ki</i></small></p></html>+<WRAP group><WRAP right><sup>From -ki</sup></WRAP></WRAP>
  
 This script snippet is only applicable for the 16 pads layout (2) as this the only layout where the knobs 0-3 are at the same screen position as on the HELP page. This script snippet is only applicable for the 16 pads layout (2) as this the only layout where the knobs 0-3 are at the same screen position as on the HELP page.
Line 362: Line 372:
 \\  \\ 
 ===== Knob double-tap Support =====  ===== Knob double-tap Support ===== 
-<html><p align = "right"><small><i>From -ki</i></small></p></html>+<WRAP group><WRAP right><sup>From -ki</sup></WRAP></WRAP>
  
 The value returned from //**GetKnobValue**// is a floating point number, usually it will contain non-zero decimal places when the knob is turned manually. If double tapped the knob-value is set to 64 exactly.  The value returned from //**GetKnobValue**// is a floating point number, usually it will contain non-zero decimal places when the knob is turned manually. If double tapped the knob-value is set to 64 exactly. 
Line 422: Line 432:
 \\  \\ 
 =====  Remove or add an entry inside an array =====  =====  Remove or add an entry inside an array ===== 
-<html><p align = "right"><small><i>From -ki</i></small></p></html>+<WRAP group><WRAP right><sup>From -ki</sup></WRAP></WRAP> 
 Instead of running through an array with a FOR loop to shift entries to either insert or remove an  intermedeate enry, it is way faster to use the CopyArray Mozaic function: Instead of running through an array with a FOR loop to shift entries to either insert or remove an  intermedeate enry, it is way faster to use the CopyArray Mozaic function:
  
Line 465: Line 476:
 </code> </code>
 =====  Using Logic Operators in Expressions instead of IF cases =====  =====  Using Logic Operators in Expressions instead of IF cases ===== 
-<html><p align = "right"><small><i>From -ki</i></small></p></html>+<WRAP group><WRAP right><sup>From -ki</sup></WRAP></WRAP>
  
 Boolean expressions compute to either 1 or 0, which are the internal values for TRUE/FALSE or YES/NO. Boolean expressions compute to either 1 or 0, which are the internal values for TRUE/FALSE or YES/NO.
Line 503: Line 514:
 \\  \\ 
 ===== Using Inc and Dec in Expressions =====  ===== Using Inc and Dec in Expressions ===== 
-<html><p align = "right"><small><i>From -ki</i></small></p></html>+<WRAP group><WRAP right><sup>From -ki</sup></WRAP></WRAP>
  
 TheOriginalPaulB discovered that Inc and Dec are working as functions. Both Inc and Dec are ‚pre-increment‘ operations like ++var  in C, as the function returns the already incremented value. This allows for several interesting language constructs: TheOriginalPaulB discovered that Inc and Dec are working as functions. Both Inc and Dec are ‚pre-increment‘ operations like ++var  in C, as the function returns the already incremented value. This allows for several interesting language constructs:
Line 540: Line 551:
 \\  \\ 
 ===== Calculate Standard Chords from a Root Note ==== ===== Calculate Standard Chords from a Root Note ====
-<html><p align = "right"><small><i>From wim</i></small></p></html>+<WRAP group><WRAP right><sup>From wim</sup></WRAP></WRAP>
  
 This is a compact way to build standard chords from just a root note. It turns out that for standard western scales such as Major, Minor, Dorian, Phrygian, etc, normal chord notes can be found by starting at the root and counting up in steps of three semitones then quantizing up to the next scale tone. Repeat this for the number of notes you want in the chord (triad (3), seventh (4), ninth (5), eleventh (6), 13th (7). This is a compact way to build standard chords from just a root note. It turns out that for standard western scales such as Major, Minor, Dorian, Phrygian, etc, normal chord notes can be found by starting at the root and counting up in steps of three semitones then quantizing up to the next scale tone. Repeat this for the number of notes you want in the chord (triad (3), seventh (4), ninth (5), eleventh (6), 13th (7).
Line 559: Line 570:
 \\  \\ 
 ===== Include Snippets ===== ===== Include Snippets =====
-<html><p align = "right"><small><i>From -ki</i></small></p></html>+<WRAP group><WRAP right><sup>From -ki</sup></WRAP></WRAP>
  
 On PatchStorage you can find several 'Include Snippets' that cover specific programming problems and that are intended to be appended your own scipt code. On PatchStorage you can find several 'Include Snippets' that cover specific programming problems and that are intended to be appended your own scipt code.
  • mozaic_tips_and_tricks.txt
  • Last modified: 2024/04/23 19:07
  • by _ki