Forums > MaxMSP

mixing four audio signals into one

May 30, 2008 | 8:33 pm

Hello list – a little problem for you to mull over…

What is the best way of mixing four input signals to one output signal?

By how much should the input signals be attenuated in order to achieve the same theoretical output level as any one input level? A pan control would sum two signals reduced by 3dB into one output signal, I think.

Is there a rule of thumb for attenuating input signals when mixing, say, three, four, or any number of signals?

I attach a patch to illustrate…

Thanks!

Jonathan.

max v2;
#N vpatcher 352 122 722 369;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 67 148 40 196617 dac~ 1;
#P newex 67 123 48 196617 +~;
#P newex 105 97 29 196617 +~;
#P newex 67 97 29 196617 +~;
#P newex 67 63 67 196617 adc~ 1 2 3 4;
#P comment 129 83 179 196617 < - should input signals be attenuated?;
#P connect 1 0 2 0;
#P connect 2 0 4 0;
#P connect 4 0 5 0;
#P connect 1 1 2 1;
#P connect 1 2 3 0;
#P connect 3 0 4 1;
#P connect 1 3 3 1;
#P pop;


May 30, 2008 | 10:58 pm

> What is the best way of mixing four input signals to one output
> signal?
>
> By how much should the input signals be attenuated in order to
> achieve the same theoretical output level as any one input level?

It depends, obviously, on what is in the signals.

If one of your signals is at zero amplitude, then you don’t have to
reduce it much. Look into compressors…they will achieve your goal.
If you signals are mostly the same…you can keep them all at 25% and
hope that works.

> A pan control would sum two signals reduced by 3dB into one output
> signal, I think.

No, a pan control takes one signal and pans it across two (or 36,689)
channels. Completely the opposite.

bt

barry threw
Media Art and Technology

San Francisco, CA
Work: 857-544-3967
Email: bthrew (at) gmail (dot) com
Web: http://www.barrythrew.com



kjg
May 31, 2008 | 8:34 pm

>
> It depends, obviously, on what is in the signals.
>
> If one of your signals is at zero amplitude, then you don’t have to
> reduce it much. Look into compressors…they will achieve your goal.
> If you signals are mostly the same…you can keep them all at 25% and
> hope that works.
>

I don’t think a compressor is the best way to deal with issues of gain structure. It is for dealing with issue of dynamic range, or for creating any of a range of specific sound effects.

I suggest you use your ears and maybe a signal level meter.
Start with summing the signals. If this results in clipping, maybe the signals were a bit too hot in the first place? Leave some "headroom", especially with live and/or very dynamic sources.

To not leave you without any numbers..
For strongly correlated signals: reduce the mixed signal by 6dB to be on the safe side. The down side is that your mix will probably sound less loud then the sources do in isolation. Which is is most _musical_ situations a bit strange, right?

For anything else you could reduce it by 3dB, but then again you wouldn’t even have to think about it, if you made sure you had some headroom in the first place. You could just turn it down a little when your ears tell you it is getting a bit too loud.

Read a little on (proper) gain structure, headroom, correlated/uncorrelated signals and related topics you run into.
Or don’t. But do yourself one favor: set your levels in db and not in linear amplitude. atodb and dbtoa are your friends.

From there, just use your ears.

regards,
kjg



kjg
May 31, 2008 | 8:45 pm

Quote: jg1983 wrote on Fri, 30 May 2008 22:33

>
> I attach a patch to illustrate…
>

I forgot to look at your patch, sorry. In this case I would say that your signals need no attenuation in max. You would need to set proper input gains, that’s all. Set them in such a way that you get a healthy level, but without even getting close to clipping when the sources "play" loudly.


May 31, 2008 | 10:06 pm

On May 31, 2008, at 1:34 PM, Klaas-Jan Govaart wrote:

> I don’t think a compressor is the best way to deal with issues of
> gain structure.

They sure aren’t the best way to herd sheep, but I think with issues
of gain structure they are designed pretty well for the task.

