a simple gate dilemma
Having a little trouble with a gate at the moment.
Let suppose I have a gate with 3 outputs.
I’m sending it an integer in the left inlet, and then either a 1 (on) or a 0 (off) in the right inlet. So basic button states.
I’ll then attach a LED to each output of the gate, in order to test my messages are going through the right gate.
I’ll press button 1, which sends a 1 to the gate, and a 1 to right inlet. Sure enough, the LED under the first outlet blinks. If I press button one again, I’ll send it a 0 through the right inlet, and sure enough, the LED under the first outlet blinks.
This is all as I expected so far.
I press button 2, which should send a 2 to the gate, and a 1 to the right inlet. But here’s where things go a little backward. The LED under the first outlet blinks again.
If I press button 2 again, which should send a 2 to the gate, and a 0 to the right outlet, THEN the second outlet blinks. A second press of button 2 will make the second outlet blink again.
Its like every time I change the gate, I need to press the button twice, which doesn’t seem right.
Its probably something really obvious I’m guessing? :)
Just made an effort to solve this. Really dunno if this is what you want, but it could be. Patch attached (you’ll have to hit the message box ‘0’ for the first outlet, ‘1’ for the 2nd and ‘2’ for the third; things in max usually start counting from 0).
be careful with [gate], it’s one of the objects which *doesn’t* start counting from 0, at least not the way we might think. Rather, a 0 will close all outlets, regardless of how many you have. 1 will open the first outlet, etc. [switch] operates similarly.
Take a look at [trigger] for this kind of order-of-operations issue. Sounds like messages aren’t getting where they need to be in the right order. So to open outlet 2 and then send a 1 through, you’d use
[t 1 2]
the crucial thing to remember is that the 2 comes out first (and goes to the control/left inlet of [gate]), then the 1 comes out and goes through the data/right inlet. This should work. Possibly in your patch you unintentionally have the order reversed, that’s what it sounds like (needing to hit it twice, and the first hit sends to the previously-opened outlet). Right-to-left ordering of messages: is your data message to the right of the control message? :) if so, there’s your problem.
By saying that max usually counts from 0, I was referring to the umenu object (which I used to the patch I made, trying to solve toddak’s problem).
There is a trigger object there as well.
@alexandros: Thanks for your patch. I had a look at it but it does something similar. I’m thinking the problem arrises when I I’m not sending on/off messages after each other for the same gate.
To try to explain:
On your patch when I press 0, the first led lights.
However, when I hit 1 directly after turning the first led on, nothing happens. The toggle box changes, but nothing lights.
Its the second press of the 1 that makes the second LED light.
However, sending it on then off for 1 works fine, on then off for 2 works fine, and on then off for 3 works fine. Do you see what I mean? Does this mean that there are some conditions where a gate can only deal with consecutive on/off messages? And if so, any ideas as to what object would work better?
@seejayjames: yes, I was thinking along the same lines myself, but couldn’t explain as well as you could! The trigger object looks like it might solve a few problems. I thought it was an ordering problem, and thought about using a delay to delay the messages, but trigger looks alot less complicated. Do you often use triggers with gates?
And many thanks to you both! This has been a great help. Shall be back in the studio later today to try to implement a trigger.
In regards to the 0’s, I have noticed this to be a challenge. I’m working with a monome as my control surface, and the top row involves alot of 0’s as its co-ordinates. I have been putting a ‘+1’ message in a lot of the time to change its data from 0-7 to 1-8 to make things in max alot easier!
does this do what you’re looking for?
-- Pasted Max Patch, click to expand. --Copy all of the following text. Then, in Max, select New From Clipboard.----------begin_max5_patcher---------- 543.3ocuVFsbiBBEF9Z8ofgqc6HnHwdWeN1oyNjHqkNJlIRlMsc569FPMcMq 1fQkKDFNf5++GvA9v2Cts5DuFBdD7Sfm2G9ddlP5.dss8fkrS6JX0lgAUU44 EbXPSWhLSvpsu9CbZWP4wRgrfqLu.5qfUGUWGsIj5s87FM.ERED7bau6Ypcu Hj4+5.empY.jPzCgAfHBVWgC6JAOqekO880EAy1KTW3k3MNwKDm3kjEzKk75 ZV9Eyn3mL+EXTWjeWIURVoQbvmNHXECY7dCuV7tY3Hs.GfG3NucfWykJlRTI 6MWkpsDJkpqBaKtPDKo32ivzF1QiL+oMckKJBwSCg3kDgz3UGgIoqOBQSCgn 6AgKBLhoKGLj7+b1M+GKTfs.wj3AZRKoFNKEdLdrkIygAVjspAMQglUjQ3GH yHaUAOa.el7sYcGYKBA2lEkLmsH1dFJkr.4pG18nv6w9wotv9cG6tl1GcW1O wI1OYAs+HoExYJNXZmVGO+zjQillLn8wFtfMGgPRGjKlO.rPHu9RylOnNdeX UWc7vtNYzcKYvWyoY7ZkPZVH7OCJo2XdQjkwMc2whRQ19pyyysZXjYNqkD0B Io2P6RMQrQSHmpoXKjzU51ERBcKIQctjv2RRotcwTjMKlvSSS5CQ02Zn41rw jjKslqZwqfZioaVI0hVA0NSMgrgf825ba.1frHrohfBuzZIDKxBwdu76biO8 +K.7o9fc -----------end_max5_patcher-----------
(if you remove the toggles under the [gate] it will just blink the LEDs once every time you click the buttons)
Forums > MaxMSP