hi folks, out of curiosity, what's the exact log function used in the slider? I'd like to emulate it.
cheers
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 porres@gmail.com wrote:
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
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 patch I'm sending, which was my attempt to get this right before reaching the list, I was able to emulate a bit reasonably with [expr pow($f1, 0.25)].
Cheers
2014-03-06 21:56 GMT-03:00 Jonathan Wilkes jancsika@yahoo.com:
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 < porres@gmail.com> wrote: 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
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 silently changes a minimum of "0" to max / 100, so you get a runtime error where you can't turn the volume down all the way. Then when you figure out what it did you have to add an object to subtract that last little bit, at which point you might as well have used [rms] or coded your own algorithm.
-Jonathan
On Tuesday, March 11, 2014 8:08 PM, Alexandre Torres Porres porres@gmail.com wrote:
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 patch I'm sending, which was my attempt to get this right before reaching the list, I was able to emulate a bit reasonably with [expr pow($f1, 0.25)].
Cheers
2014-03-06 21:56 GMT-03:00 Jonathan Wilkes jancsika@yahoo.com:
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 porres@gmail.com wrote:
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
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
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
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
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
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 of a logarithmic slider, but you're looking for the function to feed a linear slider so that it behaves as if it would be a logarithmic slider, right?
I'm interested to see, if someone comes up with a solution...
Roman
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 it. The abstraction I posted emulates the output of a logarithmic slider, but you're looking for the function to feed a linear slider so that it behaves as if it would be a logarithmic slider, right?
I'm interested to see, if someone comes up with a solution...
This is from Pd-l2ork, so the codebase might be slightly different.
Also, notice I've got hard-coded slider height = 128 in the algo.
Still don't understand why math is done in vslider_bang.
-Jonathan
Roman
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
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, took me a long time). But I don't really have a clue how to do it. The abstraction I posted emulates the output of a logarithmic slider, but you're looking for the function to feed a linear slider so that it behaves as if it would be a logarithmic slider, right?
I'm interested to see, if someone comes up with a solution...
This is from Pd-l2ork, so the codebase might be slightly different.
It looks pretty good on Pd vanilla, too.
Also, notice I've got hard-coded slider height = 128 in the algo.
Still don't understand why math is done in vslider_bang.
But that's how you did it? The code in your patch is based on the code from vslider_bang? I don't understand it at all, but it works :-)
And you're asking, why go all through the trouble to get back the input value instead of just spitting out the input value? Not a clue (someone wanted to show off their math skills?)
"Hehe, look, I can do it this way, but look now, I can also do it this way .. hehe .. pretty cool, uuh?" ;-)
Roman
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 the slider position or calculate a new stored value from mouse input.
-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
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
Cheers
2014-03-18 5:13 GMT-03:00 Jonathan Wilkes jancsika@yahoo.com:
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 the slider position or calculate a new stored value from mouse input.
-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
and as I was checking before, not too far from raising to the power of 0.25 (thicker line in the graph from the picture attached)
2014-03-18 16:48 GMT-03:00 Alexandre Torres Porres porres@gmail.com:
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
Cheers
2014-03-18 5:13 GMT-03:00 Jonathan Wilkes jancsika@yahoo.com:
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 the slider position or calculate a new stored value from mouse input.
-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
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 GMT-03:00 Alexandre Torres Porres porres@gmail.com:
and as I was checking before, not too far from raising to the power of 0.25 (thicker line in the graph from the picture attached)
2014-03-18 16:48 GMT-03:00 Alexandre Torres Porres porres@gmail.com:
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
Cheers
2014-03-18 5:13 GMT-03:00 Jonathan Wilkes jancsika@yahoo.com:
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 the slider position or calculate a new stored value from mouse input.
-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
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 porres@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 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 GMT-03:00 Alexandre Torres Porres porres@gmail.com:
and as I was checking before, not too far from raising to the power of
0.25 (thicker line in the graph from the picture attached)
2014-03-18 16:48 GMT-03:00 Alexandre Torres Porres porres@gmail.com:
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
Cheers
2014-03-18 5:13 GMT-03:00 Jonathan Wilkes jancsika@yahoo.com:
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 the slider position or calculate a new stored value from mouse input.
-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
On 03/18/2014 04:05 PM, Alexandre Torres Porres wrote:
and as I was checking before, not too far from raising to the power of 0.25 (thicker line in the graph from the picture attached)
Btw-- here's what that patch looks like in Pd-l2ork (attached).
The array rectangle is orange because it's selected. I also changed the size of the garray by click-dragging with the mouse.
-Jonathan
2014-03-18 16:48 GMT-03:00 Alexandre Torres Porres <porres@gmail.com mailto:porres@gmail.com>:
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 Cheers 2014-03-18 5:13 GMT-03:00 Jonathan Wilkes <jancsika@yahoo.com <mailto:jancsika@yahoo.com>>: 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 the slider position or calculate a new stored value from mouse input. -Jonathan On Monday, March 17, 2014 1:21 AM, Alexandre Torres Porres <porres@gmail.com <mailto: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
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 formula now so it's more related to Roman's patch.
It's something like this now
[expr~ min_$0 * exp($v1 * log(max_$0 / min_$0))]
then doing the inverse is not too complicated, just use "ln"
I still have not much clue about the original code, the slider height variable and other things, but, anyhow, these were the equations I was looking for ;)
cheers
2014-03-18 18:32 GMT-03:00 Jonathan Wilkes jancsika@yahoo.com:
On 03/18/2014 04:05 PM, Alexandre Torres Porres wrote:
and as I was checking before, not too far from raising to the power of 0.25 (thicker line in the graph from the picture attached)
Btw-- here's what that patch looks like in Pd-l2ork (attached).
The array rectangle is orange because it's selected. I also changed the size of the garray by click-dragging with the mouse.
-Jonathan
2014-03-18 16:48 GMT-03:00 Alexandre Torres Porres porres@gmail.com:
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
Cheers
2014-03-18 5:13 GMT-03:00 Jonathan Wilkes jancsika@yahoo.com:
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 the slider position or calculate a new stored value from mouse input.
-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
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 values, you can just work with this ratio variable.
Something like:
[expr exp($f1 * log(ratio))]
Now this will give you a value from 1 to the value of "ratio". And I thought it'd be cool to scale it from 0 to 1.
One thing that annoys me a lot is that the log function will not allow you to start at zero. So I wanted to tweak this in order to make it so.
Not hard, something like this does the trick.
[expr exp($f1 * log(ratio) - 1) / (ratio -1)]
You can always rescale this by multiplying to any factor and summing to a constant.
cheers
2014-03-18 19:27 GMT-03:00 Alexandre Torres Porres porres@gmail.com:
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 formula now so it's more related to Roman's patch.
It's something like this now
[expr~ min_$0 * exp($v1 * log(max_$0 / min_$0))]
then doing the inverse is not too complicated, just use "ln"
I still have not much clue about the original code, the slider height variable and other things, but, anyhow, these were the equations I was looking for ;)
cheers
2014-03-18 18:32 GMT-03:00 Jonathan Wilkes jancsika@yahoo.com:
On 03/18/2014 04:05 PM, Alexandre Torres Porres wrote:
and as I was checking before, not too far from raising to the power of 0.25 (thicker line in the graph from the picture attached)
Btw-- here's what that patch looks like in Pd-l2ork (attached).
The array rectangle is orange because it's selected. I also changed the size of the garray by click-dragging with the mouse.
-Jonathan
2014-03-18 16:48 GMT-03:00 Alexandre Torres Porres porres@gmail.com:
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
Cheers
2014-03-18 5:13 GMT-03:00 Jonathan Wilkes jancsika@yahoo.com:
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 the slider position or calculate a new stored value from mouse input.
-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
here's what I got as an abstraction
2014-03-18 21:12 GMT-03:00 Alexandre Torres Porres porres@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 have 10 and 1000, the plotting curve looks always the same. So if you forget about the minimum and maximum values, you can just work with this ratio variable.
Something like:
[expr exp($f1 * log(ratio))]
Now this will give you a value from 1 to the value of "ratio". And I thought it'd be cool to scale it from 0 to 1.
One thing that annoys me a lot is that the log function will not allow you to start at zero. So I wanted to tweak this in order to make it so.
Not hard, something like this does the trick.
[expr exp($f1 * log(ratio) - 1) / (ratio -1)]
You can always rescale this by multiplying to any factor and summing to a constant.
cheers
2014-03-18 19:27 GMT-03:00 Alexandre Torres Porres porres@gmail.com:
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 formula now so it's more related to Roman's patch.
It's something like this now
[expr~ min_$0 * exp($v1 * log(max_$0 / min_$0))]
then doing the inverse is not too complicated, just use "ln"
I still have not much clue about the original code, the slider height variable and other things, but, anyhow, these were the equations I was looking for ;)
cheers
2014-03-18 18:32 GMT-03:00 Jonathan Wilkes jancsika@yahoo.com:
On 03/18/2014 04:05 PM, Alexandre Torres Porres wrote:
and as I was checking before, not too far from raising to the power of 0.25 (thicker line in the graph from the picture attached)
Btw-- here's what that patch looks like in Pd-l2ork (attached).
The array rectangle is orange because it's selected. I also changed the size of the garray by click-dragging with the mouse.
-Jonathan
2014-03-18 16:48 GMT-03:00 Alexandre Torres Porres porres@gmail.com:
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
Cheers
2014-03-18 5:13 GMT-03:00 Jonathan Wilkes jancsika@yahoo.com:
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 the slider position or calculate a new stored value from mouse input.
-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
there's a bug in one of the number boxes, sorry
2014-03-18 23:37 GMT-03:00 Alexandre Torres Porres porres@gmail.com:
here's what I got as an abstraction
2014-03-18 21:12 GMT-03:00 Alexandre Torres Porres porres@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 have 10 and 1000, the plotting curve looks always the same. So if you forget about the minimum and maximum values, you can just work with this ratio variable.
Something like:
[expr exp($f1 * log(ratio))]
Now this will give you a value from 1 to the value of "ratio". And I thought it'd be cool to scale it from 0 to 1.
One thing that annoys me a lot is that the log function will not allow you to start at zero. So I wanted to tweak this in order to make it so.
Not hard, something like this does the trick.
[expr exp($f1 * log(ratio) - 1) / (ratio -1)]
You can always rescale this by multiplying to any factor and summing to a constant.
cheers
2014-03-18 19:27 GMT-03:00 Alexandre Torres Porres porres@gmail.com:
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 formula now so it's more related to Roman's patch.
It's something like this now
[expr~ min_$0 * exp($v1 * log(max_$0 / min_$0))]
then doing the inverse is not too complicated, just use "ln"
I still have not much clue about the original code, the slider height variable and other things, but, anyhow, these were the equations I was looking for ;)
cheers
2014-03-18 18:32 GMT-03:00 Jonathan Wilkes jancsika@yahoo.com:
On 03/18/2014 04:05 PM, Alexandre Torres Porres wrote:
and as I was checking before, not too far from raising to the power of 0.25 (thicker line in the graph from the picture attached)
Btw-- here's what that patch looks like in Pd-l2ork (attached).
The array rectangle is orange because it's selected. I also changed the size of the garray by click-dragging with the mouse.
-Jonathan
2014-03-18 16:48 GMT-03:00 Alexandre Torres Porres porres@gmail.com:
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
Cheers
2014-03-18 5:13 GMT-03:00 Jonathan Wilkes jancsika@yahoo.com:
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 the slider position or calculate a new stored value from mouse input.
-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