Forums > MaxMSP

Apply gain change to buffer IF signal level is over a certain amount

March 29, 2013 | 2:28 pm

Hi all,

I know i can change the gain inside a [buffer~] but
Is it possible to check the samples highest point (inside the buffer) and if it is over 0.80 then apply a gain change?
[info~] seems to only report MIDI velocity. I have a feeling [if/then/else] would do this, but not really sure on how to gather the info from [buffer~]

Thanks!


March 29, 2013 | 3:00 pm

See mxj buf.op.

With max you’ll get the maximum sample, there are also methods to change the gain.

p


March 29, 2013 | 3:33 pm

I tried with (~) and without but i get an error:
java.lang.NoClassDefFoundError: buf/op (wrong name: buf/Op)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at com.cycling74.max.MXJClassLoaderImpl.doLoadClass(MXJClassLoaderImpl.java:119)
at com.cycling74.max.MXJClassLoader.loadClazz(MXJClassLoader.java:88)
Could not load class ‘buf.op’

When you say " you’ll get the maximum sample" you mean the sample loaded gets Normalised to the maximum?


March 29, 2013 | 3:45 pm

ive tried to load buf.op in 6.1 some time ago ,and i could not do it for some reason . it was strange becasue absence of support for mxj wasnt listed inside release notes . just the ~mxj .


March 29, 2013 | 3:47 pm

Ooopps, I meant mxj buf.Op!


March 29, 2013 | 6:02 pm

Thanks Patrick, i found the helpfile but honestly its quite hard for me to understand. The gain portion i get but not the "max $1" message. How would i go about using that|? Would i have to take n2 output (393 0.XXXXX) then split it and use the second number and write an [if/then] function of some sort?
Could someone help me out a bit here? :/


March 29, 2013 | 11:55 pm

In the "max $1" message, the $1 is a placeholder for a variable. The message "max 1" will give you the maximum amplitude for channel 1 of the bufffer in question. You then query the buf.Op, and use the result to set your volume reduction. See attached….

M

– Pasted Max Patch, click to expand. –

March 30, 2013 | 5:08 pm

Thanks mattyo, I managed to come up with my own

– Pasted Max Patch, click to expand. –

April 1, 2013 | 2:58 pm

cool. A couple of notes for you:

– Pasted Max Patch, click to expand. –

April 1, 2013 | 4:16 pm

Nice one, thank you! All noted. Previously i thought of combining the normalize and gain, but never put it together…..Not sure why…
Thanks again!


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