Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 84d1d4b1 authored by Antti S. Lankila's avatar Antti S. Lankila
Browse files

Bias estimate of sound pressure level upwards

This patch introduced asymmetry in the loudness estimate
for the dynamic loudness correction. The effect is to
bias the estimated loudness towards the strongest sounds
heard in the last few seconds. This should fix the following
defects:

- reduce pumping treble associated with slow drum beats
- reduce the bass boost for sounds preceded by silence.

Change-Id: I5832ba7c43933ff4b71521ea4818aa9f7e3b4b65
parent 2474814f
Loading
Loading
Loading
Loading
+10 −8
Original line number Original line Diff line number Diff line
@@ -243,14 +243,16 @@ int32_t EffectEqualizer::process(audio_buffer_t *in, audio_buffer_t *out)
    for (uint32_t i = 0; i < in->frameCount; i ++) {
    for (uint32_t i = 0; i < in->frameCount; i ++) {
        if (mNextUpdate == 0) {
        if (mNextUpdate == 0) {
            float signalPowerDb = logf(mPowerSquared / mNextUpdateInterval / float(int64_t(1) << 48) + 1e-10f) / logf(10.0f) * 10.0f;
            float signalPowerDb = logf(mPowerSquared / mNextUpdateInterval / float(int64_t(1) << 48) + 1e-10f) / logf(10.0f) * 10.0f;
            signalPowerDb += 96.0f + 10.0f;
            signalPowerDb += 96.0f - 6.0f;


            /* Limit automatic EQ to sub-dB adjustments to limit the noise
            /* Limit automatic EQ to small adjustments to limit the noise
             * introduced by updates. */
             * introduced by updates of EQ bands. Additionally, we bias
            if (mLoudness < signalPowerDb - .5) {
	     * the loudness estimate strongly towards the highest seen
                mLoudness += .5;
	     * values, to avoid pumping artifacts. */
            } else if (mLoudness > signalPowerDb + .5) {
            if (mLoudness < signalPowerDb - 1.0f) {
                mLoudness -= .5;
                mLoudness += 1.0f;
            } else if (mLoudness > signalPowerDb - 0.1f) {
                mLoudness -= 0.1f;
            } else {
            } else {
                mLoudness = signalPowerDb;
                mLoudness = signalPowerDb;
            }
            }