I didn’t look at the patch either, but I would probably try a
compressor on each channel keyed off the combined signal. You could
use a final limiter for make up gain if you wanted. This would pretty
effectively keep all gains in line without having to guess.

bt


May 31, 2008 | 10:42 pm

Thanks, Kyg and Barry.

Normally, as you suggested Kyg, I would just set appropriate levels on the mixer before they reach max. I was wondering if there was a theoretically correct method of doing this.

Sorry to be pedantic, but if the four input signals were, for example, sine waves at 0dB, they would obviously clip when summed together. I was wondering by how much must each be attenuated in order to avoid the clipping when summed.

As a guess, I attach the following patch. Any thoughts?

max v2;
#N vpatcher 790 543 1404 844;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P comment 362 119 19 196617 dB;
#P user ezdac~ 309 209 353 242 0;
#P flonum 169 234 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 169 211 70 196617 snapshot~ 50;
#P newex 106 234 40 196617 dac~ 1;
#P newex 106 175 27 196617 +~;
#P newex 168 132 27 196617 +~;
#P newex 52 132 27 196617 +~;
#P newex 212 97 47 196617 *~ 0.25;
#P newex 212 64 61 196617 cycle~ 440;
#P newex 149 97 47 196617 *~ 0.25;
#P newex 149 64 61 196617 cycle~ 330;
#P newex 86 97 47 196617 *~ 0.25;
#P newex 86 64 61 196617 cycle~ 220;
#P newex 23 97 47 196617 *~ 0.25;
#P newex 23 64 61 196617 cycle~ 110;
#P newex 319 40 75 196617 loadmess 0.25;
#P flonum 319 119 39 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 319 71 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 319 95 34 196617 atodb;
#P window linecount 2;
#P comment 365 71 217 196617 < -- if max is 0 , then each of the four signals should be a quarter of the amplitude == -12dB;
#P connect 5 0 6 0;
#P connect 6 0 13 0;
#P connect 8 0 13 1;
#P connect 7 0 8 0;
#P connect 13 0 15 0;
#P connect 15 0 16 0;
#P connect 14 0 15 1;
#P connect 9 0 10 0;
#P connect 10 0 14 0;
#P connect 15 0 17 0;
#P connect 17 0 18 0;
#P connect 12 0 14 1;
#P connect 11 0 12 0;
#P connect 4 0 2 0;
#P connect 2 0 1 0;
#P connect 1 0 3 0;
#P pop;



kjg
June 1, 2008 | 12:37 am

Quote: jg1983 wrote on Sun, 01 June 2008 00:42
—————————————————-
> Thanks, Kyg and Barry.
>
> Normally, as you suggested Kyg, I would just set appropriate levels on the mixer before they reach max. I was wondering if there was a theoretically correct method of doing this.
>
> Sorry to be pedantic, but if the four input signals were, for example, sine waves at 0dB, they would obviously clip when summed together. I was wondering by how much must each be attenuated in order to avoid the clipping when summed.

It depends on their phase. Take two cycles. Drive them from the same phasor. So, these are two signals, a 100% correlated. Sum them. This will add 6 dB. You might as well run 1 cycle and add 6 db then, right?

Now give both a different frequency. They start canceling out some of the time..

So like I already said in an earlier post, to be on the safe side, you could subtract 6dB of the sum with real life signals, in case they might momentarily be 100% correlated…

regards,
kjg


June 1, 2008 | 12:52 am

I’m sure you could design a scalable algorithm for this. How do DAWs do it?

