## Calculating /compensating relative gains of 2 signals

Sep 1, 2006 at 4:49pm

# Calculating /compensating relative gains of 2 signals

I am trying to take 2 signals of different amplitudes, calculate the level difference between them then apply the appropriate amount of gain to one of them so that they are both exactly the same gain (typically, though not essentially, the gain of one of the signals). Does anyone have any good approaches for doing this?

#27431
Sep 1, 2006 at 4:51pm

define “gain”.

#83009
Sep 1, 2006 at 5:24pm

Defining gain properly would take a long time!
Yes, I was a little vague, but I am talking about a numerical, instantanious measurement of a signal’s amplitude, either linear or logarithmic. Typically the output from peakamp~ would be one way of looking at it, for instance, if I had 2 audio signals, both feeding their own peakamp~ objects, how can I automatically manipulate one of the signals so that both peakamp~s subsequently displayed the same number?

#83010
Sep 2, 2006 at 1:41am

compare them … by diving one from the other or by divigin both from 1 float … a fiktive third signal … then you
know the difference between the two … so you know what
to add to A to make its peak (or power?) envelope like B …
the gainslider object with its ramp time should be the
appropiate opposite of peakamp … maybe …

#83011
Sep 2, 2006 at 2:54am

It sounds like you might want to use a side-chained
compressor/noise-gate such as omx.comp~.

Peter McCulloch

#83012
Sep 2, 2006 at 10:47am

Justin Paterson wrote:
> I am trying to take 2 signals of different amplitudes, calculate the
> level difference between them then apply the appropriate amount of
> gain to one of them so that they are both exactly the same gain

Depends on the signal if “exactly” makes sense. If you have the output
of two oscillators, it might mean something, if you take two channels of
a classical recording you probably don’t want them to be exactly the
same always… ;-)

> (typically, though not essentially, the gain of one of the signals).
> Does anyone have any good approaches for doing this?

Look into envelope following and averaging, as you have to define how

Stefan

Stefan Tiedje————x——-
–_____———–|————–
–(_|_ —-|—–|—–()——-
– _|_)—-|—–()————–
———-()——–www.ccmix.com

#83013
Sep 2, 2006 at 1:46pm

Thanks for the help guys. I have been trying everyone’s ideas along with what seems to me the most obvious which is using the normalize~object, but I cannot get anything to work correctly. I am only going for peak values at the moment. I think a lot of it has to do with my relative newness to Max, and I am under time pressure which make thorough study around the immediate problem difficult. Would anyone be so kind as to be a little more explicit in their advice for a brain-fried newbie?

#83014
Sep 2, 2006 at 1:53pm

Oh, Stefan- I should add that my scenario in the short term is closer to an oscillator than a classical recording. I am in fact looping a short (400ms) section of audio,

#83015
Sep 2, 2006 at 2:33pm

Here is a picture of a little problem. The red signal is coming from one buffer and the 2 yellows are both coming from another. Each buffer contains successive handclaps. The 2 signals are named higher and lower, so that when it functions correctly, ‘normalized lower’ is the same as ‘actual higher’. It is currently automatically reporting every 525ms, not using the bang from the top left.
It works perfectly on the first handclap in the sequence, but if I then choose a different handclap, it does not report correctly. Also, if I mess with the individual volumes of the working handclap, it will work for a while and then perhaps not work.
What is causing this inconsistency/inaccuracy?

#83016
Sep 2, 2006 at 2:59pm

Check out tl.balance~ from the tl.objects:

Best,
Trond

Justin Paterson wrote:
> I am trying to take 2 signals of different amplitudes, calculate the level difference between them then apply the appropriate amount of gain to one of them so that they are both exactly the same gain (typically, though not essentially, the gain of one of the signals). Does anyone have any good approaches for doing this?
>

#83017
Sep 2, 2006 at 4:44pm

Hey Trond!
What a great collection of objects- Well done!
At first glance, the help file for tl.balance~ does not seem to work, but the object itself is pretty self-explanatory. Tweaking its refresh rate might prove interesting…
I will investigate and let you know how I get on.
Thanks very much.

#83018
Sep 2, 2006 at 6:11pm

My apologies for the off-topic nature of this post to the list, but
I’m getting pretty desperate and I hope that some of the sages here

Since upgrading the macs in our lab to OS 10.4.7 from 10.3.9 I can no
longer get them to recognize the Tascam US-428′s. I get not even a
flicker on the 428′s usb indicators and neither the US-428 Manager
app or Audio MIDI Setup recognize the units.

I have tried using the US-428 drivers v3.2.3 (which is supposed to be
Tiger compatible) and the new UB v3.4. I have tried first using the
supplied deinstaller before installing, I have tried manually
deinstalling all the components before installing (as recommended by
Tascam tech support, after several hours on hold), I have tried
manually installing all the components. Still no luck.

All the Macs are 466MHz G4s running OS 10.4.7, with iTunes 6.0.5, Max/
MSP 4.6.1, Pluggo 3.5.4, Digital Performer 5.1, Finale 2006d,
Sibelius 4. There are no other audio drivers, or any other
miscellaneous usb drivers installed.

Any ideas? As I said, I’m getting pretty desperate as I have classes
beginning on Tuesday which rely on this machines (I know, I know, I
should never have done an OS upgrade with only a week of shake-down
time).

Thanks for any help you might have. Feel free to contact me off-list
if you want to keep down the OT bandwidth.

John Burrow/Technical Director, Music Dept.
Cornish College of the Arts
206-726-5087
jburrow@cornish.edu
noisyjB@comcast.net

#83019
Sep 3, 2006 at 6:06pm

Have you tried using the OMX~ objects? They were designed for this problem.

KMc

Justin Paterson wrote:
Here is a picture of a little problem. The red signal is coming from one buffer and the 2 yellows are both coming from another. Each buffer contains successive handclaps. The 2 signals are named higher and lower, so that when it functions correctly, ‘normalized lower’ is the same as ‘actual higher’. It is currently automatically reporting every 525ms, not using the bang from the top left.
It works perfectly on the first handclap in the sequence, but if I then choose a different handclap, it does not report correctly. Also, if I mess with the individual volumes of the working handclap, it will work for a while and then perhaps not work.
What is causing this inconsistency/inaccuracy?

Keith McMillen
BEAM Foundation
http://www.beamfoundation.org/
510.502.5310

#83020
Sep 5, 2006 at 10:27am

Basically, the tl.balance works perfectly and effortlessly. Big thanks, Trond!
I guess the only down side is that I did not get to learn anything from designing it myself, but as I said, I am short of time on this one and will come back to it all later. Thanks to everyone who helped.

#83021

You must be logged in to reply to this topic.