11 September 2008

Some thoughts on a new technique for clipping detection

I decided to riff on an idea I had for smarter ways to detect clipping. I'm sure it's not a new approach - a quick search on Google pointed out several papers on the same basic concept - but I'm not aware of it being used for audio, or for mastering evaluation specifically.

Clipping clamps the signal to a constant value. It also tends to occur right in the middle of signal content which is of a high power. If the signal derivative is calculated, the DC component of the clipping is effectively eliminated, bringing the values to 0, while the values before/after the clipping are relatively unmodified. (Specifically, low frequencies are attenuated and high frequencies are boosted.) So naively, one could use this derivative as the basis for a clipping detector - compare y' to y, and if y' is zero or very close to 0 while y is of a high power, you may have clipping. This technique would be immune to attenuated clipping - if it occurs at -10db it should work as well as if it is at 0db.

However, this approach fails when gross frequency response distortions are introduced - like what exists on vinyl. As discussed earlier, vinyl clipping examples exist which are sloped, not flat. The derivative of these a sloped line is a constant nonzero value. The workaround for this is simple: take another derivative, the second derivative, so that this constant nonzero value collapses to 0. In theory this could be extended to an arbitrary number of derivatives, but because high frequencies are amplified, background noise tends to dominate the response after the 2nd derivative, so the 3rd and beyond are pretty useless for vinyl analysis.

What I'm ultimately hoping for is to have the final output be a histogram and running a threshold on that to give an estimate for how many clipped samples exist in the signal. This allows comparisons between signals that are not sample-aligned (as is usually the case with vinyl vs. CD comparisons).

Here's what I have so far. First, some clipped stuff from Leyendecker again, on CD:

Note how the clipped content is neatly crushed to 0 on the second derivative plot - and most importantly, that the histogram plot shows a lot of values on the left, outside the distribution curve with a high signal energy and a low 2nd derivative energy. Those are the clipped samples.

Now for the LP version, different part of the file:

The 2nd derivative crush still occurs, but it's not nearly as prominent as on the CD. And the clip signal is so weak on the 2nd derivative plot (or the noise is so high) that none of it really shows up on the histogram plot; there's no real indication of clipping there.

But it's a start.

10 September 2008

Feedback on "Waveform Plots Considered Harmful"

I received lots of feedback on my HA thread and some in the comments. I intend to update the paper incorporating this feedback, archive the original somewhere, and post it for more general consumption soon.
  • Several people commented that the tone of the article in general was too inflammatory, and given that I used waveform plots to make a few important points, potentially hypocritical. I blame the insanely late hour that I wrote it. It will be edited to be a bit more evenhanded.
  • One person commeneted that the particular waveform examples I used seemed to imply that the vinyl master is clipping significantly less than the CD master. I'm seeing that too, and I cant' really explain it. It's clearly not some sort of analog effect in the playback system, and it seems to be consistent across the entire disc. The fundamental issue is the same - buying vinyl does not always mean you are getting a product without hard limiting - so I think the article still stands up well. But the specific point of that example, that there exists a vinyl master which provably has just as much clipping as the CD master, is compromised significantly.

    Note, also, that other people have observed vinyl waveform plots that don't share Mirrored's subtle difference in clipping levels. The clipping levels really do seem to match in those cases.
  • A clearer distinction needs to be made between periodic clipping of periodic signals - which is extremely audible even in small amounts - and clipping of transients, which is far less audible. Modern mastering practices can occupy either extreme or somewhere in between.
  • I'm equivocating between clipping and hard/brickwall limiting; clipping is only one form of hard limiting. A proprietary hard limiter is capable of doing the same job that clipping does, but with potentially far less audible distortion. It's an open question as to how much more audible clipping is than a good hard limiter. Nevertheless, the damage done to the audio is quite significant for all hard limiters.
  • While we're on the subject of things that should be made more clear, the extensive use of dynamic range compression (of the non-limiting variety) clearly has a far more audible effect on the sound than limiting/clipping.
  • Important tip: Bob Katz commented that he always sends vinyl masters out without the use of the hard limiters used on the CD masters. Yay!

