Re: [PD] log function in slider

2014-03-18 Thread Roman Haefeli
On Mon, 2014-03-17 at 18:59 -0400, Jonathan Wilkes wrote: On 03/17/2014 04:34 PM, Roman Haefeli wrote: On Mon, 2014-03-17 at 02:21 -0300, Alexandre Torres Porres wrote: Hi Roman. This is turning out trickier than I thought. I think I understand now what you are trying to achieve (sorry,

Re: [PD] log function in slider

2014-03-18 Thread Jonathan Wilkes
No, the code I ported is from vslider_set and vslider_draw_update (might be different in Vanilla). In vslider_bang, math is done to output the proper value.  Without looking at the code I would have guessed vslider_bang simply outputs a stored value like [float] does.  Then just do math to set

Re: [PD] log function in slider

2014-03-18 Thread Alexandre Torres Porres
the solution is as I thought, to just invert the given formula in the code. Someone helped me with the math, is something like expr ln($f1 / 1.27) / (((log(127 / 1.27) / 1.27)) * 0.01) here's a patch attached I'm finally gonna check what kind of curve this thing gives :) Thanks everyone

Re: [PD] log function in slider

2014-03-18 Thread Alexandre Torres Porres
but when we use the slider with the log function, we're actually doing an inversion of this graphs I just posted. In other words, what we do is the first formula that is actually from the code. So using that formula was actually right to begin with. Check my patch attached now 2014-03-18 17:05

Re: [PD] log function in slider

2014-03-18 Thread Alexandre Torres Porres
just be sure to click the message, should have put a loadbang there, sorry 2014-03-18 17:16 GMT-03:00 Alexandre Torres Porres por...@gmail.com: but when we use the slider with the log function, we're actually doing an inversion of this graphs I just posted. In other words, what we do is the

Re: [PD] log function in slider

2014-03-18 Thread Alexandre Torres Porres
cool, looks great by the way, this guy was helping me out with the math, so I don't really know what's going on that well. Apparently he couldn't figure out the slider height variable. And Roman didn't use that too. The formula was behaving the same as Roman's patch, but we simplified the

Re: [PD] log function in slider

2014-03-18 Thread Alexandre Torres Porres
Hey, a few things have made sense to me now. The minimum and maximum values in PD are in a 100 / 1 ratio. This ratio is important and it's a key in the formula. In the sense that if you have 10 and 1000, the plotting curve looks always the same. So if you forget about the minimum and maximum

Re: [PD] log function in slider

2014-03-18 Thread Alexandre Torres Porres
here's what I got as an abstraction 2014-03-18 21:12 GMT-03:00 Alexandre Torres Porres por...@gmail.com: Hey, a few things have made sense to me now. The minimum and maximum values in PD are in a 100 / 1 ratio. This ratio is important and it's a key in the formula. In the sense that if you

Re: [PD] log function in slider

2014-03-18 Thread Alexandre Torres Porres
there's a bug in one of the number boxes, sorry 2014-03-18 23:37 GMT-03:00 Alexandre Torres Porres por...@gmail.com: here's what I got as an abstraction 2014-03-18 21:12 GMT-03:00 Alexandre Torres Porres por...@gmail.com: Hey, a few things have made sense to me now. The minimum and

Re: [PD] log function in slider

2014-03-17 Thread Jonathan Wilkes
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

Re: [PD] log function in slider

2014-03-17 Thread Alexandre Torres Porres
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 =

Re: [PD] log function in slider

2014-03-17 Thread Roman Haefeli
On Mon, 2014-03-17 at 02:21 -0300, Alexandre Torres Porres wrote: Hi Roman. This is turning out trickier than I thought. I think I understand now what you are trying to achieve (sorry, took me a long time). But I don't really have a clue how to do it. The abstraction I posted emulates the output

Re: [PD] log function in slider

2014-03-17 Thread Jonathan Wilkes
On 03/17/2014 04:34 PM, Roman Haefeli wrote: On Mon, 2014-03-17 at 02:21 -0300, Alexandre Torres Porres wrote: Hi Roman. This is turning out trickier than I thought. I think I understand now what you are trying to achieve (sorry, took me a long time). But I don't really have a clue how to do

Re: [PD] log function in slider

2014-03-16 Thread Alexandre Torres Porres
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

Re: [PD] log function in slider

2014-03-12 Thread Roman Haefeli
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

Re: [PD] log function in slider

2014-03-11 Thread Alexandre Torres Porres
Thanks Jonathan. Unfortunately, my C expertise is kinda poor and I'm still lost. I see it's got something to do with [exp] but haven't got my head around the function needed to emulate it. I'm making extensive documentation about Pd, so I'd like to write about it. I find it worth noting. In the

Re: [PD] log function in slider

2014-03-11 Thread Jonathan Wilkes
Wow, never mind-- it's a veritable Rube Goldberg machine of code to get from an incoming float to an outgoing one in g_vslider.c.  There's even more math to draw the tick and I can't figure out how it works at the moment. I also love how tempting log is for a volume control, but then it

[PD] log function in slider

2014-03-06 Thread Alexandre Torres Porres
hi folks, out of curiosity, what's the exact log function used in the slider? I'd like to emulate it. cheers ___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management - http://lists.puredata.info/listinfo/pd-list

Re: [PD] log function in slider

2014-03-06 Thread Jonathan Wilkes
From g_vslider.c:     if(x-x_lin0_log1)     out = x-x_min*exp(x-x_k*(double)(x-x_val)*0.01); Where x-x_k is:     log(x-x_max/x-x_min)/(double)(x-x_gui.x_h - 1); And x-x_gui.x_h is the height of the slider -Jonathan On Thursday, March 6, 2014 7:37 PM, Alexandre Torres Porres