Mile Zero is the personal website of Thomas Wilburn. All statements and opinions here are my own, and do not represent the views or policies of my employers at Congressional Quarterly, Ars Technica, or other publications.

April 8, 2010

Bitrot

Digital files don't wear out, right? This is one of the big advantages of the medium, particularly in studio situations: people love the warmth of tape, but it's fragile and it loses a tiny bit of fidelity every time you play it, much less when you make a copy. If you read a lot of studio how-to articles (a guilty pleasure of mine), a common theme is the engineer who records on tape for the sound, then immediately dumps it into Pro Tools for actual editing and mixing. And of course you can make a perfect copy of a digital file, where as there's no such thing in analog.

With one exception: back when DRM'd music sales were the norm, the typical way to remove that DRM was to burn the file to a CD and re-rip to MP3 format. This was seen as kind of a kludge, because the process involves conversion to a lossless .WAV format and then back into lossy pyschoacoustic compression. In theory, every time this happens, the latter step means a loss of information, and thus fidelity.

But how much of a loss? I started wondering this when I went to make a CD for a fellow dance student from some MP3 files I'd gotten from More Than A Stance. I didn't know how he planned to play them or how tech-savvy he was, so audio CDs seemed like a better choice than audio files on a data CD. But if he decided to rip the CDs back, how bad would the quality hit be? I decided to find out.

Using some shell scripting (first PowerShell, then old-fashioned batch files--never use a computer without at least one scripting option, kids), I sent a couple of MP3 files through a conversion roundtrip a few hundred times. My choices were "Beam Katana Chronicles" from the No More Heroes soundtrack and a remix of the Jackson Five's "Life of the Party" from DJ D.L.'s Soul Movement II, picking these particular tracks for a few reasons:

I used LAME to do the decoding and encoding at a 256kbps bitrate. On the first test, I actually ran the file out to a separate .wav and back. The second time, I figured out how to pipe the stdout from one LAME instance to the stdin of a second, and just bounced it between two MP3 files, which was much faster.

The results were surprising. Here's a table with some samples (caution: may be loud), which I'll summarize below.

iterations trackaudio
original No More Heroes
DJ D.L.
50 No More Heroes
DJ D.L.
100 No More Heroes
DJ D.L.
500 No More Heroes
DJ D.L.
At under 10 iterations, I can't tell a difference between the two files. At 30-50, it's subtle--there's a little bit of swirliness around the high end, and the transients are a little blurry, but nothing more than you'd expect from, say, a turntable. It's not until you hit 100 iterations--that's 100 times going from an MP3 file to a WAV and back--that it starts to become noticeable. At that point, there's some definite artifacting, and you can start to hear a little bit of pumping in the volume after each peak. Even still, it's not much beyond the extremes of dynamic compression that have emerged from the loudness wars, and if you snuck it into my playlist I wouldn't guarantee that I'd pick it out. Once you get beyond 100, it becomes more obvious that something's broken. By 500, there's some real glitchiness going on when the track hits full volume--surprisingly, much more in the NMH track than the J5, although the latter also has its "underwater washing machine" moments.

There are a few holes in my experiment that would be interesting to test:

Still, I have to admit this is far better performance than I expected going in, and I was cheering for LAME to begin with. I think we can safely reach the conclusion that for limited, real-world cases of digital dubbing, there's no serious impact on sound quality that wasn't already lost in the first MP3 encoding. Burn and rip away!

December 31, 2008

Don't Fear the ReaFIR

I don't really know how to say this, but: I forgot to get you anything for the holidays. I feel terrible, honestly. And after you got me such a lovely sweater.

(Belle! Take the sweater off the cat! She has some dignity to preserve!)

I'm sorry. Let me make it up to you. Here, have a peppermint stick and a quick tutorial on cheap noise reduction.

There are two cardinal sins of audio that I've committed, and which I've noticed in work by others, since it became easy to produce digital audio and video--by cardinal sins, I mean errors that make it instantly evident that this is not a professional production. The first is bad mike technique--having the microphone too far back, or too close, or using the wrong kind of microphone for the task at hand. The second is noise--noise from preamps, noise from wind and AC systems, or just the hum of a bad ambient environment.

