[line] and [line~] question

Cody's icon

First of all I'm not even sure if [line/~] is the best object for what I'm trying to do.

Here is an analogy of what I would like to do: You have a balloon and you can fill it up with air at a constant rate. Press a button to fill it up to it's capacity without popping it. Release the button to deflate the balloon at the same constant rate. And you have the ability to press the button on or off midway through filling up the balloon to try and keep it within a range manually.

I have messed around with [line] and [counter] but not able to come up with anything that works or is practical. Any thoughts?

Thanks in advanced.

Rodrigo's icon
Max Patch
Copy patch and select New From Clipboard in Max.

You probably want line, and likely the float version so [line 0.]. Both line~ and line start where they left off. Here's a simple example that can get you going.

Cody's icon

Hey Rodrigo,
Thanks for the reply. I just figured it out and was going to post my findings.

The only problem with the patch as you posted doesn't have the "constant rate" im looking for. It will always take one second to go from any value. If I hold the button for .25 seconds and release it, it will take the current value of the slider 1 full second to get back to zero instead of only .25 seconds.

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

Here is what I got and it seems to work pretty well:

Rodrigo's icon

Right. I skimmed that part I guess. Seems like you got a good/workable solution.

Roman Thilenius's icon

i would still do it with [line] and not with a counter.

you simply have to calculate the duration yourself in order to get a constant velocity.

-110