Forums > MaxMSP

increment and decrement automatically?

November 13, 2006 | 5:38 pm

this seems like it should be easy, but i don’t see an answer anywhere. i need to increment and decrement sliders automatically rather than using a mouse click to control it. the objects i’m working on need to monitor their own audio signal level and decrement the level when the signal clips, and then gradually increment the signal level until it clips again. IncDec works to increment and decrement, but is only activated by a user’s mouse clicks. how can i use a bang or a message to increment and decrement a value? thanks!


November 13, 2006 | 5:55 pm

it sounds like you want to normalize the sound input level?

take a look at the MSP normalize~ object.

If ive misunderstood, you could use counter, and change the
direction. Counter with no arguments will just start counting for
each bang.

v a d e //

http://www.vade.info
abstrakt.vade.info

On Nov 13, 2006, at 12:38 PM, collin wrote:

>
> this seems like it should be easy, but i don’t see an answer
> anywhere. i need to increment and decrement sliders automatically
> rather than using a mouse click to control it. the objects i’m
> working on need to monitor their own audio signal level and
> decrement the level when the signal clips, and then gradually
> increment the signal level until it clips again. IncDec works to
> increment and decrement, but is only activated by a user’s mouse
> clicks. how can i use a bang or a message to increment and
> decrement a value? thanks!


November 13, 2006 | 5:57 pm

Accum ?

On 13/11/06 17:38, "collin" wrote:

>
> this seems like it should be easy, but i don’t see an answer anywhere. i need
> to increment and decrement sliders automatically rather than using a mouse
> click to control it. the objects i’m working on need to monitor their own
> audio signal level and decrement the level when the signal clips, and then
> gradually increment the signal level until it clips again. IncDec works to
> increment and decrement, but is only activated by a user’s mouse clicks. how
> can i use a bang or a message to increment and decrement a value? thanks!


November 13, 2006 | 6:34 pm

yeah, i’m not sure normalize~ will work because what needs to be adjusted is often feedback or input levels, not necessarily just output. but i’ll give that one a try. the [counter] idea is a good one and i think it may be the one i end up using, counting up at very small intervals and when the signal clips, dropping down a bit more quickly.
thanks for the help.


November 13, 2006 | 6:36 pm

hmmm, accum also looks promising. i’ll have to look more into it (i’m still a bit of a novice and don’t know some of the objects very well) and try all of the above suggestions out and see which works best for this application.
thanks roger.


November 13, 2006 | 6:59 pm

Collin here is an easy way to decrement – increment, adjust to your own needs…

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P comment 207 271 100 196617 decrement;
#P button 203 91 15 0;
#P number 209 242 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 234 173 27 196617 – 1;
#P newex 222 141 27 196617 i;
#P button 91 91 15 0;
#P number 97 242 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 122 173 27 196617 + 1;
#P newex 110 141 27 196617 i;
#P comment 61 271 100 196617 increment;
#P connect 6 0 7 0;
#P fasten 6 0 5 1 239 202 279 202 279 121 244 121;
#P connect 2 0 3 0;
#P fasten 2 0 1 1 127 204 167 204 167 123 132 123;
#P connect 5 0 6 0;
#P connect 8 0 5 0;
#P connect 4 0 1 0;
#P connect 1 0 2 0;
#P window clipboard copycount 10;


November 13, 2006 | 8:39 pm

Don’t forget you can send "inc" and "dec" messages to the inc/dec object (which is then connected to the number box or slider, and the number / slider connected back to it). This might give advantages over counter, not sure. Using a number box with appropriate limits seems the best route.

Here’s a sample patch with some ideas if you’re still looking around. I think the first example is the most promising for your application, but I’m not sure.

It’s a bit more of an issue than it first seemed because of the way the counters, number boxes, and inc/dec objects work.

–CJ

—————–

