Channels ▼
RSS

C/C++

Delivery Woes and Music Minus Whatever

Source Code Accompanies This Article. Download It Now.


Nov01: C Programming

Al is DDJ's senior contributing editor. He can be contacted at astevens@ddj.com.


This month, I'll correct some errors from a recent column, introduce a good Samaritan, discuss some programming issues related to a digital signal processing (DSP) audio problem, and take a look at the state of contemporary package delivery. That's real packages, not software distributions. As you will learn, overnight delivery services are learning a lot from us software developers about how to deliver things on time.

So You Think You Live in Modern Times

I've written many times about my sojourns in the DobbsMobile, the RV in which Judy and I travel the country — me in search of that next great story, Judy in search of that next great shopping experience. Often our travels take us beyond the reaches of those amenities that today's techno-generation takes for granted. Web access. E-mail. Cable TV. Plumbing. Oh yes, and overnight express package delivery.

Even though I'm on the road living the vagabond life, I still have professional responsibilities, such as writing this column. However, another part of my job is reviewing proofs of this magazine every month, which the editorial staff sends me in hard copy. "What about PDFs?" you say. Remember, where I travel there's often no Internet access. I make corrections and report them within the framework of a deadline. Time is tight, so we use FedEx delivery service. This procedure has always worked well no matter how far back in the boonies I am. Tom Hanks has nothing on me.

For whatever reasons, however, reliable old FedEx is out at DDJ World Headquarters, and Airborne Express, an upstart FedEx wanna-be that delivers my package of pages for five bucks less, is in. So when the pages DDJ's managing editor Deirdre Blake sent me last month didn't show up, she put in a trace. Airborne Express dutifully reported that the package had arrived in Allentown, Pennsylvania, and was being delivered. Allentown is only an hour and a half from where I was, and I could have fired up the DobbsMobile and gotten the package. But I trusted Airborne. After all, it was the carrier of choice, blessed and sanctified by DDJ's beancounters.

The next day when the package still didn't arrive, Deirdre wrapped up another package, put it in a FedEx pouch, and sent it to the mailroom. As it turns out, a conscientious mailroom person had observed Deirdre's blatant disregard of official company policy — that is, her use of FedEx — and dutifully corrected her error by redirecting my FedEx package to Airborne Express. A subsequent trace revealed that now both packages were in Allentown and supposedly en route to the boonies.

Time was a'wasting. So once again Deirdre bundled up a FedEx package, but this time, hand delivered it to a FedEx carrier. And bless my soul, the next day the familiar white truck with red and blue letters crossed the creek and rolled up through the pasture with my package, just in time. Another castaway saved from a dire fate.

And now, for the rest of the story. You guessed it, the following day, two Allentown packages arrived from Airborne Express — mailed from Allentown via the U.S. Postal Service. DDJ saved five bucks on each package.

Some Corrections I Didn't Make

In September, I compared Linus of Linux fame to Charles Schultz's "Peanuts" comic-strip character of the same name. I referred to him as the kid who plays Beethoven on the piano, which, of course is wrong. As everyone knows (at least everyone who reads this column, based on the e-mail I got), the piano-playing kid is Schroeder. Linus is the blanket-holding kid who believes in the Great Pumpkin. Over the years, I've made other errors, and readers have promptly written to correct them. Nothing like this one, though. If you ever feel like you're being ignored and neglected and no one is paying attention to you, say something stupid about some cultural icon who is known and loved throughout the world. Make sure your inbox has lots of room when you do, though. My Linus flub generated more e-mail than the SirCam virus.

Comeau and Kai C++ Compilers

Many of the Linus messages and a few others pointed out a more or less important error, depending on your priorities. I said that Linux C++ programmers have no choice other than gcc when it comes to compilers. That's not right either. I should have said, "free compilers." There are at least two commercial Linux C++ compilers. My old pal Greg Comeau includes a Linux compiler among his Comeau C++ compiler line (http://www.comeaucomputing.com/). Kai Software (http://www.kai.com/) also produces a C++ compiler for Linux. I have not tried either so I cannot comment on anything other than their availability. I used earlier versions of Comeau C++ on MS-DOS platforms and found them quite dependable. I mention these two compilers here to correct my error about the availability of Linux C++ compilers.

Music Minus Whatever

As many of you know, the combination of music and computers is one of my passions. I'm always in search of new tools that assist in practicing and performing music. When my needs exceed what is available, I develop the tools myself. My latest project is a teaching aid that lets students practice ensemble work in the virtual company of professional musicians.

