How to limit bangs?

creatielivin's icon

Hi, I'm a New Media student at SUNY Purchase and am looking for some assistance with this project because none of the professors here know MAX at all.

I'm using light sensors to trigger video playback but the problem is it bangs it continuously so the video never actually gets going until the sensor has been covered again.

The sensors are giving off numbers like 300 when covered and 500 when exposed so I'm using IF objects like this:

if $i1 > 500 then set $i1

Also, if I want it to trigger only during a certain range of numbers can I just tack on a "< 600" after my "> 500"?

Any advice on how better to do this would be much appreciated! I've attached my patch so far if you want to take a look.

bryanteoh's icon

What exactly are you trying to do?

I see you're using the if/then range checker to trigger reading different movies into jit.qt.movie. You should use a bang message instead of sending your number to a bang. It'll be more efficient.

you can use the if/then object to sniff for a range of numbers, but you have to use '&&' to create multiple conditions. Your example would look like [if $i1 > 500 && < 600 then bang]. This expression will send out a bang every time it gets a number that is greater than 500 and less than 600.

if you only need it to bang once when the numbers come from outside the range to inside it, use [change] connected to a [> 500]. You can use [select 1] connected to those to send a single bang when the numbers are within range.

yair reshef's icon

hi and welcome, couple advices.

1. start small. isolate just one sensor. get it right and duplicate. build a
mechanism that changes movie only after it finish playing, see @loopreport
attribute of qt.movie, gate

2. refrain from using number boxes *as part* of the flow, connect object
directly and have numboxes connected separately, ready to be deleted when
you no longer need them, they take precious cycles. same for other gui obj
like, like bangs. they help debugging. see
https://cycling74.com/story/2007/2/5/142639/8843 for more advanced topics

3. working with sensors is can be frustrating, research this objects: slide,
change, onebang, gate

4. have a single metro (or better, qmetro) in a patch. get to know the order
of execution in max, if "right to left, top to bottom" is news, see
tutorials.

5. decide if your working with floats or ints.

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

On Thu, May 1, 2008 at 6:39 AM, bow wrote:

> Hi, I'm a New Media student at SUNY Purchase and am looking for some
> assistance with this project because none of the professors here know MAX at
> all.
>
> I'm using light sensors to trigger video playback but the problem is it
> bangs it continuously so the video never actually gets going until the
> sensor has been covered again.
>
> The sensors are giving off numbers like 300 when covered and 500 when
> exposed so I'm using IF objects like this:
>
> if $i1 > 500 then set $i1
>
> Also, if I want it to trigger only during a certain range of numbers can I
> just tack on a "< 600" after my "> 500"?
>
> Any advice on how better to do this would be much appreciated! I've
> attached my patch so far if you want to take a look.
>
>
>

creatielivin's icon

Your help is MUCH appreciated. I'm getting a better understanding of how to do this but a few questions which are probably pretty basic but:

- which inlets of [change] do I connect the [>500] and the [select 1] to?

Basically, I want to say if there is a change >500 then send one bang until until there is another change >500

- Yair, how do I translate the code you typed in the message into a patch?

bryanteoh's icon

look at the help files for the objects. The [>500] sends out a 1 if the argument is true, and a 0 if the argument is false. The middle outlet of the [change] object sends a one out if it detects a change from 0 to 1. [select 1] will send a bang if a 1 gets passed to it.

I have max 5 and am unsure how cross compatible patches are (still haven't read the updated documentation) but here's a picture of what it would look like.

creatielivin's icon

Thank you both for you help! You guys rule!

still can't get this to work though:

The split object works perfectly for "sniffing" different number ranges. So that's good!

The problem now again is with limiting the bang. The ">500___ change ___select 1" suggestion seems to work inconsistently.
I'm guessing the gate/trigger patch suggested might work better but I'm not sure how to tie that in with the patch.

Just so it's clear what I'm trying to do:
My sensors are embedded in a book and the patch is supposed to trigger different videos everytime a page is turned and a new sensor is exposed. The videos are projected onto the pages. So again, the main problem is that as you turn each new page a new sensor is exposed but the previous sensors are also exposed so those are continuously banging. This is why a range argument is needed

Eli's icon

I'll let you figure it out, but look at the [onebang] object, which lets out 1 bang at the beginning of a stream of bangs (going it one of its outlets), and only lets another one out when another bang goes into its other outlet.

It sounds like a very interesting project.

Can't open the file attached to the previous post, though.

Rob Ramirez's icon

here's my advice fwiw.

simplify for now. start off with two range values and two movies and get that working correctly. then add the rest.

you should really be using abstractions as well. a simple abstraction which enclosed a qt.movie and an [if then] object checking for a certain range.
the movie name and the range could be supplied as arguments to the abstraction. then utilize the onebang, as suggested.

but in any case, you won't get much help with a patch that's such a mess. strip it down to the simplest case possible which still illustrates what you're trying to do.
in doing so, you will probably come up with your solution on your own.

-rob