Saturday, January 18, 2014

Is 16 Bits at 44.1 KHz Enough?

Is 16 bits at 44.1 Khz enough? Yes, if...

Spectral cleanup with dither
If you're just listening, and if the source material is properly dithered, and properly mastered, 16 bits at 44.1 KHz is good enough. Decades of double-blind testing have proved it time and again. But that's a big if.

There are a number of things that will affect the sound quality and the need for more bits and more samples. The modern CD loudness wars, which compress, limit and clip the audio into a quivering mass of Velveeta would get by with 8 bits and practically nobody would notice. A well-mastered and well-engineered CD at 16 bits and 44.1 KHz sample rate can sound fantastic. A poorly-mastered and poorly-engineered one will sound like crap.

Are there ever times when more than 16 bits and 44.1 KHz sampling would be better? Yes. In a recording environment, where the incoming live sound is unpredictable, it's better to leave some headroom for unexpected, accidental peaks. If you're using all 16 bits, and a louder peak comes along, it will overload the A/D converter. Eight additional bits provide 48 dB of additional headroom, which is itself more than the dynamic range of the vast majority of commercial CDs being sold today - especially the loudness war victims.

In addition, when mixing tracks, each additional track adds about 6 dB to the sum (assuming each track is mixed at full scale - a worst-case scenario). Mixing eight tracks will consume all 8 additional bits of headroom. To avoid overload, recording additional tracks means the level of all tracks will have to be attenuated in the mix. If they're 24 bit tracks, they can be turned down without any loss of resolution (they do have to be re-dithered however - in fact, audio should always be re-dithered when it is re-scaled - up or down).

For live recording and mixing, you can do better with 24 or even 32 bits (Audacity uses 32-bit floating point by default). But for commercial distribution via e.g., CD, 16 bits really is enough. Trust me on this.

So, what about sample rate? Well, that's much less important with modern oversampling sigma-delta A/D and D/A converters. Humans can hear at best, out to 20 KHz. Most of us are lucky if we can hear 15 or 16 KHz, although it really depends on how loud the signal is. I suspect more humans could hear 20 KHz if it's loud enough. For music, there just isn't much significant energy above 15 KHz. A sample rate of 44.1 KHz means that the digital recording system can accurately capture up to a maximum of 22.05 KHz: more than most anyone can possibly hear in a musical setting. The Nyquist Shannon sampling theorem tells us that we absolutely, positively need not sample more than twice the highest frequency of interest. This is not speculation; it is one of the most well-validated results in the field of information theory.

Aliasing

In order to prevent ultrasonic frequencies, above 22.05 KHz, from getting into the A/D converter and getting aliased back down into the audio frequencies, the input should ideally be filtered. As a practical matter, the filtering requirement on A/D converters is fairly weak, because most music doesn't contain a lot of energy at or above 20 KHz, and certainly not far enough above to be aliased down to frequencies that we hear readily. Still, most good A/D converters do provide high quality "brick wall" anti-aliasing filters. It is very difficult to build analog brick wall filters, but modern (i.e., since about 1995) oversampling sigma-delta converters can do this using digital filters with mathematical precision. They hypersample internally, but they output e.g., 44.1 KHz or whatever the desired sample rate is.

The filter function is different for D/A converters, but the requirements are about the same. The output filters are used to remove the ultrasonic sidebands that are generated by the sampling process. Although we can't hear them, those ultrasonic frequencies can wreak havoc with amplifiers and tweeters, and they need to be removed. It is probably sufficient to merely attenuate the ultrasonic sidebands with a softer roll-off that won't over stress downstream equipment. But modern (i.e., since about 1995) oversampling sigma-delta converters can provide digital "brick wall" reconstruction filters with mathematical precision.

Back when ADCs and DACs ran at the nominal sample rate, we had to filter using analog elliptical filters, and I could justify a bit of "slack" between the stop band and the sample frequency. It reduced the constraints on the analog filter, which were critical and hard to keep in spec. In those days, sample rates of 48 or 50 KHz were common. But for today's oversampling sigma-delta ADCs and DACs with their built-in digital filters, any sample rate above 44.1 KHz is simply an outdated concept.

Do we need to sample at 96 KHz? Certainly not! It doesn't make the filtering job any easier. All you're adding is more load on the CPU and wasting storage space. If you can't hear 20 KHz, you're never going to hear 48 KHz, or anything in between. And 192 KHz? That's four times higher than 44.1 KHz! If you can't hear 20 KHz, neither you or your dog are going to hear 96 KHz. Why on earth store all that inaudible chaff? It's processor abuse!

Monday, January 13, 2014

