Re: [PD] log function in slider
there's a bug in one of the number boxes, sorry 2014-03-18 23:37 GMT-03:00 Alexandre Torres Porres : > here's what I got as an abstraction > > > 2014-03-18 21:12 GMT-03:00 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 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 : >> >> 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 : >>> >>> 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 : > 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 : > >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 < >> por...@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 : >> >> 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
Re: [PD] log function in slider
here's what I got as an abstraction 2014-03-18 21:12 GMT-03:00 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 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 : > > 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 : >> >> 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 : >>> 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 : 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 < > por...@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 : > > 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 [vslid
Re: [PD] log function in slider
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 : > 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 : > > 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 : >> >>> 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 : >>> >>>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 < por...@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 : 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 UNSUBSCRI
Re: [PD] log function in slider
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 : > 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 : > >> 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 : >> >>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 < >>> por...@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 : >>> >>> 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 >>> >>> >>> >> > > ___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Re: [PD] log function in slider
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 : > 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 : > > 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 : >> >> 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 : >>> >>> 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 < por...@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 : 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 >>> >> > ___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Re: [PD] log function in slider
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 : > 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 : > > 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 : >> >> 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 < >>> por...@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 : >>> >>> 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 >>> >>> >>> >> > log.pd Description: Binary data ___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Re: [PD] log function in slider
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 : > 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 < > por...@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 : > > 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 > > > log.pd Description: Binary data ___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Re: [PD] log function in slider
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 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 : 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___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Re: [PD] log function in slider
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 ___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Re: [PD] log function in slider
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 #N canvas -9 19 513 614 10; #X obj 16 319 cnv 15 202 227 empty empty empty 20 12 0 14 -233017 -66577 0; #X obj 65 57 cnv 15 351 255 empty empty empty 20 12 0 14 -233017 -66577 0; #X floatatom 148 27 5 0 0 0 f - -, f 5; #X obj 217 162 log; #X obj 217 120 f 1; #X obj 217 141 / 0.01; #X obj 217 183 /; #X obj 276 131 f 128; #X obj 276 152 - 1; #X text 331 139 x_k; #X obj 148 142 / 0.01; #X obj 148 163 log; #X obj 148 230 /; #X obj 148 67 t a b b; #X obj 148 251 * 100; #X obj 148 272 + 0.4; #X obj 148 293 int; #X text 190 295 <- x_xval; #X obj 148 374 t b a; #X obj 148 395 f 2; #X obj 148 416 + 127; #X obj 148 437 -; #X text 183 435 <- r; #X obj 148 324 + 50; #X obj 148 345 / 100; #X obj 235 493 vsl 15 128 0 127 0 0 empty empty empty 0 -9 0 10 -262144 -1 -1 0 1; #X msg 148 459 128 \$1; #X obj 148 480 -; #X obj 288 493 vsl 15 128 0.01 1 1 0 empty empty empty 0 -9 0 10 -262144 -1 -1 0 1; #X text 68 58 vslider_set; #X text 21 326 vslider_draw_update; #X text 115 581 linear slider ->; #X text 315 581 <- logarithmic slider; #X connect 2 0 13 0; #X connect 2 0 28 0; #X connect 3 0 6 0; #X connect 4 0 5 0; #X connect 5 0 3 0; #X connect 6 0 12 1; #X connect 7 0 8 0; #X connect 8 0 6 1; #X connect 10 0 11 0; #X connect 11 0 12 0; #X connect 12 0 14 0; #X connect 13 0 10 0; #X connect 13 1 4 0; #X connect 13 2 7 0; #X connect 14 0 15 0; #X connect 15 0 16 0; #X connect 16 0 23 0; #X connect 18 0 19 0; #X connect 18 1 21 1; #X connect 19 0 20 0; #X connect 20 0 21 0; #X connect 21 0 26 0; #X connect 23 0 24 0; #X connect 24 0 18 0; #X connect 26 0 27 0; #X connect 27 0 25 0; ___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Re: [PD] log function in slider
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 ___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Re: [PD] log function in slider
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.4); 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 : > 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 < > por...@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 : > > 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 > > > ___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Re: [PD] log function in slider
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 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 : 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___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Re: [PD] log function in slider
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 : > 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 > slider.pd Description: Binary data ___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Re: [PD] log function in slider
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
Re: [PD] log function in slider
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 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 : 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 >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 > > >___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Re: [PD] log function in slider
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 : > 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 < > por...@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 > > > slider.pd Description: Binary data ___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Re: [PD] log function in slider
>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 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___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
[PD] log function in slider
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