max v2;
#N vpatcher 15 55 1109 655;
#P window setfont "Sans Serif" 12.;
#P window linecount 1;
#P message 344 235 42 9109516 set $1;
#P number 316 102 35 12 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 315 42 28 9109516 dec;
#P message 263 41 24 9109516 inc;
#P user incdec 294 67 15 15 0 0;
#P user uslider 306 136 18 128 128 1 0 0;
#P window linecount 4;
#P comment 281 295 228 9109516 number box with no limits. If you change the slider with the mouse , num box will update. However , inc/dec remembers where it was before.;
#P window linecount 3;
#P comment 781 167 139 9109516 counter with args (wraps values , probably not what you want);
#P comment 593 171 139 9109516 counter with no args (goes "past" number box limits , in either direction);
#P number 797 131 35 12 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P message 832 63 28 9109516 dec;
#P message 780 62 24 9109516 inc;
#N counter 5 10;
#X flags 0 0;
#P newobj 790 94 76 9109516 counter 5 10;
#P number 603 129 35 12 5 10 3 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 638 56 28 9109516 dec;
#P message 586 55 24 9109516 inc;
#N counter;
#X flags 0 0;
#P newobj 596 87 66 9109516 counter;
#P number 146 103 35 12 5 10 3 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 145 43 28 9109516 dec;
#P message 93 42 24 9109516 inc;
#P user incdec 124 68 15 15 0 0;
#P user uslider 136 137 18 128 128 1 0 0;
#P window linecount 4;
#P comment 99 302 136 9109516 number box with min / max limits. This looks the most promising I think.;
#P connect 5 0 2 0;
#P connect 3 0 2 0;
#P connect 4 0 2 0;
#P connect 5 0 1 0;
#P connect 2 0 5 0;
#P connect 21 0 18 0;
#P connect 20 0 18 0;
#P connect 19 0 18 0;
#P connect 21 0 17 0;
#P connect 22 0 21 0;
#P connect 18 0 21 0;
#P connect 17 0 22 0;
#P connect 8 0 6 0;
#P connect 7 0 6 0;
#P connect 6 0 9 0;
#P connect 12 0 10 0;
#P connect 11 0 10 0;
#P connect 10 0 13 0;
#P pop;


November 13, 2006 | 9:02 pm

Hi Collin,

The linc object from the Lobjects is also very flexible. I use it for
most of these things

Falk

Am 13.11.2006 um 18:38 schrieb collin:

>
> this seems like it should be easy, but i don’t see an answer anywhere.
> i need to increment and decrement sliders automatically rather than
> using a mouse click to control it. the objects i’m working on need to
> monitor their own audio signal level and decrement the level when the
> signal clips, and then gradually increment the signal level until it
> clips again. IncDec works to increment and decrement, but is only
> activated by a user’s mouse clicks. how can i use a bang or a message
> to increment and decrement a value? thanks!
>
>


November 13, 2006 | 9:06 pm

thanks for the patch. my version of max (i’m running v. 4.3.2 on windows xp) doesn’t let me send inc and dec messages to IncDec. when i click on the messages you attached to IncDec it tells me "incded doesn’t understand "dec" " and the same for inc. but the counter works well and receives those messages. maybe newer versions of max let IncDec receive inc and dec messages rather than just mouse clicks. when i have the $ (i’m a poor grad student) i’ll upgrade. or if there’s some other reason it wouldn’t work, i’d love to know.


November 13, 2006 | 9:08 pm


November 13, 2006 | 9:10 pm

thanks for the reply karrrlo.
for some reason, i can’t get your patch to open when i save the text. Max just opens a window that shows the text. i don’t really know much about the conversion from patch to text and vice versa; i normally just copy the text into notepad and save it as a .pat file. if you upload a patch, i’d love to see it. or if there’s something i’m doing wrong, let me know.
(by the way, are there instructions somewhere about how to make patches appear as text to be posted to the forum? i still haven’t figured it out.)


November 13, 2006 | 11:49 pm

Hi Collin, just copy the "text" and in max select : file>new from clipboard and a nice little miracle will happen ;)

best

Quote: collin wrote on Mon, 13 November 2006 13:10
—————————————————-
> thanks for the reply karrrlo.
> for some reason, i can’t get your patch to open when i save the text. Max just opens a window that shows the text. i don’t really know much about the conversion from patch to text and vice versa; i normally just copy the text into notepad and save it as a .pat file. if you upload a patch, i’d love to see it. or if there’s something i’m doing wrong, let me know.
> (by the way, are there instructions somewhere about how to make patches appear as text to be posted to the forum? i still haven’t figured it out.)
—————————————————-


November 14, 2006 | 12:26 am

Quote: collin wrote on Mon, 13 November 2006 10:38
—————————————————-
> this seems like it should be easy, but i don’t see an answer anywhere. i need to increment and decrement sliders automatically rather than using a mouse click to control it. the objects i’m working on need to monitor their own audio signal level and decrement the level when the signal clips, and then gradually increment the signal level until it clips again. IncDec works to increment and decrement, but is only activated by a user’s mouse clicks. how can i use a bang or a message to increment and decrement a value? thanks!
—————————————————-

you should not use messages for this at all, but
a signal sent to a [*~] object.

you do not even need a [line~] for interpolation
when your control sognal is (probably) coming from
[rampsmooth~] or [avg~] or similar.

-110


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