[dial] 360 degrees no clipping - counting each revolution

Michael Sperone's icon

Hi,

I want to use a [dial] object to control a timer. Where one full turn is 60s, and when you go all the way around, it can send a bang or something to make another number box go up one (minutes).

I first tried [match 59 0] and [match 0 59] (for turning the dial backwards). that worked well, except when I turn the dial fast (dial skips numbers when you go fast). I then tried something with [>] which I can only get working well for increasing values, and won't let you decrease.

Has anyone did anything like this before? Any ideas?

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

here's 2 tries in 1 patch with comments, as you can see in the left one, it works unless you try to spin the dial too fast.

Tristan's icon

It's a little hackish but try this. You can't spin the dial extremely fast but it seems to work at reasonable speeds.

//--dialhelper.js--

inlets = 1;
outlets = 1;

var last = 0.0;

function msg_float(current)
{
// dial outputs neg nums if spun too fast..
current = Math.abs(current);

if (last > 0.6 && current < 0.4)
{
outlet(0, "inc");
last = 0.0;
}
else if (last < 0.4 && current > 0.6)
{
outlet(0, "dec");
last = 1.0;
}
else
last = current;
}

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

//-----------

Michael Sperone's icon

Thank you so much tristanb!

This seems to work great so far, I will put it into my patch later to see if it works as well in my full patch.

I was just thinking maybe it would require a javascript solution, and that I wanted to start learning js anyway just to have it as an extra tool I could use.

Thanks again, and of course it would be interesting to see if anyone else has alternate solutions to this as well.

Tristan's icon

Yeah, I was thinking there was probably an easier way, but I just went straight for the js. With some thinking, you could recreate that script with regular max objects though. I'd also be interested to see if someone else has a different way!