Switching when values arrive in a certain order?

Peter Ostry's icon

I get MIDI from a controller and want to [toggle] only in a particular situation:

CC#7 goes to zero and there is no other CC#7 message afterwards.
Now goes CC#10 to 127.
Than bang.
(If CC#7 does anything after it went to 0, there is no bang.)

I hope this was clear and it is a kind of a simple latch. But what is the best way to do it in Max, is there an object which does exactly these things?

I got it working but I needed 5 if-statements and complicated cabling. I wonder if there is a better way.

Mattijs's icon

This might work, depending on which other input you get. It's not a general solution though.

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

Mattijs

Jeremy's icon

Something like this should handle your special case. There's no general "if something happens after something, but not after something else, and if so and so is the case, then bang" object. Which is why you're using Max, right?

jb

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

Peter Ostry's icon

Quote: Mattijs wrote on Sat, 05 April 2008 03:12
----------------------------------------------------
> This might work, depending on which other input you get. It's not a general solution though.

Hm, looks pretty, works with clicking but I don't know how to make the two lists to feed the [match] thingy. Some basics still missing ;-)

Quote: Jeremy Bernstein wrote on Sat, 05 April 2008 04:00
----------------------------------------------------
> Something like this should handle your special case.

Yess Sir.
Thanks. I am going to study that.

>There's no general "if something happens after something, but not after something else, and if so and so is the case, then bang" object. Which is why you're using Max, right?

I use Max because I wanted some software Lego to play with while my girl friend sleeps. No. Actually I started because the Logic environment cannot do what I want and MainStage can't either. And although I do basically not like graphical programming interfaces, I find Max/MSP really great. I am overhelmed with the sheer number of objects and find it very hard to find the right bricks but it is certainly one of the best programs I've ever seen.

Mattijs's icon

Quote: Peter Ostry wrote on Sat, 05 April 2008 12:48
----------------------------------------------------
> Quote: Mattijs wrote on Sat, 05 April 2008 03:12
> ----------------------------------------------------
> > This might work, depending on which other input you get. It's not a general solution though.
>
> Hm, looks pretty, works with clicking but I don't know how to make the two lists to feed the [match] thingy. Some basics still missing ;-)
>

Ah, you mean something like this?

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

Mattijs

Peter Ostry's icon

Quote: Mattijs wrote on Sat, 05 April 2008 05:02
----------------------------------------------------
> > > This might work, depending on which other input you get. It's not a general solution though.

> Quote: Peter Ostry wrote on Sat, 05 April 2008 12:48
> ----------------------------------------------------
> > Hm, looks pretty, works with clicking but I don't know how to make the two lists to feed the [match] thingy. Some basics still missing ;-)

> > Quote: Mattijs wrote on Sat, 05 April 2008 03:12
> > ----------------------------------------------------
> Ah, you mean something like this?
>

Oh yeah, now I begin to understamd this packing and matching. No, it can't work in this case. The patch assumes that the two values come consecutively but there is something between. I did not tell the exact situation. CC#10 goes down to zero but not instantly. Here is what happens:

First:
CC#7 = 56, 55, 54, 53, ..., 0
I have to detect this and watch if it changes.

Then:
CC#10 = 34, 33, 32, 31, ..., 0
Hey I got a zero on CC#10 - Was CC#7 at 0 the last time?
Yes, bang and sorry for misleading Mattijs.

It is a two-dimensional MIDI expression pedal which sends a volume message for up/down and a pan message for sideways. I needed a software switch for that pedal: I push the heel fully down (CC#7=0) and turn the foot sideways (CC#10=127). Then bang, switch, cheers amd thank you both!

johnpitcairn's icon

Uh ... ?

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

johnpitcairn's icon

Or ...

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

Peter Ostry's icon

Quote: johnpitcairn wrote on Sun, 06 April 2008 17:12
----------------------------------------------------
> Uh ... ?
----------------------------------------------------

Uh.

Works well. Small and beautyful!
Thanks John.

Peter Ostry's icon

Quote: johnpitcairn wrote on Mon, 07 April 2008 01:15
----------------------------------------------------
> Or ...

Only one object with a simple formula!
Yes, the second input does the trick.

That is what I call elegance.
Many thanks for this example.

outoftheaircrash's icon

..a slightly related question, and hopefully much more simple..

Does anyone know how to convert a temporary midi bang to a 'latch'?

I've got a Nanokontrol, and all the buttons are temp rather than latches. So when I'm trying to assign one to a toggle, it is only 'active' of course, while the button on the nano is depressed..

Anyone got any ideas?

Kris