Forums > Jitter

How to limit bangs?

May 1, 2008 | 3:39 am

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.


May 1, 2008 | 6:33 am

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.


May 1, 2008 | 8:09 am

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
http://www.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.

#P window setfont "Sans Serif" 9.;
#P window linecount 3;
#P comment 404 117 100 9109513 < using elseif is also possible.;
#P window linecount 1;
#P newex 154 355 19 9109513 t 1;
#B color 5;
#P newex 23 63 27 9109513 t b b;
#P toggle 23 19 15 0;
#P newex 23 40 50 9109513 qmetro 33;
#P user jit.pwindow 37 374 82 62 0 1 0 0 1 0;
#P newex 38 288 42 9109513 gate 1 1;
#B color 5;
#P newex 38 257 42 9109513 t 0 l;
#B color 5;
#P newex 154 334 74 9109513 route loopnotify;
#B color 5;
#P newex 343 127 53 9109513 clip 0 1500;
#P button 439 190 15 0;
#P button 383 191 15 0;
#P button 343 170 15 0;
#P number 343 110 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 383 169 66 9109513 split 500 1000;
#P newex 343 148 51 9109513 split 0 500;
#P number 108 132 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P button 181 204 15 0;
#P message 169 233 78 9109513 522;
#P newex 169 174 121 9109513 if $i1 > 500 then set $i1;
#P button 48 201 15 0;
#P newex 38 173 121 9109513 if $i1 > 500 then set $i1;
#P message 38 233 73 9109513 522;
#P newex 38 311 189 9109513 jit.qt.movie 720 480 @loopreport 1 @loop 0;
#B color 5;
#P comment 144 134 100 9109513 master number box;
#P window linecount 3;
#P comment 247 341 100 9109513 < < wait for end of file to open gate for
other read messages;
#P connect 4 0 3 0;
#P connect 4 0 5 0;
#P connect 17 0 24 0;
#P fasten 23 0 2 0 28 309 43 309;
#P connect 2 0 20 0;
#P connect 19 0 2 0;
#P fasten 2 1 17 0 222 332 159 332;
#P fasten 24 0 19 0 159 377 233 377 233 283 43 283;
#P connect 18 0 19 0;
#P fasten 18 1 19 1 75 282 75 282;
#P connect 6 0 7 0;
#P connect 6 0 8 0;
#P connect 9 0 4 0;
#P connect 9 0 6 0;
#P connect 21 0 23 0;
#P connect 22 0 21 0;
#P fasten 7 0 18 0 174 254 43 254;
#P fasten 3 0 18 0 43 254 43 254;
#P connect 16 0 10 0;
#P connect 12 0 16 0;
#P connect 10 1 11 0;
#P connect 11 0 14 0;
#P connect 11 1 15 0;
#P connect 10 0 13 0;
#P window clipboard copycount 26;

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.
>
>
>


May 1, 2008 | 9:34 pm

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?


May 1, 2008 | 10:17 pm

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.


May 2, 2008 | 3:55 am

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
May 2, 2008 | 4:16 am

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.


May 2, 2008 | 5:33 am

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


Viewing 8 posts - 1 through 8 (of 8 total)