04 August 2008

MT9: Terrible marketing, better potential?

(Reposted from an Audioholics post.)

There was a little hubbub recently over this Korean codec called "MT9" that claims to attempt to unseat MP3. Most sane people rightfully call that bollocks. Even the English-language MT9 site calls it bollocks.

But I wouldn't count it out quite yet. There are a lot of subtle implications to MT9 that I don't think people have fully realized.

All MT9 appears to be is a container format for an unmixed record. That is, instead of taking a multitrack production and downmixing all the instruments to stereo, you encode each instrument to a separate track as .MT9 and let the player do the downmixing. There's no technical innovation involved here. MT9 is probably (well hopefully) just a container around a mainstream codec like MP3 or AAC.

Therefore, MT9 does not in any way compete with MP3 or other mono/stereo lossy codecs - although it may be able to use them internally. As is mentioned, it could be used as an alternative means to deliver music, but the odds of it ever catching on in popular music are rather slim. That all press discussion (and MT9's own web site!) have focused on that aspect is quite unfortunate.

From a encoder standpoint, this is still kind of a win - because there's a 1 to 1 correspondence between channel and instrument, you no longer have to worry about weird stereo collapse issues, you only have to tune the encodings for mono, etc. The bitrate would likely still be much higher than MP3 for high quality, simply due to the number of channels involved.

From a playback quality point of view, the MT9 system precludes the use of global dynamic range compression and limiting. That is, because mixing is deferred until playback, mastering must also necessarily be deferred until playback. This, of course, is a partial solution for ending the loudness war and is a huge win. Compression can still be applied to individual tracks, but because the listener has control over the volume of individual tracks, there would be much less impetus for producers to try to make a particular track stand out in the mix. Of course, this also strongly implies that producers would not need to employ mastering engineers in the traditional sense, bringing costs down.

This has virtually no chance of supplanting other formats for commercial music. But the deals with karaoke and possibly cell phones are probably the perfect application for this at the moment: very closed markets, and the music is often custom produced anyway so doing a multichannel production is not a big deal. But as I mention, I suspect I wouldn't mind buying normal music in this format either.

18 July 2008

Foot wrapped in tonearm cables and inserted in mouth - film at 11


I made a recording of a 2-LP set before ever listening to it, and after mucho processing, I listened and discovered that it was corrupted by large amounts of ground noise. Bleh. I had to throw them out and re-record.

After much searching I discovered that the power supply from my Dell laptop was the culprit. Moving the turntable cables away from the PS relieved the noise. Moving them back increased it. Wrapping the cable around the power supply amplified the noise tremendously.

The noise consisted of peaks about 30db above the noise floor at 60hz and 180hz, many peaks in the 20db range from 200-10khz, and a huge mass of +20db harmonics centered at about 13khz and 18khz. Not subtle at all.

This throws a major wrench into my whole way of thinking about balanced turntable connections. I was under the impression that a well-shielded balanced cable is fairly immune to EMI of this nature; clearly I'm mistaken.

Microphone and pro audio connections have the same issues; I'll need to research how sensitive they are supposed to be to this sort of thing before I consider making cabling/equipment changes.

11 July 2008

Recording sample: Einstein on the Beach

Here is a 30-second sample of my current recording process. It's the first 30 seconds of side 3 of the CBS Masterworks pressing of "Einstein On The Beach", encoded with lossyWAV --portable in FLAC.

I bought the boxed set at Amoeba Records in SF for $9, and it's easily some of the best pressed and maintained vinyl I have ever laid eyes upon. (The music is excellent too.)

Note the hiss before the violin begins - that is the 0404 USB's mic preamp noise I was talking about. It is fairly prominent in silent passages, but is difficult to identify while most music is playing, and is also pretty hard to spot with noisy vinyl. So it's fairly important to get this fixed, as far as vinyl upgrades are concerned. Besides that, I think the sound quality is excellent.