WxService Stops Responding After Approx 17 Hours

I noticed recently that WxService would stop responding after a WxMonitor client was connected for about 17 hours (or half that with two WxMonitor clients, etc.). It turns out that StAX XMLInputFactory cannot create more than 64000 readers in JDK 1.7.0_45. In other words, WxService can only respond to 64,000 update requests until the XML parser stops responding. At one request per second, a single WxMonitor makes about that many requests in about 17 hours. Fortunately, there is a work-around that should hold us until Oracle produces a fix for this problem.

Using Notepad or other simple text editor, create a a file containing the following text:
#Hack for JAXP00010001 error.
jdk.xml.entityExpansionLimit=0
and save it as C:Program Files/Java/jre7/lib/jaxp.properties (that is, place the file jaxp.properties in $JAVA_HOME/jre/lib).

I will publish an update when this is no longer a problem.

Update: The latest WxService includes a code change that uses a different thread pool implementation that seems more compatible with JAX-WS. By "more compatible", I mean "the one it uses internally by default". There were some features that I liked with the one I had been using, but locking up wasn't one of them, so there you go. If you're experiencing lockups, download the latest version

Friday, December 6, 2013

Microsoft Ends Windows 7 Retail Sales



Microsoft quietly announced that it officially ceased sales of Windows 7. This is the first time I am actually sad to see a previous version of Windows come to an end. Windows 7 has been my favorite incarnation of the popular OS to date. I have called it "Vista, done right". With Windows 7, Microsoft solved a number of nagging problems from earlier versions, including performance, security, usability, and so on.

Originally, I was anxious to know what Windows 8 would bring. But not anymore. Windows 8 is a huge regression, in my humble opinion. I have been using Windows 8, side-by-side with Windows 7 on various machines. I still stand by my assessment that Windows 8 is a usability disaster; a schizophrenic OS that does a poor job as a tablet interface and as a desktop interface, and forces users to switch between vastly different UIs to accomplish tasks on the same platform. It's just dreadful.

I write software for a living, so I feel that I have some knowledge of which I speak. I'm sorry to see Win7 die, and I hope Microsoft can see fit to give Windows 8 some much needed treatment for its schizophrenia.

Wednesday, November 6, 2013

High Fidelity Hobby Becomes Necessity

I have been an audiophile all my semi-adult life, getting into it in a big way while I was in high school. I just bought the most sophisticated sound system that I have ever owned: a Phonak Audeo Q90-312 system. That's right, they're deaf-aids. I have been struggling with hearing loss for about a decade, and I finally got fed up with not hearing offhand remarks in meetings, and asking people to repeat themselves. My music enjoyment was never affected much, if I turned it up loud enough. But my family objected to that.

I resisted getting hearing aids because I figured the fidelity would be low; optimized for speech intelligibility over fidelity. I had already decided what I wanted: Something like the Dolby S encoder for cassette tape. And it had to be high fidelity, wide band and low distortion.

The Dolby S encoder is essentially a multi-band, equalized compressor, whose job it is to keep low-level signals above the tape hiss, backing off once the input signal gets above the noise level. In my case, the noise is tinnitus - ringing in the ear. For me, it's like narrow band pink noise, centered on about 4 kHz. Sounds need to be louder than that, in that spectral region, in order for me to hear them.

One of the features I like about Dolby S is that the design was based on the principle of least action (Ray Dolby borrowed the term from physics, but it makes sense in a different way, in this context too). As the signal gets above the noise, further expansion isn't necessary, so Dolby S gets out of the way, and lets the system behave normally. Of course, my hearing is compromised, so while the encoder (hearing aid) brings the signal up above the ringing in my ears, there is no corresponding decoder to undo the encoding. Or is there? As a matter of fact, there is: my brain! I'll get back to that.

Hearing Impaired Musician
I started researching hearing aid technology, asking in particular, what do hearing impaired musicians use? Well, they use high-fidelity, WDRC-TILL (wideband dynamic range compression with treble increase at low levels) devices (or they did a decade or so ago). So, armed with this information, I sallied forth to my local audiologist, and told her that I'm her worst nightmare: a well-informed electronics buff, critical listener and opinionated & demanding audiophile. That news didn't seem to upset her in the least.

She took me back to the soundproof room and we did a hearing test. She keyed the data into her desktop computer, which displayed my hearing chart and calculated the necessary correction. We discussed various models of deaf-aids, and I explained that I would require the highest possible fidelity, and that I was very skeptical that anything could meet my requirements. She finally selected a sample and put them in my ears. She then radioed the prescription to the devices, configured them with the necessary gain, equalization and compression (in 20 bands). I could instantly hear better, and they sounded great (w00t)!

