Convert the rate of change of the input value to the sound volume

Mirie Ya's icon

Hello. I'm a beginner to Max.
I hope you understand what this question means.
I'm thinking of creating a program that calculates the rate of change of the value obtained from an analog sensor over a certain period of time and adjusts the volume of the output sound according to the rate of change.
For example, if the temperature is rising rapidly, there will be a loud sound, and if the temperature is falling slowly, there will be a small sound.
I don't know how to write the part that calculates the rate of change in Max.
Can someone give me some advice?

Volume_Change_1.maxpat
Max Patch

Sébastien Gay's icon

Some thoughts :

Mirie Ya's icon

Thank you very very much, I will try out!!

Sébastien Gay's icon

Reading this article : https://cycling74.com/tutorials/my-favorite-object-bucket, I learned that [bucket] can be used to calculate speed (and acceleration) in a very elegant way :