On Sat, May 31, 2008 at 8:37 PM, Klaas-Jan Govaart wrote:
>
> Quote: jg1983 wrote on Sun, 01 June 2008 00:42
> —————————————————-
>> Thanks, Kyg and Barry.
>>
>> Normally, as you suggested Kyg, I would just set appropriate levels on the mixer before they reach max. I was wondering if there was a theoretically correct method of doing this.
>>
>> Sorry to be pedantic, but if the four input signals were, for example, sine waves at 0dB, they would obviously clip when summed together. I was wondering by how much must each be attenuated in order to avoid the clipping when summed.
>
> It depends on their phase. Take two cycles. Drive them from the same phasor. So, these are two signals, a 100% correlated. Sum them. This will add 6 dB. You might as well run 1 cycle and add 6 db then, right?
>
> Now give both a different frequency. They start canceling out some of the time..
>
> So like I already said in an earlier post, to be on the safe side, you could subtract 6dB of the sum with real life signals, in case they might momentarily be 100% correlated…
>
> regards,
> kjg
>
>


Morgan Sutherland



kjg
June 1, 2008 | 1:10 am

Quote: morgan wrote on Sun, 01 June 2008 02:52
—————————————————-
> I’m sure you could design a scalable algorithm for this. How do DAWs do it?
>

Design a scalable algorithm for what exactly?? Matching signal levels?

The math is not that hard for simple waveforms in phase.. For complex waveforms the scaling factor would be different from moment to moment. I rather not have a DAW scale all my signals from moment to moment to make sure I end up with a signal of constant amplitude…

Or what do you mean?

regards,
kjg


June 1, 2008 | 1:35 am

Doesn’t a DAW have to compensate for the fact that adding signals on
top of each other increases gain? I’m not talking about dynamic
adjustment, just some logic that scales things so that you don’t have
to think about it.

On Sat, May 31, 2008 at 9:10 PM, Klaas-Jan Govaart wrote:
>
> Quote: morgan wrote on Sun, 01 June 2008 02:52
> —————————————————-
>> I’m sure you could design a scalable algorithm for this. How do DAWs do it?
>>
>
> Design a scalable algorithm for what exactly?? Matching signal levels?
>
> The math is not that hard for simple waveforms.. For complex waveforms the scaling factor would be different from moment to moment. I rather not have a DAW scale all my signals from moment to moment to make sure I end up with a signal of constant amplitude…
>
> Or what do you mean?
>
> regards,
> kjg
>


Morgan Sutherland



kjg
June 1, 2008 | 2:05 am

Quote: morgan wrote on Sun, 01 June 2008 03:35
—————————————————-
> Doesn’t a DAW have to compensate for the fact that adding signals on
> top of each other increases gain? I’m not talking about dynamic
> adjustment, just some logic that scales things so that you don’t have
> to think about it.

If I add two signals in a DAW with both faders at 0dB I want them to just be summed. Depending on their correlation I will end up with a signal with either a higher or a lower level. I might then compensate for that using the faders depending on what I want. My DAW can not know what I want. It can’t mix for me. And personally I wouldn’t be interested in an algorithm approximating the ‘right balance’ between a bunch of signals. Not statically (I don’t even like the automatic gain make-up in some compressors – those algorithms don’t take into account perceived loudness, only gain), let alone dynamically.

But that’s just me…
2 cents, YMMV, et cetera :)

regards,
kjg


June 1, 2008 | 2:59 am

Maybe there’s a fundamental misunderstanding here, but if you
straight-up sum 4 channels of white-noise, shouldn’t the sum be (not 4
times as loud because dB is logarithmic), but noticeably louder? In a
DAW, if you mix 4 channels of white noise, the master gain stays
constant, no?

On Sat, May 31, 2008 at 10:05 PM, Klaas-Jan Govaart wrote:
>
> Quote: morgan wrote on Sun, 01 June 2008 03:35
> —————————————————-
>> Doesn’t a DAW have to compensate for the fact that adding signals on
>> top of each other increases gain? I’m not talking about dynamic
>> adjustment, just some logic that scales things so that you don’t have
>> to think about it.
>
> If I add two signals in a DAW with both faders at 0dB I want them to just be summed. Depending on their correlation I will end up with a signal with either a higher or a lower level. I might then compensate for that using the faders depending on what I want. My DAW can not know what I want. It can’t mix for me. And personally I wouldn’t be interested in an algorithm approximating the ‘right balance’ between a bunch of signals. Not statically (I don’t even like the automatic gain make-up in some compressors – those algorithms don’t take into account perceived loudness, only gain), let alone dynamically.
>
> But that’s just me…
> 2 cents, YMMV, et cetera :)
>
> regards,
> kjg
>


