audio clips when vinyl scratched

Bug #1741684 reported by Owen Williams
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mixxx
Fix Released
High
Daniel Schürmann

Bug Description

I was taking a look at 2.1, and I noticed if I have a track that does not clip during playback (red lights do not illuminate), it will clip if I do a fast scratch. I suspect there is some new amplification code for vinyl scratching mode that is causing this. While I can understand altering gain when scratching is happening, we should definitely not be introducing clipping. Either we need to compress the signal or clamp the gain at 1.0

Revision history for this message
Be (be.ing) wrote :
Changed in mixxx:
milestone: none → 2.1.0
importance: Undecided → High
Revision history for this message
Daniel Schürmann (daschuer) wrote :

You are right Be, scratching increases the gain up to 5.5 dB.

Owen, which track is effected?
Do you use replay gain? What is your target loudness?
Do you use any additional effects, gain or EQ?

Revision history for this message
Owen Williams (ywwg) wrote :

A 5.5db increase is a lot, are we assuming everyone has at least a 6db headroom? I don't think we should cause a gain increase at all unless we have a built-in compressor to compensate. I'm using replaygain at -15 (+3db) which is a good amount to get the tracks as loud as possible without clipping. No gain or other effects.

Revision history for this message
Be (be.ing) wrote :

I think it would make more sense to adjust the gain calculation formula than use more CPU cycles on a compressor after that.

Revision history for this message
Owen Williams (ywwg) wrote :

That's also my preferred solution -- not to cause any gain increase

Changed in mixxx:
status: New → Confirmed
assignee: nobody → Daniel Schürmann (daschuer)
Revision history for this message
Daniel Schürmann (daschuer) wrote :

This feature does not work without increasing gain, because rate 1.0 is the sweet spot of the effect. It is simply the reality that the gain is increased with increasing speed.
On the other hand I can understand that clipping is undesired. Owen uses more default gain than recommended, for -18 or -16 LUFS, but I can easily find high dynamic tracks, where I also see clipping during fast scratches with Mixx's default gain settings.

I Think a good compromise solution is to keep the over all track gain below 0 dB even of fast scratching. This keeps a reasonable vinyl effect for normal tracks, but avoids clipping for high dynamic tracks. It can still clip though if you user EQs above 0dB or other gain increasing effects, but this behaviour should be expected anyway, since a track is allowed to play at digital 1 level.

What do you think?

I will prepare a PR to test this.

Revision history for this message
Owen Williams (ywwg) wrote :

I'll take a look at the PR, I think your approach should be ok.

Revision history for this message
Be (be.ing) wrote :
Changed in mixxx:
status: Confirmed → Fix Committed
Changed in mixxx:
status: Fix Committed → Fix Released
Revision history for this message
Owen Williams (ywwg) wrote :

Did this regress? I'm getting clipping 100% of the time with current 2.1.

Revision history for this message
Sean M. Pappalardo (pegasus-renegadetech) wrote :

This is the only change I see since everyone signed off on the original fix: https://github.com/mixxxdj/mixxx/commit/ac9f425e0f39cd1dbeb8408b8068250fc7b31a3e#diff-d4fbe0c80e66c0977f4a44d9d1f415f2

Does const vs const expr make a difference?

Revision history for this message
Sean M. Pappalardo (pegasus-renegadetech) wrote :

Or does moving that kSpeedOneDiv make a difference?

Revision history for this message
Owen Williams (ywwg) wrote :

And the tests should have blown up if something changed, hm. Printing out some values, the function still looks like it's working correctly: total pregain is still only .9. But that's showing up as clipping.

I wonder if something changed elsewhere? If I hack the code to have speedGain max out at 1.0, I don't get clipping any more and my totalGain never goes above .47, which is the replaygain value for this track (duh, because then it'll never get above zero).

What I don't get is why at a final pregain of 0.9 I'm getting major clipping.

It looks like there's been some sort of across-the-board gain change. If I turn off replaygain completely and set all my pots to zero, almost every track I have is clipping during normal playback. This shouldn't happen for wavs, flacs, and mp3s. I'll see if I can do a bisect and narrow down the problem

Revision history for this message
Owen Williams (ywwg) wrote :

(er, it'll never get above 1.0 so it obviously won't cause more gain than the replaygain value)

Revision history for this message
Sean M. Pappalardo (pegasus-renegadetech) wrote :

There was a bug # 1766042 where FLAC files had their gains set too low and you need to re-analyze them.

Revision history for this message
Owen Williams (ywwg) wrote :

Currently I'm testing with replaygain turned off, so analysis should not affect the result at all. Also, this is on brand new files so the analysis is fresh anyway. I identified this revision: d68a5997c745320555bab6860198d00d3e6b0edf Fix -6dB gain in FLAC

Before this change, playing back flac files was fine, but after, they are clipping regularly out of the box (no replaygain, no eq, no adjustments to gain)

Revision history for this message
Owen Williams (ywwg) wrote :

But what's weird is, not just flac files seem to be clipping, I'm seeing problems in wav and mp3 files as well. So it could be that the decoding in flac is correct now, but something else downstream is wrong.

Revision history for this message
Daniel Schürmann (daschuer) wrote :

In lossy codecs you can experience samples above one if the original track was hard normalized to one. The noise added by the lossy encoding will produce clipping samples after decoding.
This does not explain you flac and wav format issue though.

Do you have clipping without scratching with some files now?

Revision history for this message
Owen Williams (ywwg) wrote :

It seems to be something in the effects processing. if I comment out this bit in enginedeck.cpp the clipping issue goes away:

EngineEffectsManager* pEngineEffectsManager = m_pEffectsManager->getEngineEffectsManager();
    if (pEngineEffectsManager != nullptr) {
        pEngineEffectsManager->processPreFaderInPlace(
            m_group.handle(), m_pEffectsManager->getMasterHandle(),
            pOut, iBufferSize, m_pSampleRate->get());
    }

I'll see if I can figure out where the extra gain is coming from. (I have no effects turned on)

Revision history for this message
Owen Williams (ywwg) wrote :

Ah, it's the EQs. I thought EQs were neutral when the knobs were at zero? I'm using LinkwitzRiley8

Revision history for this message
Owen Williams (ywwg) wrote :

lol, our docs make it clear that filter is not bit perfect. OK so I think my issue was a combination of:

* the FLAC -6db fix, which made all my flac files louder afterward.
* my preexisting replaygain settings, which had been tweaked to secretly account for that bug.
* my EQs, which cause a small amount of gain naturally

Conclusion: I think maybe we need to fix the LR8 filter? I'm seeing regular peak sample values with that EQ of up to 1.44, vs nothing above 1.0 for the same track with bessel8

Revision history for this message
Swiftb0y (swiftb0y) wrote :

Mixxx now uses GitHub for bug tracking. This bug has been migrated to:
https://github.com/mixxxdj/mixxx/issues/9064

lock status: Metadata changes locked and limited to project staff
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.