How to allocate current inlet and previous inlet to different var

wiccy's icon

Dear all.

I am completely new to using javascript. But I am intending to find the rate of change or velocity of an inlet stream. So my idea is to find the difference between the current value and the previous value of the inlet. So the pseudocode I think is:

a = inlet;
wait for an interval x ms ;
b = inlet;
outlet = b - a;

Can you help me out with this? What should the script be?

Many thanks to you all.

Jiajun

tonton's icon

my be what you looking for...?

best regards

peet

difference.maxpat
Max Patch
difference.js
js
tonton's icon

maybe what you're looking for...?

best regards

peet

difference1.maxpat
Max Patch
difference1.js
js