Previous topicNext topic

Global to create MIDI Slider Time from 1 to 300 seconds

Questions, comments, feedback, etc.
Post Reply
LexD
Posts: 20
Joined: Tue Apr 07, 2020 10:18 pm

Global to create MIDI Slider Time from 1 to 300 seconds

Post 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 228 times
Magic
Site Admin
Posts: 3440
Joined: Wed Apr 09, 2014 9:28 pm

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

Post 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.
Post Reply