Morgan Sutherland



kjg
June 1, 2008 | 7:57 am

Quote: morgan wrote on Sun, 01 June 2008 04:59
—————————————————-
> Maybe there’s a fundamental misunderstanding here, but if you
> straight-up sum 4 channels of white-noise, shouldn’t the sum be (not 4
> times as loud because dB is logarithmic), but noticeably louder? In a
> DAW, if you mix 4 channels of white noise, the master gain stays
> constant, no?
>

I’m not sure what you mean by "master gain" here, but yes, if you sum noise sginals the result will be signals with a higher level.

When summing the output of two independent white noise generators, RMS value of the resulting signal will be approximately 3.01 dB higher (these signals are said to have a correlation of 0).

If you split the signal of one white noise oscillator, and sum the two resulting signals you will end up with the same signal approximately 6.02 dB higher in level (correlation of 1 – doubling)

For more than two uncorrelated signals things are less straight forward. You will still see a rise in RMS value, but it will be less than 3dB. Adding together four signals like you suggested does not result in a another 3dB rise in RMS level like you might expect(2×2, right) but probably something between around 1 and 2dB. For even more signals the rise in level of the sum will get smaller and smaller and soon be more or less irrelevant, assuming you have use a proper gain structure and there have some headroom.

Try it. Really. Start mixing some sines and some noises, correlated uncorrelated and in anti-phase. You will understand more, better and faster.

cheers,
kjg


June 1, 2008 | 10:47 am

I haven’t read all of this thread, but has anyone mentioned tap.elixir~ yet
?
I know it’s more satisfying to build your own solution for this, but if
there is a time constraint for this project, this object from the excellent
Tap Tools does exactly this in a single object.
Alternatively, you could always ask Tim how it does it’s thing, so you can
build your own in Max…
Cheers
Roger



f.e
June 1, 2008 | 12:12 pm


June 1, 2008 | 12:56 pm

Huh, I’m sitting here summing noise in Live and you seem to be right.
If you keep adding the same signal, the "master level" (sum) will
continue to increase into the clipping range (more-so if it’s the same
signal, less-so if it’s different signals).

I stand corrected/enlightened.

On Sun, Jun 1, 2008 at 3:57 AM, Klaas-Jan Govaart wrote:
>
> Quote: morgan wrote on Sun, 01 June 2008 04:59
> —————————————————-
>> Maybe there’s a fundamental misunderstanding here, but if you
>> straight-up sum 4 channels of white-noise, shouldn’t the sum be (not 4
>> times as loud because dB is logarithmic), but noticeably louder? In a
>> DAW, if you mix 4 channels of white noise, the master gain stays
>> constant, no?
>>
>
> I’m not sure what you mean by "master gain" here, but yes, if you sum noise sginals the result will be signals with a higher level.
>
> When summing the output of two independent white noise generators, RMS value of the resulting signal will be approximately 3.01 dB higher (these signals are said to have a correlation of 0).
>
> If you split the signal of one white noise oscillator, and sum the two resulting signals you will end up with the same signal approximately 6.02 dB higher in level (correlation of 1 – doubling)
>
> For more then two uncorrelated signals things are less straight forward. You will still see a rise in RMS value, but it will be less than 3dB. Adding together four signals like you suggested does not result in a another 3dB rise in RMS level like you might expect(2×2, right) but probably something between around 1 and 2dB. For even more signals the rise in level of the sum will get smaller and smaller and soon be more or less irrelevant, assuming you have use a proper gain structure and there have some headroom.
>
> Try it. Really. Start mixing some sines and some noises, correlated uncorrelated and in anti-phase. You will understand more, better and faster.
>
> cheers,
> kjg
>


Morgan Sutherland