The thing is, mike technique is hard. And you don't always have the option of great equipment, or the time to perfectly position it. You can't fix mike technique for free. And noise is also hard--I have noisy recordings all the time, because I use relatively dirty preamps with very quiet microphones, and I record in locations that aren't soundproofed (it is also likely that I'm simply not as good at this as I think I am). But constant and regular noise (such as that caused by a cheap preamp or a climate-control system) can be cleaned up (or at least, minimized), for free, after recording. And it gives us a chance to learn about DSP! Who doesn't love that?

Before going into the details of our signal processing, though, a disclaimer: sometimes simpler ways of dealing with noise are better. For example, rather than worry about filtering you could always just mask the noise with background music. Or you could use a noise gate, which would dip the volume when a person isn't talking. But I find that without music or something else to fill the spectrum, a gate can even make noise more noticable when the voice "pops" in from the silence. Besides, there are plenty of times when background music just doesn't match the desired mood, or when it's distracting. In this case, a slight amount of filtering combined with a gentle gate has produced very good results for me.

So let's say that we've got an interview recorded in a room with the AC fans running in the background, and on playback it doesn't sound great. What we're going to use to strip the white noise out of this audio clip is a Finite Impulse Response (FIR) filter. As might be obvious, this kind of filter is in contrast to an Infinite Impulse Response. Both work using the same basic principles, FIR just limits its scope a bit. Although the math for these filters quickly becomes complex, at its heart they rely on a very simple principle of weighted averages.

Remember that digital audio is represented as a series of numbers, each of which represents the value of a sample at a specific point of time. From sample to sample, sounds with high frequency content will show more change than those with little high frequency content, simply because the innate property of a high-frequency wave is its rapid change over time. So to filter out high frequencies, the easy approach is simply to generate a new wave, where each sample is the average of itself and the samples around it. That "smoothes out" the high frequency sounds, but leaves the low frequencies--which, after all, change much less from sample to sample--basically unaltered. Other kinds of EQ filters can be generated by altering the weights for each sample in the average.

What's really interesting about FIR is that you can combine it with a Fast Fourier Transform (also known as a FFT, which is a fascinating process for doing spectral analysis using math I don't completely understand) to determine the weighting for a desired filter curve. This is what the plugin we'll be using, ReaFIR, does to perform its noise reduction. Using the FFT analysis window, it takes a fingerprint of the noise we want to remove, and then sets up an filter to subtract that from the audio stream.

Let's see it in action, step by step:


click to view larger

  1. Add a ReaFIR instance to the track on which you want to perform noise reduction. Set the Mode pulldown to Subtract.
  2. Find a nice, long (1-4 seconds) of relative silence. We're going to use this to build the reduction fingerprint, so you want as pure a sample of noise by itself as possible. If there are any other sounds, they'll be incorporated into the fingerprint, and you may find yourself filtering out parts of the sound that you didn't want. This sounds really weird, and not usually in a good way.
  3. Check the "Automatically build noise profile" checkbox, and then using the DAW transport, play the clip you've picked for training. You should see yellow lines representing the frequency domain of the noise jumping across the display, with the red line (which represents the filter) fitting itself with the average of the yellow. Be sure to stop playback before you hit any voice or non-noise content. I often cut the noise out and move it to an isolated section at the end of the track, just in case I let it run too long by mistake.
  4. Now uncheck the "build noise profile" checkbox, and your filter is all set! If you play the track now, the noise should be magically gone, even during other sounds. You'll also probably hear a few artifacts, the most common of which is a slight whistling in the high frequencies due to resonance in the filter bands. I usually find that you can apply a gentle lowpass filter and tame this until it's unnoticeable.
This is really just the simplest trick that you can pull with ReaFIR, although it's the function I use most often. Another neat feature is to apply it as a mastering EQ (making sure to switch the mode from "subtract" to "EQ) after using the FFT to grab a fingerprint from a CD or a piece of music--it'll "clone" the sound of that track for your own, which works well if they're in the same style. An analysis EQ like this is a very useful tool to have around.

Well, I'm glad we got this sorted out. I'm sure you'll agree it's much better than a fruitcake, which was my backup gift. And just think: now that you've got this under control, we can celebrate the next holiday with an in-depth discussion of convolution reverb, which is based on many of the same principles. Why, maybe we could even start now...

Oh, you have to go? So soon? Ah, that's a shame, but if you must...? Then you must. I understand. Have a safe trip, then. And happy new year!

September 23, 2008

Unnatural Selections

Buying an MP3 player for the first time has made me think a bit more about the weirdness of contemporary popular music.