For years, music students have practiced with "Music Minus One" (http://www.musicminusone.com/), a library of recordings wherein one instrument is omitted. The student plays the missing instrument along with the record, thus practicing ensemble work without needing other musicians in attendance. The downside to this approach is that there must be separate recordings for each instrument that can be eliminated.

More recently, jazz educator Jamie Abersol published a package of recordings for jazz studies. He recorded each tune with only a trio rhythm section playing accompaniments. The tunes are mostly be-bop, and the package includes books of printed music for C, Bb, and Eb instruments in both clefs accommodating players of most instruments. Cleverly, Abersol recorded the piano on one stereo channel, the bass on the other channel, and the drums on both. Bass players can slide the balance control to one side to eliminate the recorded bass, and piano players can slide the control to the other side. (I guess drummers don't practice, because there was no way to eliminate the recorded drum part.)

Next came Karaoke. Enough said.

Vocal Eliminators

Another technology is the so-called "vocal eliminator." In theory, if a recording consists of an orchestra or band distributed across the stereo spectrum with a soloist recorded in dead center, you can acoustically, electronically, or digitally eliminate the solo part of the audio, the so-called "center channel." The obvious advantage is that an amateur soloist can perform with lush and professional accompaniments without needing arrangements and a bunch of musicians. Imagine that. If you can remove Old Blue Eyes's voice from those old records and leave all the rest, you can have your own Count Basie or Nelson Riddle accompaniments to warble against in the privacy of your own shower.

You can test the center channel elimination theory by facing a stereo's two speakers toward one another and wiring one of them out of phase, which means reversing the wire connections from the amp to the speaker. Parts of the waveform that have equal frequencies and amplitude tend to cancel one another out unless you put something between the speakers. When the right speaker pushes, the left pulls, and vice versa, resulting in zero sound for those frequencies in the signal that are normally of equal amplitude.

You can do the same thing with a vocal eliminator circuit that results in a monaural signal. A kit for the circuit is available for $35.00 (http://www.paia.com/vocalzap.htm/). Radio Shack used to sell such a device for $50.00, but it is no longer listed as being available. A more expensive device (about $1700) is available at http://www.ltsound.com/. It has other features to account for the higher price. A Google.com search for "vocal eliminator" returns many other solutions, hardware and software.

Channel Elimination Software

You can, of course, do it yourself with software. ("At last. He's talking about software!") There's a Winamp (http://www.winamp.com/) plug-in that, among other effects, removes the center channel from a stereo waveform in real time. If you want to do it yourself and see the process graphically, use a multitrack audio processing program such as CoolEdit (http://www.syntrillium.com/). Load the two-channel signal into the application. Make copies of both channels. Invert the copies so that each sample is itself times -1. This operation emulates putting the channel out of phase. (CoolEdit includes an Invert command.) Mix the inverted copy of each channel into the opposite channel's original (Paste Mix on the Edit menu). These operations emulate adding out-of-phase signals to their corresponding signals in the opposite channels. Delete the inverted copies and playback the stereo waveform that remains.

Another way is to get the source code to a sound player program. I use the player program included with DDJ contributing editor Tim Kientzle's book A Programmer's Guide to Sound (Addison-Wesley, 1998). Find the place where the stereo samples are read into memory to be played. Stereo samples are adjacent in sound files. Example 1 approximates what you do to generate a signal with the center channel removed for a 16-bit stereo file recorded with traditional recording technology.

A word about downloaded source code. I use Tim's code from his book's CD-ROM because it works, it's well organized, and I know how to use it. Its only drawback is that it doesn't support MP3 compression. I've downloaded many open-source MP3 playback programs. I look for ones that have Win32 versions because any product that results from this research must necessarily run on that platform. So far, none of them even compile under Win32, much less work. Eventually, I'll need the source code to an MP3 player. Most likely I'll port a well-behaved *nix program, several of which I have found, to Win32.

I built a simple Winamp plug-in (available electronically; see "Resource Center," page 5) to test my theories. You can download the source code for an example DSP plug-in from http://www.winamp.com/nsdn/winamp2x/dev/plugins/dsp.jhtml. I was able to understand the Winamp plug-in SDK just by reading the code.

But Does It Really Shut Madonna Up?

The effect of the center-channel removal operation varies depending on how the audio was recorded. Usually what you get is the loudest part of the vocal removed with ghostly echoing remnants remaining. Vocals are seldom recorded at absolute dead center; digitally remastered analog recordings (from the old days) are particularly bothersome. Some of the more expensive (as in "not free") hardware and software include adjustments that let you pan for the vocal channel from side to side. Even if you find the center, recording engineers usually add reverberation to the vocal track to make the singer sound better, distributing the reverberating echoes across the stereo spectrum. Those echoes are residue in audio that has the center channel removed.

Music Minus Whatever as a Teaching Aid

What good is all this unless you are really into Karaoke? Not much until you consider the Music Minus One paradigm and its attendant problems. Suppose you could deliver the basic repertoire of a typical musical ensemble genre on one CD-ROM. Suppose you could let the student dial-in any of the instruments to eliminate for a practice session. Thus for a chamber music string quartet, the cello student removes the cello channel from the signal and practices away, blending in with the best that professional players have to offer. A slide trombone player can dial-out the trombone player in a dixieland band and learn all those tunes with the funny names that your grandmother did the shimmy to.

Add the ability to display and print sheet music, run loops on selected passages, and other teaching aids, and your product becomes a full-featured multimedia teaching tool. You need to publish only one version of the recorded medium. You could produce Music Minus Whatever CD-ROMs for any genre that involves ensemble playing and a relatively small number — six or fewer — in the ensemble: dixieland, mainstream jazz, blues, bluegrass, chamber music, brass choirs, woodwind ensembles, barbershop and gospel quartets, and so on.

But how is this possible? How can you represent up to six channels in a two-channel stereo signal? You can't or at least I haven't figured out how, but you can represent three. If the center channel is recorded absolutely dead center, its frequencies are at the exact same amplitude in both channels. To achieve that in the studio, record the soloist into a mono channel with no residual sounds from the rest of the band. Mix that mono channel equally into the two stereo channels of the performance. A home studio with Cakewalk or CoolEdit, a set of headphones, and a decent microphone can do this with no trouble at all. Example 1 completely removes the center channel from a stereo recording with a perfectly balanced center channel.

That takes care of the center channel and whatever instrument happens to occupy it. What about the other instruments? Simple. A second instrument is recorded only in the left channel and a third only in the right. Just as with the center channel, record each instrument as a mono channel with no residual sound from the other instruments. Then mix it into its assigned right or left channel. To eliminate one of the right or left instruments from the playback, use Example 2.

To represent from four to six instruments, add a file. You then need a playback program that can read and mix two files. I haven't gotten that far yet. The six-instrument limit is reasonable and covers many ensemble formats. More than that and it's not reasonable to eliminate only one instrument. Who cares if you can or cannot hear the third trumpet in a big band trumpet section?

I'm still experimenting with this technique, but so far, it looks promising. By converting the files to MP3, the size of each tune decreases substantially. Sufficient space exists on a CD-ROM to record the basic repertoire of many musical genres with room left over for the playback software and some lesson software, too.

Is This a Great Idea or What?

If my experiments are successful and the technique works, it begs the question: Since this solution is obvious and since it addresses an age-old music education problem, why hasn't anyone done it? If they have, why haven't I heard of it?

Perhaps economics was a factor. Would it sell? I don't know. I'd buy one. The cost of professional recording studio time can be prohibitive, but advances in digital hardware and software on the desktop minimize such costs. Marketing and distribution costs can be offset by an effective e-commerce approach, assuming anyone ever figures out how to make that work.

Of course, you still have to pay the musicians.

There might have been technical prohibitions in addition to the costs. Real-time DSP has not been feasible on the desktop until recently. MP3 compression is relatively new, too. Perhaps this is an idea who's time has only recently come.

But there's another possible reason this technique has not been explored. I'm neither a DSP expert nor an acoustic engineer. Just a plain old country programmer. My theory is founded in naiveté; I don't already know you can't do it. My lab experiments so far use simple audio files — me talking into a cheap computer microphone saying, "Left channel, left channel," and so on. I have not progressed to using real musicians. Maybe it will just sound crappy. I'll let you know.

The Good Samaritan and the IRS

You've heard about the "kinder, gentler" IRS. Skeptics may scoff, but it's true. Here's my story to prove it. There is a form (5500 and 5500EZ) that people with SEPs send in every year. There's no money involved, just information. The form must be filed by July 31. If you're late, the penalty is a whopping 25 bucks a day. They really want that information. Two years ago I sent it in at the beginning of October. Really late. It was an oversight caused by a lot of stuff going on and an advanced case of CRS. When the IRS notified me of my transgression and the likelihood of a $1700-plus fine, I sent them a letter explaining my exigent circumstances and throwing myself on their mercy. Apparently they forgave me because I heard no more about it. Kinder and gentler, I calls it.

This year I was motoring up I-95 along about the end of July when I realized I left the form in Florida. Not to worry, the IRS posts all its forms on the Internet. Stopping at a local library in Virginia, I logged onto http://www.irs.gov/ and found that the online version of this form is for information only and not to be filed. You have to file an original. I called the IRS's forms delivery 800 number. (Hint: Respond as if you have a rotary dial phone. It's the only way to talk to a live person.) They could get the form to me in 10 days. I had only about two. All of a sudden, kinder and gentler becomes rougher and tougher. The only form with such a stiff penalty is also the one you can't get when you need it. Would they buy another sob story from me? No way. The IRS guy at the 800 number agreed — I cashed in that chip two years ago. He suggested I call a local CPA. What a great idea! I flipped open the Yellow Pages, picked a CPA within an easy drive, and called him. Not only did he have the form, he took the information from me and when I got to his office, it was filled out and ready to sign. He even put postage on the envelope for me with his postage meter.

I asked this kind fellow what I could do for him in return. Nothing, he said, maybe refer me to some of my friends in Florida. Turns out he offers services to clients around the country. Well, he doesn't know it yet, but I can refer him to tens of thousands of friends around the world who read this column. His name is Joseph Wheeler, his office is in Fairfax, Virginia, and his web site is http://www.josephwheelercpa.com/. If you need some numbers crunched, give Joe a holler. Tell him Al sent you.

DDJ


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.
 

Video