kjg
June 1, 2008 | 1:14 pm

Quote: f.e wrote on Sun, 01 June 2008 14:12
—————————————————-
> I may see what he is talking about : In PT, when you’re over, it’s
> clipping. In Cubase or Nuendo, you can be all in the red and it will not
> always clip or distort. I don’t know what Steinberg is doing but you can
> work at very high levels in their DAW without big troubles

yes, true. cubase/nuendo, logic and other properly designed DAWs work with floating point internally, providing a large amount of headroom whenever you forget to keep a proper gain structure for some reason. I still make a habit of always keeping proper levels from input to output, thru channels and busses, plugins and external hardware. from recording all the way through "mastering" or otherwise finalizing a project. It’s a matter of basic understanding and a little discipline, but it can save you so much head aches.

Yes "pro" tools.. I love it as a tape machine replacement! To record 24 channels and coarsely clean them up. It does that great. But from there I rather take it to something a little more refined and 21st century. An app that can deal with stereo files… uses floating point internally… Runs VSTs or AudioUnits instead of proprietary rtas/tdm… O, and something that I can use with the hardware of my choice instead of overpriced digidesign hardware.

Sorry for the rant… If it works for you, please enjoy it. It’s just otols after all.

Yes, with poly~ it is easy to get in clipping trouble. I normally multiply with 0.1 on the output of a voice which equals to -20dB and most of the time that provides enough headroom.
Than a signal fader on the output to carefully bring it up and see how loud it sums..

regards,
kjg


June 1, 2008 | 7:20 pm

barry threw schrieb:
>> A pan control would sum two signals reduced by 3dB into one output
>> signal, I think.
>
> No, a pan control takes one signal and pans it across two (or 36,689)
> channels. Completely the opposite.

I’d say yes, each doubling of channels would require a attenuation of
about 3 dB, even if there is a theoretical chance that all hit at the
same sample a full volume, this chance is very minimal and gets
exponentially smaller the more signals you mix….

> It depends, obviously, on what is in the signals.

yes, but I would simply assume the signals are not correlated…

> If one of your signals is at zero amplitude, then you don’t have to
> reduce it much. Look into compressors…they will achieve your goal.
> If you signals are mostly the same…you can keep them all at 25% and
> hope that works.

I would put them at 50% which is -6dB. With 4 signals there is almost no
hope that it doesn’t work… (I you’d put up 4 full blown noise signals,
you might get some rare inaudible clippings, but that is not a realistic
example…)

Stefan


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



f.e
June 2, 2008 | 1:22 am


June 2, 2008 | 7:18 am

Thanks for your succinct reply, Stefan.

My input sounds are all percussion, so although I understand that the likelihood of clipping is minimal, I was just curious about the theory on this.

I have used tap.elixir~ in the past, but prefer not to rely on 3rd party objects (especially paid-for ones), because it limits the portability of the patch.

Thanks again.

Jonathan.


June 2, 2008 | 10:26 am

f.e schrieb:
> What i do in Max is i always use clip~ -1. 1. for safety.

I bet it sounds the same if you leave them out…
Usually a dac~ is just doing the same as a clip~ -1. 1. (unless its
badly designed and fold over instead of clipping, but all interfaces I
came across till now clip…)

Stefan


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



f.e
June 2, 2008 | 10:31 am


June 2, 2008 | 11:27 am

Morgan Sutherland schrieb:
> Doesn’t a DAW have to compensate for the fact that adding signals on
> top of each other increases gain? I’m not talking about dynamic
> adjustment, just some logic that scales things so that you don’t have
> to think about it.

If you mix, you don’t need to think about it, you hear it and mix…
I would not want any automation with that, it doesn’t make sense. You
listen and adjust. If there is distortion you lower the level. Thats
what a master control is for….

Morgan Sutherland schrieb:
> In a DAW, if you mix 4 channels of white noise, the master gain stays
> constant, no?

Definitely no, I wouldn’t buy it if it would lower the volume on its own…

Stefan


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


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