I used to rail about MP3, but writing the Audiofile articles for Ars opened my eyes on a lot on the realities of the technology. I've also mellowed out on sound quality when it became obvious that MP3 was a disruptive technology for individual musicians, and as I thought more about the ecological impact of CDs. I'm still not very keen on buying MP3s directly, so I'm trying out the Zune music subscription, and so far I like it quite a bit. I find it's helpful to think about it as a paid replacement for Pandora, one with lots of extra features and offline capability, instead of as a "rental" system.

But as I go through the honeymoon period with the hardware, I'm listening to a lot more music. I'm listening to it a lot more closely, trying to keep my "producer's ear" in practice (as much as it ever was). And when you do that, the surreality of modern recordings is really fascinating.

For example, I was talking to a friend a while back about recording tricks, and I mentioned the standard technique of using a sidechained compressor on drum tracks to make the snare "pop" more or tame boominess. Most people are aware of compression in general terms, as part of the mastering step--the prevalence of Loudness Wars articles makes sure of that. But I don't think most listeners are aware that individual tracks are also compressed, and that the compression can be triggered by other, separate tracks--or that this is, in fact, a special effect that's part of the modern rock sound.

To the average person, this kind of production is transparent, because it sounds "natural" to us now. We think of that as the way music would sound--under great conditions, granted, but still plausible. But when you start to break apart the processing that's done on even stripped-down productions, and you consider how that compares to, say, a person standing in a room with a band, it starts to form a bizarre picture. Take the following list:

It's a profoundly unreal set of manipulations, perversely designed to make music that sounds more real to the listener. It's so good, in fact, that it sounds more real than the real thing. Audio pundits often complain about the glossy perfection of music production, but there's another way to think about it, and that is that all of this production is intended to flatter the listener with the powers of omniscience. The reason producers work so hard to eradicate mistakes is that the audience will be able to hear everything in a way that no physical person ever could.

June 27, 2008

Thumbs Up

If you love the sound of kalimba as much as I do, you may enjoy the pad I created for CQ's upcoming DTV Transition explainer:


MP3 download

Best soundtrack instrument ever. It's just exotic enough to add interest, but not so strange that it distracts from the video. If I had a set of gamelan samples to mix with it, I'd be a happy man.

April 21, 2008

Musical Sketchpad, Session Thirteen

Better Off Dead, as made famous by Bad Religion:

Download

Been a while. Give me a chance to explain this one.

Bad Religion's Stranger than Fiction caught my ear again a couple months ago. It's the album with a lot of the classic BR songs on it: Infected, 21st Century Digital Boy, and Incomplete, for starters. But there's an impressive level of songwriting in evidence, with sharp lyrics and chord progressions that--if not incredibly original--are more complicated than they sound, and certainly more involved than punk deserves.

In fact, I like the songs so much, I've had an itch to do the whole lot of them as acoustic, voice-and-bass covers, inspired in part by the sound of the baritone guitar on the most recent Evens CD. "Better Off Dead" just happened to be the first one I picked. I think it'd be a fun project, to cover the album from start to finish this way.

There's not much technique on display here, either in terms of production or musicianship. I experimented with doing some fingerstyle arpeggios, but in the end I just strummed and sang. This mix has barely even been mixed, and has had no EQ or compression or mastering, as far as I can remember. I don't know how it'll sound through your speakers. But I'm pretty happy with the performance, and still oddly taken with the idea--although I won't subject anyone else to it anymore. Just this once.

March 2, 2008

Why Records DO Sound All the Same

There's a little-watched video on Maroon Five's YouTube channel which documents the torturous, tedious process of crafting an instantly forgettable mainstream radio hit. It's fourteen minutes of elegantly dishevelled chaps sitting in leather sofas, playing $15,000 vintage guitars next to $200,000 studio consoles, staring at notepads and endlessly discussing how little they like the track (called Makes Me Wonder), and how it doesn't have a chorus. Even edited down, the tedium is mind-boggling as they play the same lame riff over and over and over again. At one point, singer Adam Levine says: "I'm sick of trying to engineer songs to be hits." But that's exactly he proceeds to do.

...from Tom "Music Thing" Bramwell's article in Word Magazine.

Every year someone writes an article along these lines--between digital technology, aggressive mastering, and the monolithic industry control of radio, they say, music's all shot to hell and we're all going to die. I mean no disrespect to Tom, who (as always in these articles) raises a lot of points I happen to agree with. But you're preaching to the choir, friends.

