Smooth transition between two numbers

encoder audio's icon

Hi there guys,

I've been thinking about this for a while, but is there any simple way to to transition between two numbers smoothly in a certain amount of time?
I know that this could be done with the line object, yet, I'm working on a M4L device, where the toggle has an initial value and that makes things complicated.
It controls an UI object and every single time I load up the device, there is an UI movement...

Source Audio's icon

togge is anyway on/off, what do you want to smooth there ?
maybe you want a delay for initial value ?
then remove initial value and use loadbang with delay.

encoder audio's icon

The toggle controls the width of the device.
If zero, the width it (let's say) 150 pixels, if 1 then it is 300.
With line, I'm able to transition 150 to 300 in 200 ms, which looks amazing, yet, since the toggle has an INIT value (0), every timeI open the M4L device, the UI jumps from 300 to 150, since the paramtering of the LINE object.
I may just don't know enough about it...

Source Audio's icon

you need to initialise the width as first, I mean to decide
if it is 150 or 300 when device gets loaded fresh.
then treat that toggle.
Do you store it's value in the live set or not ?

if yes, then you will allways have missmatch when loading device,
recalling width state, with or without that toggle.
toggle itself is not a problem

encoder audio's icon

Yes, the mismatch was problem.
Actually, I've read through again the line objects manual, and for future users, the solution is super simple.
If you want to smoothly transition between two numbers with the toggle, you can just send the $1 200 parameters to the line object and it works as it should!

Source Audio's icon

yes, line needs no from - to , 2 values are enough.
but you can initialise it with default value, like 300.

Max Patch
Copy patch and select New From Clipboard in Max.

Just Evan's icon

I'm a complete newbie, but today I was faced with the same task, and here's what I came up with.

Perhaps you will find this useful.

P.S. I don't know how to insert patches, so here's the compressed code.

<pre><code>
----------begin_max5_patcher----------
1705.3oc2Z80bahDC+4zY52gcXZeyGi1U6euo2C2M2Gg6s1axfcHIzZCd.bZ
Z6be2OAX6XGCXLESRsyCNVrFI8a+IsRB+i29lq7ll7XXlG62Yejc0U+fjbUo
rBIWsQvUdKBdb17frxE5MKYwhv3buIquXd3i4kW3Ce3CaEFcSonjoe92jByV
wKCxmceT7cWmFNKuRsbs13yUbkVJMVqQJ.yDlCz9fFoOJEnVYPENgIHYSXbq
Ov92M2w3UKhhmGlWZa7cjlrJeiXnT5+812T7N81jN6qKByxBtK7Pe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NLMqNVDF5ZunT5XIejakF
twRmXAfjPGm0RB4jLsETDjYbu7yQr4RTSIBysr2m8oOM48Yz6dmLFo6AsR47
0JzPc3XQ5pTCMT0q59c79viJKC9BCXPepamZbuGvABTeLJcQicZPoTbSEkYb
giNOrYuZc71KAgZFwWBNZYTcHTgHXQHfCPekzY4.mHCDlHndZsi9.Qazw+6v
4AeiMML+qggwr7ulrd95Yd8az4Tlz1AInF1gURAFBtV6zNIRrCAIjipegGaL
ZjGIwJkevY.N8BIO2BtKvwFS80zNJnr9bxKUVsxZbfxZuDGaLZZe54nn5vSo
Ppn1nIv3hbpwno8DnB25d3.fRK.BovcgL0XT67N4tedZpw6z85k8XiQ8QJGk
Zn+Pbxf9ZpUeiiHPTFDq5RZrwz9+oWtU8PxEwXiQkoG3gTcXAFWXiMtVGmJ6
r5IRt4mqfheFGRGJ6QqAc1Du7FbLJ6AWt1tuekN33ZcfwcvwnrG4Oe4Fbb0s
tjX87eYgkVewEd11RVxpzYaPhsOOB1NV4MgY4QwawwOtyOgLF+okkjdCUhS6
cP0cin3wc1Ain3Gz2tKaqQvGBi3428lLh0.1H527yJ3W7zR5hQnZ.7GFFfsa
FgY.A+t42afmAQkhwWk33qR4nqxNlEq3YUeFSfzw.I6YzHJG.8wMhxpINeHA
zIRW4zgYhAgAT97b5pJgATk7toR9vnRc21ccuFnXEOtny1oVa2HOlQnGt8aY
27a04Lz5f.2lhuGPdtg2MUNfPsQL9pDGeUJGcUp5F8QO9gMZ2Yr9xtl3T20b
Vq68JX4xGBSyVeWpzO066mSJ+R1IUeNJt5y5pOmFV7ayn5qT0pmWPJ0rYN0o
4pzpQA8nd8yDxaQBYBwqh1jAo.AJTcY60EiNJaYPkuV1F9aeCsf+GbmD6JA
-----------end_max5_patcher-----------
</code></pre>
Source Audio's icon

problem with that is that zl.stream 2 needs 2 values to output anything.

You will allways miss 1st received value.

Roman Thilenius's icon

which means that you have to provide the first value at initialisation - and to do so, have to choose which value will make the most sense.

while you are on it, you can then also add a "reset" function which reinitialises the process when needed.