Global to create MIDI Slider Time from 1 to 300 seconds

Tue May 19, 2020 6:02 am

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 10 times
LexD
 
Posts: 17
Joined: Tue Apr 07, 2020 10:18 pm

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

Thu May 21, 2020 3:13 pm

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/Magic_UsersGuide.html#MIDIFeatures.

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.
Eric
Site Admin
 
Posts: 2795
Joined: Wed Apr 09, 2014 9:28 pm

Return to General Discussion

© 2020 Color & Music, LLC • This web site is mobile-friendly