[PD] Scaling values in pd

Ed Kelly morph_2016 at yahoo.co.uk
Tue Sep 3 23:59:55 CEST 2013

```Whoops! Here's the other one!

Cheers,
Ed

----- Forwarded Message -----
>From: Ed Kelly <morph_2016 at yahoo.co.uk>
>To: Mario Mey <mariomey at gmail.com>; "pd-list at iem.at" <pd-list at iem.at>
>Sent: Tuesday, 3 September 2013, 22:58
>Subject: Re: [PD] Scaling values in pd
>
>
>
>Couple of tricks for scaling here.
>
>
>These are from my Pd workshops at Camberwell College of Art in London. The sutoscaler abstraction is especially useful when you don't know what the input will be, but you want to specify the output range. The other patch is a tutorial on how to scale input values with a bit more explanation.
>
>Enjoy!
>
>
>Ed
>
>
>Ninja Jamm - a revolutionary new music remix app from Ninja Tune and Seeper, for iPhone and iPad
>http://www.ninjajamm.com/
>
>
>
>Gemnotes-0.2: Live music notation for Pure Data, now with dynamics!
>http://sharktracks.co.uk/
>
>
>>________________________________
>> From: Mario Mey <mariomey at gmail.com>
>>To: pd-list at iem.at
>>Sent: Tuesday, 3 September 2013, 15:15
>>Subject: Re: [PD] Scaling values in pd
>>
>>
>>El 03/09/13 10:11, Lorenzo Sutton
escribió:
>>> On 03/09/2013 14:06, Mario Mey wrote:
>>>> IOhannes, you are right only in these cases:
>>>>
>>>> 0 127 0 500
>>>> 0 300 0 1
>>>> ...
>>>>
>>>> But, if I need:
>>>>
>>>> 50 10 0 500|
>>> (assuming you want to map have 50 mapped to the 'minimum'):
>>> |
>>> [- 10]
>>> |
>>> [t b f]
>>> |   /
>>> [-  ]
>>> |
>>> [* 12.5]
>>> |
>>>
>>>> 3000 -3000 0.5 0.6
>>> [* -1]
>>> |
>>> [+ 3000]
>>> |
>>> [/ 60000]
>>> |
>>> [+ 0.5]
>>
>>Yes, you can make this math every scale you need... or use an abstract
>>that does the same automatically. In my patch, I use 284 lin-eq-conv
>>objects. I didn't want to think how to make that math... and change
>>everytime (normally, I create a lin-eq-conv and change its values a lot
>>of times).
>>
>>Best.
>>
>>
>>>
>>>>
...
>>>>
>>>> I will need a "linear equation conversion". As I wrote in last mail,
>>>> I was needing something like this, first in ActionScript... then in
>>>> Python... but I never could did it. Now, I needed again in Pd... so,
>>>> I made lin-eq-conv.pd with extrapolation and lin-eq-conv-clip.pd for
>>>> clipped values. I made it as neat as I could, to see how it works.
>>>> Using x0-x1 and y0-y1, it uses expr to get "a" and "b" at load. Then,
>>>> it only computes "aX + b = Y".
>>>>
>>>> I attach the lin-eq-conv.pd, lin-eq-conv-clip.pd and
>>>> lin-eq-conv-help.pd.
>>>>
>>>> Also, I have some issues using [autoscale]. I start giving values and
>>>> it outputs only 1. Then, I start to down the input and, then, it
>>>> Pd-Extended 64bits).
>>>>
>>>> PD:
translated to Python:
>>>>
>>>> |def lin_eq_conv(x, x0, x1, y0, y1):
>>>>    a = (y0 - y1) / (x0 - x1)
>>>>    b = (a * x0) + y0
>>>>    return a * x + b|
>>>>
>>>>
>>>>
>>>>
>>>> El 03/09/13 03:32, IOhannes zmölnig escribió:
>>>>> On 09/02/2013 06:17 PM, hghoyer wrote:
>>>>>> Hi,
>>>>>>
>>>>>> in Max/MSP there is an object for simple scaling.
>>>>>>
>>>>>> If you create in MAX these object with this arguments:
>>>>>>
>>>>>> [scale 0 127 0 500] incomming messages from 0 to 127 are automatically
>>>>>> scaled from 0 to 500...
>>>>> honestly i'm of the firm conviction that you should learn how scaling
>>>>> works: it really is only a matter of adding, multiplying, dividing,
>>>>> subtracting - stuff you should
heave learned in primary school.
>>>>>
>>>>> as frank pointed out, this should do for you:
>>>>>
>>>>> |
>>>>> [/ 127]
>>>>> |
>>>>> [* 500]
>>>>> |
>>>>>
>>>>> if you find it too tedious to do the maths over and over again, you
>>>>> might want to create an abstraction.
>>>>>
>>>>>
>>>>> being able to solve trivial problems like this will surely empower you
>>>>> to solve more complex problems :-)
>>>>>
>>>>> gamsdr
>>>>> IOhannes
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Pd-list at iem.at  mailing list
>>>>> UNSUBSCRIBE and account-management
>>>>> ->http://lists.puredata.info/listinfo/pd-list
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Pd-list at iem.at mailing list
>>>> UNSUBSCRIBE and account-management ->
>>>> http://lists.puredata.info/listinfo/pd-list
>>>
>>>
>>> _______________________________________________
>>> Pd-list at iem.at mailing list
>>> UNSUBSCRIBE and account-management ->
>>> http://lists.puredata.info/listinfo/pd-list
>>
>>
>>_______________________________________________
>>Pd-list at iem.at mailing list
>>UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20130903/28a2b9cf/attachment-0001.htm>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 0A_Scaling-2.pd
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20130903/28a2b9cf/attachment-0001.txt>
```