Hey. Mild head-scratcher. I can think of a couple of workarounds but wondered if there was a neater function.
I’m using an OSCin CHOP to map a bunch of faders in TouchOSC across to equivalent parameters in some base components.
All of the OSCin go from 0-1. I’d like to be able to map these to the component parameter in the same range that’s set in the customise component settings (e.g. if a component parameter is setup to go between 0.5 and 20 then I’d like 0 in the Osc fader = 0.5 and 1 = 20). Does anybody know of a way to do this neatly as I bind the channel to the component parameter without having to run out a load of messy Math range CHOPS?
Failing this, is there a way of returning the parameter min and max so that I can have a bind component or a script to adapt it automatically, otherwise I’m going to have a very large OSC management component with lots of messy stuff to manage (and if I make a change in the component itself, I’ll need to update the equivalent Math as well!).
yeah this is the reason we have a code design rule in our team to normalize all IO signals and external parameters in our projects, so everything becomes 0-1. Then within each component you can convert that to whatever range you want locally.
Having said that, you can get all of a parameter’s properties using the Par Class, such as:
op("comp).par.Myparameter.max
Get or set the parameter’s numerical maximum value
op("comp).par.Myparameter.normMax
Get or set the parameter’s maximum slider value if the parameter is a numerical slider
Also perhaps the remap method from the tdu class is useful here, so you can remap the 0-1 OSC channels to the range of your sliders, maybe in a Script CHOP:
tdu.remap(inputVal, fromMin, fromMax, toMin, toMax)
Returns the input value remapped from the first range to the second.
I wanted to control the ranges of my custom parameters on my base comp but still have an easy way to map 0-1 values to them from other sources and controllers.
I found using the parameter Dat with the NormMin and NormMax turned on (Under the Define page) and then using Chop Execute with an OnValueChange an effective way to remap values. You just have to rename the incoming channel to match your parameter name and it’ll work.
#Use a Parameter Dat that references you custom Base Comp with NormMin and MinMax on
table = op('parameter1')
value = tdu.remap(val, 0, 1, float(table[channel.name, 'normmin']) , float(table[channel.name, 'normmax']))
op('base1').par[channel.name] = value