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/07/30 19:01] – [Multi-Line Pad Labels] Added Dynamic Letters for Labeling _ki | mozaic_tips_and_tricks [2021/04/12 17:35] – Remove/add array entries (part I) _ki | ||
---|---|---|---|
Line 9: | Line 9: | ||
* [[#Store two positive Values into a single Variable]] | * [[#Store two positive Values into a single Variable]] | ||
* [[#Store three unsigned Bytes into a single Variable]] | * [[#Store three unsigned Bytes into a single Variable]] | ||
+ | * [[#Output Fixed Point Values in Labels]] | ||
* [[#Some Best Practice Tips]] | * [[#Some Best Practice Tips]] | ||
+ | * [[#Detect Long or Short Pad Taps]] | ||
+ | * [[#Detect Long or Short SHIFT Button Taps]] | ||
* [[# | * [[# | ||
+ | * [[#Dynamic Letters for Labeling]] | ||
* [[#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]] | * [[#Knob double-tap Support]] | ||
+ | * [[#Remove or add an entry inside an array]] | ||
* [[#Using Logic Operators in Expressions instead of IF cases]] | * [[#Using Logic Operators in Expressions instead of IF cases]] | ||
* [[#Using Inc and Dec in Expressions]] | * [[#Using Inc and Dec in Expressions]] | ||
Line 80: | Line 85: | ||
varB = 124 // allowed range 0 .. ~16000 | varB = 124 // allowed range 0 .. ~16000 | ||
| | ||
- | combinedValue = valA + valB * maxA | + | combinedValue = valA + (valB * maxA) |
</ | </ | ||
+ | |||
+ | For single-byte MIDI values, use 128 for maxA | ||
To later extract the values from their packed format use | To later extract the values from their packed format use | ||
Line 116: | Line 123: | ||
</ | </ | ||
+ | |||
+ | \\ | ||
+ | ===== Output Fixed Point Values in Labels ===== | ||
+ | < | ||
+ | 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. | ||
+ | |||
+ | \\ | ||
+ | To always output a positive float with two digits (even when integer), one needs to split the input value and output the computed integer parts individually: | ||
+ | < | ||
+ | n = Round value * 100 | ||
+ | f = Div n, 100 | ||
+ | d = n-f*100 | ||
+ | r1 = Div d, 10 | ||
+ | r2 = d % 10 | ||
+ | LabelKnob 0, {B: | ||
+ | </ | ||
+ | |||
+ | \\ | ||
+ | To always output a negative and positive float with a single digit, the split needs to work on the absolute value | ||
+ | and a conditional statement is used to output both variants: | ||
+ | < | ||
+ | n = Round Abs(value * 10) | ||
+ | f = Div n, 10 | ||
+ | r = (n-f*10) % 10 | ||
+ | if value >=0 | ||
+ | LabelKnob 1, {N: +},f,{.},r | ||
+ | else | ||
+ | LabelKnob 1, {N: },f,{.},r | ||
+ | endif | ||
+ | </ | ||
\\ | \\ | ||
Line 144: | Line 182: | ||
</ | </ | ||
+ | |||
+ | \\ | ||
+ | ===== Detect Long or Short Pad Taps ===== | ||
+ | < | ||
+ | |||
+ | < | ||
+ | @OnLoad | ||
+ | FillArray downStart, | ||
+ | pressTime = 250 | ||
+ | @End | ||
+ | |||
+ | @OnPadDown | ||
+ | downStart[LastPad] = SystemTime | ||
+ | @End | ||
+ | |||
+ | @OnPadUp | ||
+ | pad = LastPad | ||
+ | if SystemTime - downStart[pad] < pressTime | ||
+ | Log {Short tap pad }, pad | ||
+ | else | ||
+ | Log {Long tap pad }, pad | ||
+ | endif | ||
+ | @End | ||
+ | </ | ||
+ | |||
+ | \\ | ||
+ | |||
+ | ===== Detect Long or Short SHIFT Button Taps ===== | ||
+ | < | ||
+ | |||
+ | < | ||
+ | @OnLoad | ||
+ | shiftStart = 0 | ||
+ | pressTime | ||
+ | @End | ||
+ | |||
+ | @OnShiftDown | ||
+ | shiftStart = SystemTime | ||
+ | @End | ||
+ | |||
+ | @OnShiftUp | ||
+ | if SystemTime - shiftStart < pressTime | ||
+ | Log {Short tap SHIFT} | ||
+ | else | ||
+ | Log {Long tap SHIFT} | ||
+ | endif | ||
+ | @End | ||
+ | </ | ||
\\ | \\ | ||
Line 180: | Line 266: | ||
</ | </ | ||
+ | \\ | ||
===== Use the SHIFT Button to toggle to HELP View ===== | ===== Use the SHIFT Button to toggle to HELP View ===== | ||
< | < | ||
Line 298: | Line 385: | ||
+ | \\ | ||
+ | ===== Remove or add an entry inside an array ===== | ||
+ | < | ||
+ | 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. | ||
+ | < | ||
\\ | \\ | ||
===== Using Logic Operators in Expressions instead of IF cases ===== | ===== Using Logic Operators in Expressions instead of IF cases ===== |