# Differences

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

From -ki

+ 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 + + Therefore scripts don‘t need to check for this ‚NoteOn Vel 0‘ case, as that special case is handled by Mozaic. Even when using MidiThrough, an incomming ‚NoteOn Vel 0‘ command will be converted to ‚NoteOff Vel 0‘ + ===== Two dimensional Arrays ===== ===== Two dimensional Arrays ===== Line 81: Line 92: 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 117: Line 130: + + \\ + ===== Output Fixed Point Values in Labels ===== +

From -ki

+ 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:},f,{.},r1,r2 + + + \\ + 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 145: Line 189: + + \\ + ===== Detect Long or Short Pad Taps ===== +

From wim

From wim

+ + + @OnLoad + shiftStart = 0 + pressTime  = 250 + @End + + @OnShiftDown + shiftStart = SystemTime + @End + + @OnShiftUp + if SystemTime - shiftStart < pressTime + Log {Short tap SHIFT} + else + Log {Long  tap SHIFT} + endif + @End + \\ \\ Line 181: Line 273: + \\ ===== Use the SHIFT Button to toggle to HELP View ===== ===== Use the SHIFT Button to toggle to HELP View =====

From -ki

From -ki

Line 299: Line 392: + \\ + =====  Remove or add an entry inside an array ===== +

From -ki

+ 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: + + CopyArray source, dest, size \\ \\ + === Remove an entry of an array (shift left) === + + + @OnLoad + for i=0 to 6 + a[i] = i + endfor + Log {Before },a,{ },a,{ },a,{ },a,{ },a,{ },a,{ },a + + // Remove entry a by left shift of the following entries + CopyArray a, a, 6 + + Log {After  },a,{ },a,{ },a,{ },a,{ },a,{ },a,{ },a + @End + + + \\ + === Insert an entry into array (shift right) === + + Due to the inner working of CopyArray, the above trick doesn‘t work for right shifts - but one can use a temporary array to be more efficient than iterating over the array: + + + @OnLoad + for i=0 to 6 + a[i] = i + endfor + Log {Before  },a,{ },a,{ },a,{ },a,{ },a,{ },a,{ },a + + // Insert a new a + CopyArray a, _tmp, 6 + CopyArray _tmp, a, 6 + a = 9 + + Log {After   },a,{ },a,{ },a,{ },a,{ },a,{ },a,{ },a + @End + =====  Using Logic Operators in Expressions instead of IF cases ===== =====  Using Logic Operators in Expressions instead of IF cases =====

From -ki

From -ki

• mozaic_tips_and_tricks.1596099708.txt.gz
• by _ki