Forums > MaxMSP

possible for bang to act like toggle

November 30, 2007 | 10:44 pm

Hi

This is a very , very basic question I almost feel stupid but I haven’t been able to answer it.

I want a bang to act like a toggle in a [>= ] situation.

To be more precise, when you have a toggle connected to a >= object, it displays that it is "on" when greater than and "off" when smaller than. Great, this is ok when you want to turn something on or off. But what I want is a bang once if greater than.

With select, it bangs once if matches. But as I said, I don’t want a specific number, I want a specific range.

thanks alots

phil


November 30, 2007 | 11:22 pm

Try the [if] like so:

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 93 279 32 196617 print;
#P newex 94 241 112 196617 if $i1 >= $i2 then bang;
#P slider 198 88 15 128 0 1;
#P slider 94 88 15 128 0 1;
#P connect 2 0 3 0;
#P connect 1 0 2 1;
#P connect 0 0 2 0;
#P window clipboard copycount 4;

On Nov 30, 2007, at 3:44 PM, phil wrote:

>
> Hi
>
> This is a very , very basic question I almost feel stupid but I
> haven’t been able to answer it.
>
> I want a bang to act like a toggle in a [>= ] situation.
>
> To be more precise, when you have a toggle connected to a >=
> object, it displays that it is "on" when greater than and "off"
> when smaller than. Great, this is ok when you want to turn
> something on or off. But what I want is a bang once if greater than.
>
> With select, it bangs once if matches. But as I said, I don’t want
> a specific number, I want a specific range.
>
>

—-
Steven M. Miller
Professor, Contemporary Music Program
College of Santa Fe

Home < http://pubweb.csf.edu/~smill>
SFIFEM <
http://sfifem.csf.edu>
Atrium Sound Space <
http://atrium.csf.edu>
OVOS <
http://pubweb.csf.edu/~smill/ovos.html>
CMP <
http://www.csf.edu/csf/academics/cmp/index.html>


November 30, 2007 | 11:40 pm

you could use onebang to make sure it only bangs once.


December 1, 2007 | 12:36 am

—————————————————-
But what I want is a bang once if greater than.
—————————————————-

You can use [change] between comparison and select objects:

#P button 75 232 75 0;
#P button 195 232 75 0;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 142 186 40 9109513 sel 0 1;
#P newex 142 160 40 9109513 change;
#P number 142 85 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 142 119 31 9109513 >= 10;
#P connect 3 1 4 0;
#P connect 3 0 5 0;
#P connect 2 0 3 0;
#P connect 0 0 2 0;
#P connect 1 0 0 0;
#P window clipboard copycount 6;

Best.


December 1, 2007 | 12:36 am

Quote: philippehughes@hotmail.com wrote on Fri, 30 November 2007 14:44
—————————————————-
> Hi
>
> This is a very , very basic question I almost feel stupid but I haven’t been able to answer it.
>
> I want a bang to act like a toggle in a [>= ] situation.
>
>

I tend to have comparisons followed by sel 1 or sel 0 very frequently. Sometimes I throw in change. ASCII style:

[>= 3.14]
|
|
[change] (optional)
|
|
[sel 1]

That gives me a bang when the input passes above a certain threshold.

mz


December 1, 2007 | 4:26 am

At 3:44 PM -0700 11/30/07, phil wrote:
>With select, it bangs once if matches. But as I said, I don’t want a specific number, I want a specific range.

It sounds like you want something like a window comparator. Try this:

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 171 195 40 196617 change;
#P comment 204 244 75 196617 Exited Window;
#P comment 93 244 81 196617 Entered Window;
#P button 188 242 15 0;
#P button 171 242 15 0;
#P message 202 143 14 196617 0;
#P toggle 171 170 15 0;
#P message 148 143 14 196617 1;
#P newex 171 215 44 196617 sel 1 0;
#P comment 215 92 66 196617 Window Low;
#P comment 215 69 66 196617 Window High;
#P number 176 68 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 175 91 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont "Sans Serif" 12.;
#P number 113 79 35 12 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont "Sans Serif" 9.;
#P newex 148 122 64 196617 split;
#P window setfont "Sans Serif" 12.;
#P window linecount 2;
#P comment 60 71 55 196620 Number to test;
#P connect 7 0 11 0;
#P connect 7 1 12 0;
#P connect 15 0 7 0;
#P connect 9 0 15 0;
#P connect 1 0 8 0;
#P connect 10 0 9 0;
#P connect 1 1 10 0;
#P connect 8 0 9 0;
#P fasten 4 0 1 2 181 86 171 86 171 112 207 112;
#P connect 3 0 1 1;
#P connect 2 0 1 0;
#P window clipboard copycount 16;


Chris Muir | "There are many futures and only one status quo.
cbm@well.com | This is why conservatives mostly agree,
http://www.xfade.com | and radicals always argue." – Brian Eno


December 1, 2007 | 4:12 pm

try these, remember things like counter and comparisons don’t work like most beginners think, a bang is any change of state, so sending an led a 0 is still a bang. Comparisons send out a 1 for ever number that’s ‘true’ and a 0 for ever number that’s ‘false’. But this means it’ll always bang even if you don’t expect it to.

#P button 310 238 15 0;
#P button 253 233 15 0;
#P window setfont "Sans Serif" 9.;
#P number 236 156 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 334 157 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 287 156 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 254 193 54 196617 split 1 10;
#P button 168 242 15 0;
#P button 112 242 15 0;
#P newex 119 199 46 196617 TogEdge;
#P number 151 124 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 101 125 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 123 171 27 196617 >=;
#P connect 3 0 4 0;
#P connect 0 0 3 0;
#P connect 1 0 0 0;
#P connect 2 0 0 1;
#P connect 3 1 5 0;
#P connect 6 0 10 0;
#P connect 9 0 6 0;
#P connect 7 0 6 1;
#P connect 8 0 6 2;
#P connect 6 1 11 0;
#P window clipboard copycount 12;


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