These devices have FM transceivers, so they can communicate with each other, and with a Bluetooth ComPilot that I can wear around my neck if I want to use my cell phone hands-free, or listen to a TV or iPod through my deaf-aids. In normal operation, they radio audio information left and right, to continuously triangulate on stereophonic directional cues, just as our brains do. So they can classify noise sources, as well as speech sources, that the digital signal processor on each ear can then sort out in real time. It's quite amazing, and all that in a package that is so small that the casual observer cannot even see I'm wearing unless I point them out.

The electronics (7/8" long) tuck behind each ear, and the tiny loudspeakers, pictured above right, on the other end of the wire, go in each ear canal. They have excellent fidelity - at least for frequencies above 300 Hz or so. Below 300 Hz, where I don't require any assistance anyway, the direct sound just goes right past them. They're driven by a super high-efficiency class-D amplifier, so battery life is about six or seven days (if I turn the devices off at night when I'm not using them). Batteries are mercury free air-zinc type 312.

For the first two weeks, I was delighted that I could understand speech so much better, even in noisy restaurants, and in conferences at work. But I did notice some distracting artifacts: the stereo image seemed to move around, and I noticed a strange "warble", kind of like the sound I would hear when I was a kid, and my brother and I would talk to each other through a rotating fan. Some people describe the sound as being like talking in a corrugated pipe.

The first artifact was undoubtedly due to the devices trying to make voices more intelligible, by changing their directional characteristics. It's great for speech, but for music, not so much. The second artifact, I found after doing a bit of research on the web, is probably caused by the anti-feedback algorithm being set too high. This chipset (code named Spice) has a characteristic sound when feedback cancellation kicks in.

So when I went in for my initial two-week tune-up and oil change, I told the audiologist that I need a "stable platform" for music; I described the warble, and what I had found on the web. She pulled up the configuration software, and I was pleased to see, there was a "music" program right on the menu. So she added it to my configuration options. When I listen to music, I can push the button behind my ear to select the music mode.

The audiologist also noted that anti-feedback was set rather high. She turned it off, and we experimented with various feedback-inducing scenarios, none of which set them off, so we disabled anti-feedback, and the warble is gone. My hearing loss probably doesn't require enough gain to risk feedback. That could change if my hearing continues to decline, but for now it isn't a problem.

When I first started wearing the devices, it was like having new glasses: everything sounded freakishly clear, and I noticed details that I hadn't heard in years. This is like listening to a Dolby S-encoded cassette without the decoder turned on, only more so. But after a while I became accustomed to the sound, until now it just sounds natural - except that I can understand speech and hear soft music. My brain has adapted and provides the necessary decoding.

The fidelity is spectacular - and I'm speaking as an audiophile now. I can listen to music and enjoy it more, and the hearing aids only enhance the experience - they don't get in the way, as I feared they might. Low-volume live music is audible and enjoyable again. I have noticed zero distortion or overload with loud music, and no compression artifacts with sudden dynamic changes. My family appreciates that I don't have to turn up my sound system or the TV to deafening levels. Now I wonder why I waited so long to do this.

Saturday, October 19, 2013

Confessions of a Frustrated Audiophile

Magnavox Portable Stereo Record Player
I have been an audiophile ever since my Grandfather gave me a homemade cabinet containing an Electro-Voice SP12B speaker with an Atlas horn tweeter. At the time (1970), I had a portable Magnavox stereo.

I think the Magnavox had about 3 watts per channel into those 3x6 oval speakers shown in back. Well, I found some RCA plugs and just paralleled the outputs together and hooked them to my Grandfather's single mono speaker (not recommended for audiophile work). But it worked, and the amplifier didn't seem to mind. The sound blew me away. The high end and the low end were like I had never heard before, even from the "hi fi" my parents had in the living room. I was hooked.

The next task was getting back to stereo. So I hunted down a source of EV SP12B speakers. Unfortunately, the one my Grandfather gave me was from the late '50s, and the new ones were of a slightly different design. No matter. I only had $50.00, so I could only afford one. I built some cabinets from a project in Popular Electronics (I think it was), that used some mail-order tweeters from Mouser Electronics. The cabinets were designed for some Radio Shack woofers, but the specs were similar enough to the EVs that I decided to go ahead. I finished building the cabinets, and now I had full range stereo. At 3 WPC. With a ceramic cartridge. Still, I remember it sounded great! I got a lot of enjoyment playing Nilsson Schmilsson, Abbey Road, Ram, Straight Up, The Best of the Guess Who, and ... and I think that was the extent of my record collection then. I had some singles, Joy to the World, American Pie, Albert Flasher, a few others.

BSR 610 Automatic Record Changer
I started reading Stereo Review, and from there I realized that I would need a magnetic cartridge. Also, I started to notice thumps and rumble coming from the record changer in the little Magnavox. Plus, I wished it could play a little louder. My fascination with electronics had led me to get on the Heathkit mailing list, and they always had the most beautiful audio gear (for the time). It was time for an upgrade (such as my meager income could afford). So I bought a Heathkit AA-1214 amplifier and a BSR 610 record changer (with a Shure M71 cartridge). I eventually got matching woofers and purchased EV "building block" midrange horns, tweeters and crossovers.

BIC 980 Belt Drive Turntable
The BSR turntable also had thumps and rumble, so eventually I upgraded it to a BIC 980 with a Shure V15 Type III (I was making more money by then). I used the BIC until about 1984, when CDs started coming out. I bought a Magnavox 4X oversampling CD player (which was actually a Philips, which contained very good electronics and converters). In those days, it was nearly impossible to build a 16 bit D/A converter that was actually accurate to 16 bits. But Philips made 14-bit oversampling converters. The 4X oversampling produced the additional 2 bits by duty cycle modulating bit 0 of the 14-bit converter for 16-bit accurate output. It was ingenious, and it sounded great. So much so, that I started to wish I had a better turntable. Which brings me to the subject of this article. (That's the longest intro I ever wrote).

Dual 505-2 Belt Drive Turntable
Here's my confession: I love my Dual 505-2 turntable! I think it cost me about $300.00 in the day. The salesman talked me into a Denon high-output moving coil cartridge. Moving coils were all the rage in those days. But the Denon never sounded great to me. For one thing, my Heathkit AA-1214 had kind of a noisy phono preamp, and even though the Denon was "high output" for a MC design, it was lower than any moving magnet cartridge. So I purchased an Ortofon OM-20, which is one of the highest output moving magnet cartridges out there. I was kind of a Shure bigot, though. I only went with Ortofon because of the high output, and I had read that Ortofon and Dual had teamed up to match the 505-2 tonearm with the OM-20.

Ortofon OM-20 Phono Pickup
When the cartridge arrived in the mail, I hooked that baby up, and put on my Mobile Fidelity copy of Abbey Road. Wow! I was hooked. That was about 1986. My vinyl collection didn't get as much use in the CD era, or in the MP3 era, for that matter. But what I didn't have in digital format, I have played on vinyl. Over the past few weeks, I have been spinning a lot of vinyl, and really enjoying it, on a turntable and cartridge that is now 27 years old. The OM-20 stylus is still in good shape (I used to replace my old Shure stilii every year or two - don't ask me why the Ortofon has stood up so well). Fortunately, OM-20 replacements are still being made.

Here's the bottom line: Audiophiles and vinylphiles are quick to poo-poo any turntable that costs less than $1000.00, and is built with anything less than unobtanium parts and magical wire, broken in for three months. Well, the fact is, that old Dual is still kicking (after a belt replacement and a few other maintenance repairs), and it is capable of producing sound that is as good as can be stored on vinyl. A 50-lb platter just doesn't turn any more evenly or quietly than a well-engineered lighter one.

Thorens TD 235 Semi-Automatic Turntable
And here's a really interesting tidbit. I was looking at Thorens* turntables with the thought of updating (just because). Guess what I found? One of the midrange Thorens turntables is a dead ringer for the Dual 505-2, and I'm not just a-woofin'. Check it out: The tonearm is identical (right down to the gimbals and headshell), and the semi-automatic operation is as well. The plinth as been redesigned slightly (possibly for easier manufacture), but the look is nearly identical. MSRP: $1000.00 US.

I might buy the Thorens TD 235 someday, but for now, I still love my Dual 505-2 and that sweet sounding Ortofon OM-20. As long as I can still get parts.

* Thorens makes very high-end turntables for the rarefied audiophile community.

Friday, October 4, 2013

WxService Update Available

WxMonitor ow4j130929

  • Modified the Wind Vector to show the wind direction in blue when the average wind speed is zero. The reason for this is that when there is no wind, the wind direction is meaningless. The wind vane will be pointing somewhere, but the direction is completely arbitrary. What's more, without the wind and its turbulence to buffet the wind vane and dither the data, the displayed direction will only be precise to the nearest compass point. When the average wind picks up above zero, the indicator turns red to indicate active status. 

Saturday, September 21, 2013

Going Down! (For Maintenance)

I will be taking the weather station offline for a short time while I upgrade my weather server computer. I hope that this interruption will be brief (less than a day).

Update: We're back!