Page 1 of 1

Global to create MIDI Slider Time from 1 to 300 seconds

Posted: Tue May 19, 2020 6:02 am
by LexD
I'm working on a global to be controlled by MIDI in which I'd like to adjust a timer with a range from 1 second to 300 seconds. I can't figure out the exact code but I'm in the ballpark. Project file attached. Any suggestions would be appreciated. Thanks!
Global MIDI Timer.magic
(1.68 KiB) Downloaded 229 times

Re: Global to create MIDI Slider Time from 1 to 300 seconds

Posted: Thu May 21, 2020 3:13 pm
by Magic
All MIDI values are scaled in the range of 0 to 1 (by dividing into 127), as the User's Guide describes: https://magicmusicvisuals.com/downloads ... DIFeatures.

So, to make a value go from 0 to 300 instead of 0 to 1, you simply add a Scale modifier with a parameter of 300.

If you want it to go from 1 to 300 instead of 0 to 300, you Scale it by 299 instead of 300, and then use an Offset with a parameter of 1.

The algebraic equivalent is therefore 299x + 1 = y; so when x=0, y=1; and when x=1, y=300.

However, there is something very important to understand: MIDI has a finite resolution. Native MIDI commands go from 0 to 127 in integer increments (0, 1, 2, 3 ... 127). So, using the above equation, you will never be able to get a result of 2, because 299 * (0/127) + 1 = 1, and 299 * (1/127) + 1 = approx 3.35.

This is a limitation of the MIDI protocol. OSC, by contrast, uses floating point values which have far greater resolution.