A lot of this is just disguised fervor for the good old days of analog, when making music was hard and expensive. That can be safely discounted. For the rest, which basically laments that "commercial" sound, what's there to say? I personally doubt that cheap earbuds are going to end the trend, and frankly high-def sound formats show no sign of taking off. Compression and pop mastering are here to stay.

But look at it this way: The Shins made Chutes Too Narrow in 2003, and no-one would call that a "polished"-sounding record. After Garden State, everyone may well be sick of the album, but the point remains that people are still making music without a stereotypical studio sound. I can name three or four without even trying hard. They're not on the radio, though, and they're not going to be.

In the meantime, berating the music that is on the radio when it's commercial-sounding is a lot like burning yourself on the stove and then getting angry at it for being hot. What did you expect? That's what it's for. If you don't like it, quit sticking your hands in the flames.

February 21, 2008

Free Rain

Rain Recording, an company that makes computers for audio production, asked if they could use an old post of mine for their "Pro" section. It's up now (with some revision) as the newest addition to the page: In the Garageband. Yes, there is some irony in writing a piece about cheap and free music software for a company that makes a $10k recording workstation, but I guess after spending that kind of money you'd be tempted to cut back elsewhere.

January 10, 2008

Rubber Factory

A little while back, David Byrne had a piece in Wired about the new digital landscape for musicians. He's now published some corrections based on feedback from musicians who say that you can't possibly make a record for nothing, as he claimed.

Well, it's true that he exaggerated, but I'm not sure that his correspondents aren't doing the same.

"While it's true that the laptop recording setup made self-produced recordings worlds easier than before, the simple truth is that laptops alone don't make records. First off, there is the peripheral equipment needed...microphones, stands, cables, pre-amps, sound cards, headphones, speakers, hard-drives, instruments, etc. And while the cost of the aforementioned has cascaded in the past decade, a complete and flexible home studio setup still comes at a price. Then, of course, there is the issue of know-how--recording skills and technique--two incredibly important factors in making a decent sounding recording, and two things that don't come "with the laptop". Lastly, there is mastering, currently hovering (at the low end scale) at around $750-$1,000. Even these moderate costs can make recording out of reach for many bands.

All tolled, in addition to the laptop, a band is looking at between $5,000 - $10,000 in extra costs just to have the ability to record themselves (I am talking about having enough equipment to record a four-piece band live with enough channels to mic a drum-kit). Yes, there are alternatives, rental being one of them. But, that still doesn't account for the skills and technique part of the equation. The only analogy that comes to me is, you can buy a cheap pair of scissors at every corner store, but that doesn't mean everyone (wants to or) should be out there cutting their own hair."

There are a couple of respectful objections I think should be raised: First, rock bands are not the end-all and be-all of home recording. Not everyone needs to simultaneously record a full drum kit with the rest of a four-piece. Not everyone even has a drummer. Many genres of music--techno, industrial, dance, hip-hop, and some of the weirder indie stuff--can easily be done using minimal hardware, recording one track at a time. Even rock and blues can be done on a shoestring: the Black Keys' Thickfreakness was recorded on a Tascam 8-track from the 80s in the drummer's basement, and Rubber Factory--which I told someone the other day is my pick for the top album of the decade--was done in an abandoned building. It's only the obsession with perfect clarity and the "processed" sound that says that you need to do things with lots of tracks and expensive equipment.

Second, the question of mastering seems to me like it's less urgent in these days of shuffled MP3s, and given the emphasis on digital distribution in Byrne's article. How much mastering do you need to put something online? I'm not the most experienced engineer, but I think you can do pretty well with an analyzer, a decent EQ plugin, and a limiter (Kjaerhaus gives away their old mastering limiter for free, and I've had good results from it). Most people just aren't listening to music that closely for it to matter whether you had it professionally mastered.

But there are good points to be made about the cost of equipment. I'm lucky enough to scratch my purchasing itch regularly, but most people--particularly many people who want to be "professional musicians" can't do that. So it occurs to me that although the last thing the world needs is a new social network, there should be a place for musicians to get together and pool their resources for playing and recording. If I own a laptop, and you own an interface, and she owns some drum mikes, and that guy over there owns a decent preamp, it only makes sense for everyone to help each other out. Add some reputation systems to the mix, and see what self-organizes.

October 30, 2007

The Groove

