Forums > MaxMSP

resetting toggle

March 28, 2008 | 7:59 pm

Hi, for some reason I cannot work out how to do this.

I have a bang being sent to a toggle turning it on and off. (e.g. 1 bang is on, and another bang is off). But I want the toggle to automatically turned off 10 milliseconds after it is turned on(e.g before the next bang has time to occur.) Therefore the incoming bang should only really be used to turn the toggle on.

I worked out one way to do it using metro and counter, but I require 5 versions of this mechanism to control 5 different toggles separately. After pasting multiple versions max msp crashed!

Please help!


March 28, 2008 | 8:55 pm

Not sure if this is what you’re getting at, but why don’t you just use your bang to send a 1 to the toggle – that way it can only ever turn it on.

Eg:

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 152 190 14 196617 0;
#P newex 152 168 49 196617 delay 10;
#P message 133 168 14 196617 1;
#P button 133 144 15 0;
#P toggle 133 219 15 0;
#P connect 2 0 0 0;
#P connect 4 0 0 0;
#P connect 3 0 4 0;
#P connect 1 0 2 0;
#P connect 1 0 3 0;
#P window clipboard copycount 5;


March 28, 2008 | 9:05 pm

…And in fact you can accomplish exactly the same thing as the example I suggested without the 1 and 0 messages:

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 340 174 49 196617 delay 10;
#P button 321 150 15 0;
#P toggle 321 225 15 0;
#P connect 2 0 0 0;
#P connect 1 0 0 0;
#P connect 1 0 2 0;
#P window clipboard copycount 3;


March 28, 2008 | 9:32 pm

for some reason when a bang is sent to the above patches the toggle never seems to be turned on… I’m baffled!


March 28, 2008 | 9:47 pm

haha forget the last post.. just me being slow!

Thanks Daniel!


March 28, 2008 | 10:12 pm

On Mar 28, 2008, at 2:32 PM, Adam wrote:
> for some reason when a bang is sent to the above patches the toggle
> never seems to be turned on… I’m baffled!

10ms is too short to guarantee that that it will ever be drawn on
screen. Hang a print off of the toggle to see that it is actually
working properly.

Chris Muir
cbm@well.com

http://www.xfade.com


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