non-linear to linear

Feb 16, 2009 at 9:57pm

non-linear to linear

I would like to scale exponential data coming from a potentiometer (slider) to linear. Does anyone have any hints?

#42339
Feb 16, 2009 at 10:06pm

Have a look at the ‘expr‘ object (for instance, expr exp($f1))
Zoe

#151526
Feb 16, 2009 at 10:09pm

Or for your case, maybe more kindof ‘expr log($f1)’, or ‘expr ln($f1)’, depending on what kind of log you’re after.

Maybe ‘dbtoa’ or ‘atodb’ could also be helpful – Z.

#151527
Feb 16, 2009 at 10:13pm

You can use a logarithmic function as a reciprocal function for any exponential function.

For instance if your exponential function is pow(2, x) the function log2(x) will allow you to get a linear output. It means you must know the base of the exponential function.

There is no log object allowing you to choose the base you want, however there is a property of logarithms you can use :
log a (b) = log c (a)/ log c (b)

With expr, this would result in this:
expr log($f1)/log($f2) with $f1 being the numbers coming from the slider and $f2 being the base of the logarithm (2 in the former example).

Hope this helps.

Roald Baudoux

#151528
Feb 17, 2009 at 9:36am

I am not fluent in thinking in log and exp therefore I’ve build a little patch that does virtually what I need. It would be lovely to learn how I could use one object to do this:

{
“patcher” : {
“fileversion” : 1,
“rect” : [ 404.0, 135.0, 388.0, 243.0 ],
“bglocked” : 0,
“defrect” : [ 404.0, 135.0, 388.0, 243.0 ],
“openrect” : [ 0.0, 0.0, 0.0, 0.0 ],
“openinpresentation” : 0,
“default_fontsize” : 10.0,
“default_fontface” : 0,
“default_fontname” : “Verdana”,
“gridonopen” : 0,
“gridsize” : [ 15.0, 15.0 ],
“gridsnaponopen” : 0,
“toolbarvisible” : 1,
“boxanimatetime” : 200,
“imprint” : 0,
“metadata” : [ ],
“boxes” : [ {
"box" : {
"maxclass" : "number",
"outlettype" : [ "int", "bang" ],
“patching_rect” : [ 112.0, 199.0, 50.0, 19.0 ],
“fontsize” : 10.0,
“id” : “obj-2″,
“numinlets” : 1,
“fontname” : “Verdana”,
“numoutlets” : 2
}

}
, {
“box” : {
“maxclass” : “number”,
“outlettype” : [ "int", "bang" ],
“patching_rect” : [ 197.0, 93.0, 50.0, 19.0 ],
“fontsize” : 10.0,
“id” : “obj-71″,
“numinlets” : 1,
“fontname” : “Verdana”,
“numoutlets” : 2
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “scale 21 950 85 127″,
“outlettype” : [ "int" ],
“patching_rect” : [ 197.0, 125.0, 113.0, 19.0 ],
“fontsize” : 10.0,
“id” : “obj-72″,
“numinlets” : 6,
“fontname” : “Verdana”,
“numoutlets” : 1
}

}
, {
“box” : {
“maxclass” : “number”,
“outlettype” : [ "int", "bang" ],
“patching_rect” : [ 197.0, 155.0, 50.0, 19.0 ],
“fontsize” : 10.0,
“id” : “obj-73″,
“numinlets” : 1,
“fontname” : “Verdana”,
“numoutlets” : 2
}

}
, {
“box” : {
“maxclass” : “number”,
“outlettype” : [ "int", "bang" ],
“patching_rect” : [ 40.0, 93.0, 50.0, 19.0 ],
“fontsize” : 10.0,
“id” : “obj-70″,
“numinlets” : 1,
“fontname” : “Verdana”,
“numoutlets” : 2
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “if $i1 < 21 then $i1 else out2 $i1",
“outlettype” : [ "", "" ],
“patching_rect” : [ 40.0, 66.0, 177.0, 19.0 ],
“fontsize” : 10.0,
“id” : “obj-69″,
“numinlets” : 1,
“fontname” : “Verdana”,
“numoutlets” : 2
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “scale 0 20 0 85″,
“outlettype” : [ "int" ],
“patching_rect” : [ 40.0, 125.0, 88.0, 19.0 ],
“fontsize” : 10.0,
“id” : “obj-67″,
“numinlets” : 6,
“fontname” : “Verdana”,
“numoutlets” : 1
}

}
, {
“box” : {
“maxclass” : “number”,
“outlettype” : [ "int", "bang" ],
“patching_rect” : [ 40.0, 35.0, 52.0, 19.0 ],
“fontsize” : 10.0,
“id” : “obj-39″,
“numinlets” : 1,
“fontname” : “Verdana”,
“numoutlets” : 2
}

}
, {
“box” : {
“maxclass” : “number”,
“outlettype” : [ "int", "bang" ],
“patching_rect” : [ 40.0, 155.0, 50.0, 19.0 ],
“fontsize” : 10.0,
“id” : “obj-33″,
“numinlets” : 1,
“fontname” : “Verdana”,
“numoutlets” : 2
}

}
],
“lines” : [ {
"patchline" : {
"source" : [ "obj-73", 0 ],
“destination” : [ "obj-2", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-33", 0 ],
“destination” : [ "obj-2", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-69", 1 ],
“destination” : [ "obj-71", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-39", 0 ],
“destination” : [ "obj-69", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-69", 0 ],
“destination” : [ "obj-70", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-67", 0 ],
“destination” : [ "obj-33", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-70", 0 ],
“destination” : [ "obj-67", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-72", 0 ],
“destination” : [ "obj-73", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-71", 0 ],
“destination” : [ "obj-72", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
]
}

}

#151529
Feb 17, 2009 at 9:46am

#151530
Feb 17, 2009 at 10:26am

Thanks. I made 3 splits and tuned them to the slider output. Works fine for now.

#151531

You must be logged in to reply to this topic.