One can only hope that Wired's article on audiophiles choosing vinyl over digital formats is true. Not because vinyl actually offers a better sound. It doesn't: the noise floor is roughly 50dB higher than CDs, the high-end response is limited, the media itself tends to warp and erode, and the format is far larger than it needs to be. But at least this way, we'll have a more reliable sign of sound system gullibility. "Oh," you can say. "You've got a nice collection of vinyl. Excuse me, I have to go make up lame excuses for leaving this conversation."

Choice quotes from the piece:

Another reason for vinyl's sonic superiority is that no matter how high a sampling rate is, it can never contain all of the data present in an analog groove, Nyquist's theorem to the contrary.
I love that little jab at Nyquist. Because as I found while researching A/D converters last week, Claude Shannon's elaboration on Harry Nyquist's original paper means that a sampled analog recording does, in fact, contain every bit of information under the Nyquist limit. That's the whole point of the theorem--given a bandlimited signal, there is only one possible way to recreate it using the samples. Saying that digital "can never contain all of the data present in an analog groove" is not only hyperbolic, but it's also completely false.

This objection is often paired with the myth that people can somehow perceive frequency content beyond a CD's 22.05KHz Nyquist limit. And again, that's just bogus. The average adult's hearing flat-out stops at 16KHz, and above that it requires extremely high amplitudes for even the most sensitive ears. Considering the fact that modern digital recordings are probably captured and mixed at twice the sample rate of CD-quality audio (or higher), the whole argument is snake oil.

Golden-eared audiophiles have long testified to vinyl's warmer, richer sound.
Sure they have. They also buy $3,000/meter audio cables, so maybe we shouldn't be going by the word of these "golden-eared" listeners. It should be added, of course, that everyone claims to have near-magical hearing perception. At least one listening test, however, has shown that "expert" listeners actually vary wildly in their capabilities for detecting audio errors. There's no such thing as a naturally "golden" ear, in my opinion--merely people who have trained themselves to listen closely, or convinced themselves that they can hear the difference.
San Francisco indie band The Society of Rockets, for example, plans to release its next album strictly on vinyl and as MP3 files.

"Having just gone through the process of mastering our new album for digital and for vinyl, I can say it is completely amazing how different they really sound," said lead singer and guitarist Joshua Babcock in an e-mail interview. "The way the vinyl is so much better and warmer and more interesting to listen to is a wonder."

This could just be clumsy writing, but it sounds to me like he's comparing mastering for MP3 and vinyl--in which case, yes, I'm not surprised that it sounded good during mastering. How would the CD sound? How does it sound at home? How does it sound after 100 listens? And can we really consider people to be distinguishing listeners when, according to the Matador rep, they're enthusiastically pairing their vinyl purchases with MP3 downloads? I've come around some on MP3, but I don't think anyone has ever argued that it's a premium-quality format.

As far as I can tell, the point of all this vinyl frenzy (such as it is--Van Buskirk's evidence of a rebirth is far from conclusive) is the nostalgia of it all, not how the material actually sounds. The experience of putting a record onto a turntable, and hearing the inherent rumble and flaws of the medium, makes some people happy. It makes them feel like they're closer to an "authentic" experience. Just don't tell them that they could do the same thing with a plugin, or a cheap tube preamp with the tone turned down--in other words, don't explain that their authenticity is highly constructed and artificial. We wouldn't want to spoil their fun.

September 3, 2007

Musical Sketchpad, Session Twelve

Plenty More

Around 1996, the Squirrel Nut Zippers had a song on the radio from the album Hot, starting a tiny swing revival that lasted just long enough for high-schoolers to realize that swing music was really kind of a dorky fad. Hot sold a lot of records, but I don't think most people ever bought a copy of the previous album, The Inevitable. Which is unfortunate, because it was a dark, feverish little gem. I wrote a whole movie with it as a soundtrack in my head. "Plenty More" closed it out, and has long been a favorite of mine for its cynical swagger.

This is not a particularly original cover, nor is it flawlessly-executed. My copy of Sonar hasn't arrived for the new laptop yet, and so I recorded it on the Pro Tools rig at work, where the air-conditioning has been turned off all weekend. So I haven't cleaned up my terrible drumming or the other timing issues. But I've wanted to do at least a quick recording of this song ever since Something Awful called me a "a shakier, less confident version of John Flansburgh of They Might Be Giants (when he does his goofy lounge singer voice, no less)".

Yes, it's terribly cheesy. I have no taste in synths. Now go buy the original.

Future - Present - Past