PDA

View Full Version : Audio Tutorial and gain/clipping



Reggie
07-15-2016, 05:55 PM
I'm going through the audio tutorial for the teensy 3.2 + Audio board I'm up to part 2-2 'Mixers & Playing Multiple Sounds' and I notice the use of gain and mention of clipping but it doesn't really make sense to me, I understand clipping to be when the audio signal goes above 0db generally but with the examples so far I'm not seeing any mention of levels at all just advice to make sure that you don't set the gain above 1.0, what am I missing?

The info summary for mixers makes sense but contradicts the gain/clipping advice and says it amplifies above 1.0, obviously the wave files could already be mixed down to 0db which would make the advice in the tutorial make sense.

B.Jacquot
07-18-2016, 11:53 PM
Some of this takes careful reading, as the tutorial is using similar notation (IE: "1.0") to express both signal levels and mixer gain factors.

If a signal is already at maximum, a mixer won't add clipping if:

The channel gain is 1.0 or less.
There are no other channels being added to cause the resulting sum to clip.


I think the overall point is that if mixer channel gain is above 1.0, then it's possible to clip. Whether it clips or not is dependent on the signal. If a signal is below the maximum, you can amplify it without clipping. Similarly, gain below 1.0 can't clip, as there's no factor that's less than 1.0, but causes the output to be larger than the input.

Gain factors can happily exceed the 1.0 ceiling, but signals shouldn't, in general*.

*There are situations where you might want to clip the signal, so this is more of a guideline than a rule.

defragster
07-19-2016, 12:05 AM
If I recall doing the tutorial as the video played. In the video it was noted that this would happen only briefly - and either the resultant distortion would add emphasis, or likely not happen with the short duration sounds events involved as noted in p#2.

Reggie
07-19-2016, 03:09 AM
B.Jacquot, that's how I expect it to be, I wasn't trying to pick holes in the tutorials, I wanted to make sure I hadn't misunderstood something fundamental. So the distinction needs to be made that it's not the sum of the levels being > 1.0 that causes clipping, it's the sum of the levels of mixed objects exceeding 0db.

defragster, it depends on the content you're trying to mix, in the tutorials I'd expect the examples to not clip, unless they're implicitly trying to show you what clipped signals sound/look like. In real world examples I'd expect every sample to be different and treated accordingly.

PaulStoffregen
07-23-2016, 11:20 PM
So the distinction needs to be made that it's not the sum of the levels being > 1.0 that causes clipping, it's the sum of the levels of mixed objects exceeding 0db.


Signal level of -1.0 to 1.0 peak-to-peak is effectively 0 dB, in traditional audio lingo.

The Teensy Audio Library tries to use a consistent API where signals and gains are represented with linear scale numbers, not log scale decibels.

defragster
07-23-2016, 11:39 PM
... defragster, it depends on the content you're trying to mix, in the tutorials I'd expect the examples to not clip, unless they're implicitly trying to show you what clipped signals sound/look like. In real world examples I'd expect every sample to be different and treated accordingly.

Indeed - I do not have expert knowledge or even 'traditional' understanding, of this - just general and the tutorial presentation got across to me just that/this:: these samples may clip if you hit the buttons right and combine peak values - but generally will not - based on the samples and timing. If the samples were all full scale and played together there would be clipping - because the net gain would be over 1 as configured.

It seems it has been 2 months since I got the Tutorial hardware and went through it once, then I focused on video display of the FFT data on two displays - and the last month on beta PJRC hardware. I do intend to go through it again on the Beta Teensy.

Reggie
07-24-2016, 11:27 AM
Signal level of -1.0 to 1.0 peak-to-peak is effectively 0 dB, in traditional audio lingo.

The Teensy Audio Library tries to use a consistent API where signals and gains are represented with linear scale numbers, not log scale decibels.

Hi Paul, that's sort of how I understood it but with nothing to reference to, 1+1 =?? if you haven't actually measured the output signal(s). I hope it doesn't sound like I'm trying to be pedantic, log scale is well used in audio production, as I'm sure you're aware.

Ben
07-24-2016, 01:24 PM
0dB is referenced to the full scale digital representation of the signal, which is represented by a value of 1.0 in the Audio Library.
Thus:
dB = 20*log10(amplitude/1.0)

So if you mix (add) two signals of 1.0 amplitude you get 1+1=2, plug it into the formula:
dB = 20*log10(2.0/1.0) = 20 * 0.3 = 6dB
As this is a positive number it will clip.

I'm not sure that's what you were asking for though?

Reggie
07-24-2016, 03:47 PM
Thanks Ben, that's useful, a quick method to output a db value pretty much solves my next problem, my original post was just questioning the information that was given, that's been cleared up now too. I'm no expert either, it's just that all of my audio kit apart from synths tends to mostly use a +/- db scale when it's talking about clipping.