[mythtv] [mythtv-commits] Ticket #4804: Add software amplification support to libmyth/AudioOutput
Chris Hamilton
chamilton at cs.dal.ca
Wed Apr 16 12:20:24 UTC 2008
Mark Spieth wrote:
>> Then perhaps the right approach is to make the software preamp available
>> in the audio output class, but to use the decoders native preamp if one
>> exists. Another possibility is to extend the AudioOutput class to
>> accept floating point input as well, and to make decoders use this when
>> access to the floating point data is available.
>
> all codecs currently output 16bit 2ch audio. changing that would be an lavc
> also.
> IMO I dont think this is an option.
>
>> Regardless of the approach, I'm not convinced that the errors involved
>> in rounding before amplifying are significant; typical preamp values
>> (looking at the ReplayGain values across my collection of music) are
>> going to be within +/- 10 dB, so we're talking about errors of at most 2
>> units per 32,768, or an error of at most 0.006% per sample value.
>
> note 12dB is 2 bits when amplifying.
At 12 dB the average expected error is just over 1 while the worst case
error is of 2 units. Suppose the true sample is x+d, which rounds to x
(for -0.5 <= d < 0.5). Then the error in amplification is given by
(where g is the gain expressed as a multiplicative factor):
| round(g*x) - round(g*(x+d)) |
For any integer value of g, this simplifies to
| round(g*d) |
The worst case of this is 2 units for g=4 (12 dB). In my 10 dB example,
g = sqrt(10) = 3.16... and the worst case error is 2 units as well with
an expected error of around 0.8.
> so are we talking about every audio codec type having a preamp value to
> provide volume normalization?
> If this is so, I would still change the gain values in lavc so that it
> happens at the correct place.
>
> I know mpeg1 layer2 audio is currently softer than it should be.
> music from mythmusic is usually loud and almost saturated (using
> flacdecoder).
>
> also which codecs are we talking about? video only modes? or music modes
> too?
The preamp stuff is initially intended for ReplayGain support. In that
case, the MythMusic plugin will manually set the gain according to any
ReplayGain values found in the audio file. Since ReplayGain is
calculated in a standard way, any bias built into the codec will have no
effect.
The talk about adding some default gains for differing codecs was
brought up by somebody else. If certain codecs can be proved to have a
consistent bias, then such amplification factors could always be
selected as a default gain in the absence of ReplayGain data. I'm
currently talking only about the MythMusic plugin, but a similar
technique might work for video playback.
Cheers,
Chris
More information about the mythtv-dev
mailing list