Re: Mixing manually vs. Mixer AudioUnit and avoiding clipping
Re: Mixing manually vs. Mixer AudioUnit and avoiding clipping
- Subject: Re: Mixing manually vs. Mixer AudioUnit and avoiding clipping
- From: Admiral Quality <email@hidden>
- Date: Fri, 18 Jun 2010 16:15:53 -0400
Guys, again the music production world solved all this stuff 50 years ago.
For an adaptive solution, one that "rides" the volume as you go to try
to maximize output volume all the time, you want to build a "brick
wall limiter". You can google from there.
The divide each track by 8 when there's 8 tracks thing will work. But
you DON'T want to adjust this on the fly. You figure out the most
*voices* your instrument is going to play and that's your scaling
factor. The worst case mixing scenario then, where each track is equal
to 1.0 (or -1.0), will still mix without clipping.
But in real life, you'll find that that's mostly overkill. It's very
rare (but still quite possible) for all the "tracks" (if talking about
individual notes produced by an instrument we should call more
properly call these "voices") to be in the exact same phase and all
reach a peak at the same time. More typically, some tracks are high,
some are low, and when added together (mixed) they all average out.
Keep in mind that sample data in float format goes from -1.0 to 1.0.
Turning the volume/gain of a track down by 0.25 would make that range
-0.25 to 0.25. You should always have a negative range extreme that
roughly matches the positive range.
- AQ
On Fri, Jun 18, 2010 at 3:58 PM, Paul Scott <email@hidden> wrote:
> You have to normalize the buffer. The application I'm working on generates
> modulated continuous wave and FSK signals at various frequencies
> superimposed on each other. With more than about 4 simultaneous signals I
> start to get distortion. I have had moderate success normalizing each buffer
> after each "track" is added by noting the highest value in the buffer,
> computing a normalization factor relative to 1 and then multiplying each
> value in the buffer by that factor. Normalizing once after all tracks are
> added can cause clicks between buffers depending on how may tracks appear
> across buffers. Normalizing after each track is laid down reduces the
> effect. Will that work for you? I am experimenting with a ramp factor
> across buffers but have nothing to report yet. I am also experimenting with
> pre-emphasis and de-emphasis of each track before addition and
> normalization, but again, nothing to report yet. I am getting pretty good
> results so far without knowing anything about DSP algorithms, just code
> developed through experimentation. What I mean is, I'm no expert. Advice
> from experts is welcome.
>
> FWIW, HTH,
> Paul
>
> uɐıʇəqɐz pnoqɥɒɯ wrote:
>>
>> On Jun 18, 2010, at 11:44 AM, Gregory Wieber wrote:
>>
>>
>>>
>>> You have to think in terms of the max output signal being "1". You need
>>> to divide that by the number of busses you have and set the volume for each
>>> bus accordingly.
>>>
>>
>>
>> I tried something like that but it didn't work very well. Take, for
>> instance, the case where you have one note playing, 5 notes are silent and
>> two notes are playing at very low levels. Dividing the mixed signal by 8 is
>> not going to sound right.
>> I think the trick is to reduce the volume of the very high notes, but not
>> to reduce the lower notes.
>> Google has pointed me to some articles on compression or Dynamic Range
>> Compression... maybe that's the direction I need to move in...
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Coreaudio-api mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden