Gating a midi control data stream?
Please forgive me if this is an obvious question, I’m fairly new to Max.
I have a stream of data coming from an arduino and into MAX, then triggering scenes in ableton. NB I’m not using M4L, I’m just sending ctrlout messages as either 127 or 0 to launch different scenes in Ableton depending on what the sensor value is. This is working.
The problem is the scenes keep re-launching every half-second or so, because they are getting a constant stream of midi cntrl messages. I need some way to let either a single message through or just gate the stream so it sends 127 for a say 200ms and then back to 0. This will be enough to launch the scene and not then to re-trigger it.
By the way I have tried onebang and gate but without much success, and i think its because of my newbie-ness. If anyone has any objects or advice I’d be very grateful. Will post my patch if that would help.
Thanks for your time
Yes, posting the patch would help to understand what exactly you’re doing.
One object that may be useful for you is [change], which only forwards a number passed into it, if it has changed since the last number was received.
If you want a gate that only lets a single message/number through, after which it closes until you tell it to accept another value, you can do something like this:
----------begin_max5_patcher---------- 351.3ocyTEsSCBCE84xWQSeFMsU1B5a9cXVLE3JqFncg1Emtr+coW.2T2VvY xBuTRO2K264bZucaDgkY2.NF8A5STBYaDgfPA.R+dBqVsIuR4vzX0fyoJAVb WLOrwi3hAjUJe9Rso74FH22UYgH4VdLUvuG+jNrRWz+Ol00ZSE3wVH6A0EXg sYudiLYn5uXMdipFvPO1nUUr80vt1OTDQOZGj+8UPGUXruZZnTN8GX.g7Vd. cWTTXI9eZF7yXFoyP4eWxk5ExooWz1yLnYD2BliFvLdXUxOkxEGQ47+pxkmR 4ZimESYYJS4U1DRDciByuPSPjN8MA3sVl9qghRkGFw0itAij4m2YNxfg3JOX f4vpzle9.JJt.928HmccS9PGFdUitWeEfyqMJu1ZNHofpNHok5hB.iy6Qp0E qrsGk8jft3nmXilSxoGmDigSxoHm3WWNkN1yNwExo1M6h9jyt9cB -----------end_max5_patcher-----------
Click on the  message to open the gate. Then you can send one value through the gate, after which it automatically closes again, until you click on  again.
In other words: This is identical to the behaviour of [oneclick], except that it passes messages instead of bangs.
(And of course the opening of this gate can be easily automated as well.)
If you just want to limit the speed at which messages get passed through, take a look at the [speedlim] object. [speedlim 1000], for example, would only let through new messages once per second.
Many thanks for the tips – I’ll try these out.