so you say this is actually the section of the code I'm looking for to make the conversion I want, right?
======
static void hslider_set(t_hslider *x, t_floatarg f) /* bugfix */
{
double g;
if(x->x_gui.x_isa.x_reverse) /* bugfix */
{
if(f > x->x_min)
f = x->x_min;
if(f < x->x_max)
f = x->x_max;
}
else
{
if(f > x->x_max)
f = x->x_max;
if(f < x->x_min)
f = x->x_min;
}
if(x->x_lin0_log1)
g = log(f/x->x_min)/x->x_k;
else
g = (f - x->x_min) / x->x_k;
x->x_val = (int)(100.0*g + 0.49999);
x->x_pos = x->x_val;
(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
}
2014-03-17 4:07 GMT-03:00 Jonathan Wilkes jancsika@yahoo.com:
AFAICT vslider is saving something like a slider position, and your expression above (along with the code I posted) is for getting back the original value from it. If you send it something between 0.01 and 1 you'll get a curve that's inverted from the one you're after. If you send it a slider position-- something like another [expr] based on the code inside vslider_set-- you'll get back (roughly) the same value you input.
But I'm still stuck on why vslider_bang is doing any math at all. Why should it be more complex than "if bang then output stored value"? (Setting aside sending to receive symbols for the moment.)
-Jonathan
On Monday, March 17, 2014 1:21 AM, Alexandre Torres Porres < porres@gmail.com> wrote: Hi Roman. This is turning out trickier than I thought. A friend explained the code to me and got to the following equation, with min/max values as 0.01 and 1 respectively.
[expr 0.01 * exp((log(1 / 0.01) / 0.01) * $f1 * 0.01)]
For what I've checked, it seems to behave like your patch. But it doesn't do the trick I'm looking for yet. I sent a patch earlier, and I'm sending it back again.
The goal is to connect a linear slider to an [expr] (with this so called "log" function) and then to another linear slider. The idea then is that this second slider behaves as one that was set as being "log".
In the patch attached I was able to emulate it poorly with [pow 0.25], but that was before reaching the list. See that if I use this expr function from the code or your patch it presents quite a different behavior.
maybe it is some sort of inversion of this equation, not sure. Apparently this code converts the "log" function values to linear and I'm hoping to get the exact opposite. Got it?
Thanks for looking into this
2014-03-12 4:38 GMT-03:00 Roman Haefeli reduzent@gmail.com:
On Don, 2014-03-06 at 21:37 -0300, Alexandre Torres Porres wrote:
hi folks, out of curiosity, what's the exact log function used in the slider? I'd like to emulate it.
I am not sure, if this is what you want. It converts the incoming linear range between 0 and 1 to a logarithmic range specified by $1 and $2, respectively by the second and third inlet. They behave like the lower and upper bound specified in the [vslider]/[hslider] classes.
https://raw.github.com/reduzent/netpd2-patches/master/abs/rh_scalelog.pd
Roman
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list