Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

C/C++

Open Source, Open Mike


Sep99: C Programming

Al is a DDJ contributing editor. He can be contacted at [email protected].


Recently, I made a trip to Amsterdam to talk to a small software company about a new product, a multimedia application C++ class library. I'll talk more about the project later, but first I'll talk about the trip itself. Traveling is a drag. It took two extra days to get there because airlines seem to be a little more cavalier about overbooking and canceling flights than they used to or ought to be. I was all over the east coast of the U.S. getting from Orlando to Amsterdam, and I reached Europe a day and a half late after spending most of my time in those uncomfortable waiting lounge seats and those equally uncomfortable center seats in coach class between two other large travelers. If you travel overseas these days, you are well-advised to take a thick book to occupy your time, wear comfortable shoes for trudging between airlines and distant gates, and use carry-on luggage (so that your necessary items are available in case of routing changes and arrive at your destination when and if you do).

I saw on the news recently that Congress is working on an air traveler's bill of rights to force the airlines to improve their passenger service. Can't come too soon for me. Getting there is definitely not any part of the fun.

But it was worth it. This was my first visit to Amsterdam, and I was delighted with the city and its people. Amsterdam is a city of wide canals and narrow streets. Each canal has a one-lane, one-way street on either side. The crossing streets are two-way and have small bridges over the canals. Some streets have parking spaces and others do not. Usually, all the parking spaces are occupied during the day as in most cities. There are plenty of cars, but most of the people I met travel by foot or bicycle. While there, I stayed in a small hotel near the office and walked everywhere. The weather was perfect, which, I am told, is unusual for that time of year. A walk through Amsterdam is a pleasure any time of the day. Old buildings, canals, barges, tour boats with gondoliers, quaint trolley cars, shops, restaurants, lots of trees. I don't think you can point a camera in Amsterdam and not get a postcard-quality picture.

A testament to the patience of the Dutch people is when a car needs to stop briefly at a house or a delivery truck is loading or unloading on one of those narrow, one-way streets. They just stop where they need to be and block passage. Eventually other cars will turn onto the street. It is not always obvious when they do that they can't make it through, particularly if there are bends in the street. But do they honk, yell, and display rude displeasure at the inconvenience? No, they simply pull behind the blocking vehicle and wait patiently. Or, they throw it in reverse, back up to the intersection and try another route. Imagine that kind of patience in, say, Los Angeles.

People are not really mindful of one-way streets, either. If avoiding one would put you out of your way and there is no traffic coming, it seems to be okay to just go the wrong way. If you encounter another car, one of you backs up, usually the one closest to an intersection and not always the direction offender. In the U.S., road rage would set in and you'd get shot off the road.

The lady who picked me up at the airport skillfully negotiated her little hatch-back through a maze of narrow streets from the airport to the center of the city. She said that getting a driver's license in Holland involves a considerable training program, a difficult written examination, and a grueling driving test that takes the better part of a day. Many people need several tries to pass. I didn't put that much time and effort into getting a pilot's license here in the States.

If you like handsome men and stunning women, go to Amsterdam. A young woman that I met in a bar bore a strong resemblance to the beautiful young Ingrid Bergman as she looked in Casablanca. And she was about average. If you are short like me (5'7") and uncomfortable where everyone else is tall, go elsewhere. The NBA should send scouts to Holland. Dutch is the native language but everyone speaks English and is delighted at the opportunity to practice it. Try finding such an attitude in France. Or Miami.

If you go to Amsterdam, don't ask about drugs. It greatly troubles the Dutch people that most foreigners comment on the city's reputation for looking the other way at the over-the-bar availability of pot, hash, and other illegal substances. I don't remember making such a comment, but several people there expressed dismay that their beautiful city is best known in other parts of the world for tolerating various forms of vice. When I got home, at least three people asked if I saw, not the dikes, the windmills, the tulips, the wooden shoes, the Queen's palace, or the Anne Frank house, but the red-light district, thus verifying the Dutch people's worst fear -- not that I might visit the seedier side of town, but that folks elsewhere would expect the night life, drugs, and ladies of the evening to be foremost among Amsterdam's tourist attractions.

The only night life I saw was when my hosts took me to a tiny, dark local tavern for lots of Dutch beer and good company. That's where I met Ingrid Bergman. There was an old, rickety upright piano off in a corner. The piano had known better years and seemed mostly neglected now. My new friends asked me to play for them, and I did. No one requested "As Time Goes By," though.

And for the record, no, I did not visit the red-light district. It wasn't within walking distance, and Ingrid did not offer me the use of her bicycle.

Open Source

The product that the Amsterdam company is about to launch is a C++ class library that supports the development of multimedia applications with a platform-independent interface. I saw demos of applications that have been developed with the library and learned as much as I could about it in the short time we had. The company's primary business has been the development of multimedia products, CD-ROMs, and web sites, and it originally developed the library as a tool for their own use. Recently, it began to think about turning the library into a product for other developers. And they are considering its distribution under what has come to be known as the "Open Source" license. This issue led me to the subject of open source and gave me cause to wonder. "What is it all about?"

"Where have you been?" you might ask. Well, not exactly in a cave. I do know that Open Source is the name for the practice wherein a purveyor of software makes the source code openly available to the users of that software and to the developer community at large. Open Source is a moniker that the vendor may use if the software license adheres to the conditions of the Open Source Definition. Linux is the Open Source poster child and the model that, according to the experts, proves the theory, which maintains that the more programmers who look at a program's source code, the fewer bugs the program will have. Users and modifiers of software acquired under an open source license are required to perpetuate the idea by making their source code available, too.

Open source code (as opposed to Open Source) is not a new concept to me. For years, I have been distributing free source code with most of the programs I write -- except that there are no strings attached. In my view, truly free source code is truly free only when no conditions constrain the users of the source code. There are two meanings for the word "free" when you talk about free software. One meaning has to do with what you pay for it. The other has to do with what you are free to do with it. My software is free in both respects. If you take source code from this column and integrate it into a project that makes a million bucks for you, I am happy. It is reward enough to have been of use to you as a constituent of the column and the magazine. It's my job. I get paid to give away source code. Not everybody has a magazine column, however.

Not being an expert on Open Source, I won't try to explain it. There are plenty of discussions of it on the Web and lots of people who understand its implications far better than I. Its formal definition can be found at http://www.opensource.org/osd .html. What I will do is voice the questions that arise when its proponents suggest that Open Source should be used for some particular venture, the questions that people such as my friends in Amsterdam ask themselves when they consider whether to enter the Open Source community.

I am not voicing opposition to the concept of Open Source software. Quite the contrary, I am very much in favor of it. I just don't understand how companies who want to sell software can succeed with Open Source and so I ask these questions.

Actually, there is only one question...

"Show Me the Money"

Where is the money? If you are in the business of selling software, where is the profit in giving it away? The Open Source people argue that your gain is twofold; first, in the enhanced reliability of your code because the world of programmers at large are looking at it; and second, in the free availability of the software that all the other participants make available to one another.

Any code is bound to benefit from close scrutiny by more programmers, assuming that a manageable mechanism exists to receive, review, and incorporate or reject the changes they suggest. But where is the money? If you are in the business of selling software, you need revenue. You can carry all the lines of reliable free source code you want to the bank, and they will not exchange the code for anything negotiable that you can use to make the payroll, pay the rent, and reward your investors. Merchants are not interested either. The complete body of source code for Word, for example, would not get you one can of beans at the local Piggly Wiggly or one cup of coffee at Starbucks.

If we learned anything during the 20th century, it is that the concept of "from each according to his ability, to each according to his needs" does not work for many reasons. One is that excellence is granted the same rewards as mediocrity, so there is no incentive to excel. Another is that since free enterprise has to be suppressed by law, personal liberties are severely curtailed. So, in a free society, how can Open Source prevail if entrepreneurs are free to take advantage of free software without joining the movement and contributing to the pool of free software?

I am reminded of the movie wherein two '60s dropouts return from a self-imposed exile in the jungle after 30 years to view the world of the '90s. When someone explains that a tanning salon is a place that charges people to get sun tans, one of the two, played by Cheech Marin, asks how they keep everyone else from going out in the sun? I wonder, too. How do you keep those who do not contribute to Open Source from taking and using the free source code?

Suggest to Bill Gates that he make the source code to the latest version of Word openly available and his likely response will be, "I do that on Monday, and Tuesday my sales of Word drop to zero." Suggest further that he, therefore, should in all fairness decline to partake of the bounty of free source code that Open Source makes available. We can only guess at the response. To qualify as an Open Source license, you must make the source code available to those who purchase your product. Those who get the source code are permitted to modify it, compile it, and sell or give away the binaries. Where is the money?

Does anyone really believe that Netscape would be an Open Source product if its main competition was not bundled with the operating system?

Given that we acknowledge the advantages of all those programmers reviewing the source code, consider the other side. If you make your source code openly available, do you not empower your competition by revealing the fruits of your research (which is not free and does not come easily)? Is that smart? Do you not give to your customers that which you intended to sell to them? Where is the money?

Several years ago, I sent a query to the Free Software Foundation asking for clarification on my responsibilities for distributing the GNU C++ compiler binaries and libraries on a diskette with a C++ book. The GNU Public License (GPL), which predates Open Source, conforms to and was the inspiration for Open Source. Instead of getting answers to my questions, I got a fund-raising call from Richard Stallman, who urged me to support his work by making the publisher add $3 to the cost of the book and pass the money on to the foundation. Apparently, free software itself cannot survive without revenue.

In a presentation on DDJ's TechNetcast (http://www.ddj.com/technetcast/), John Ousterhout, the creator of Tcl, makes some interesting observations about Open Source, under which Tcl is being released. When it comes to compensation for the effort, he observes that "Most developers aren't in it for the money," implying that there is a community of hobbyist programmers who have day jobs and hack away at open source software in their spare time. Volunteers. They do it because they want to and for no compensation. He goes on to point out that Open Source is "almost exclusively used for tools that developers want," rather than for end-user applications, and that the Open Source development process "doesn't meet the needs of less sophisticated users," because it typically is under-documented, needs to be downloaded and compiled by those who know how to do that, and offers virtually no technical support. He also admits that some Open Source evangelists (my word, not his) openly disagree with him on these points.

Where is the money? Ousterhout suggests that if there is revenue to be made from Open Source software, perhaps it is found in producing and selling that which is missing -- books, training materials, extensions and enhancements, tools to augment the product, support. This is an interesting business model. Give away what most users can't use and don't want anyway, but sell to those who can use it the add-on stuff that they cannot do without. Talk about a better mousetrap...

"We'll Always Have Paris"

This month's project is named Storch after a guy I met only once, but whose talent has always impressed me. Bear with me while I provide some background.

Years ago, I worked for the government. The agency, which shall remain nameless, being one with foreign interests, thought it worthwhile to reward employees who acquired foreign language skills. So, they hosted what they called a "language lab." Employees could use the lab on their own time to improve their skills. As they got better, they could qualify for bonuses and consideration for overseas assignments. The more difficult the language, the greater the rewards.

I used the language lab to work on my French, a language I had taken in high school. French wasn't one of the big ticket skills, but I had visions of assignments in Paris, so I spent many a dinner hour in the lab.

The agency was more interested in our ability to communicate in and assimilate into the cultures of those foreign countries, so the emphasis was on colloquial conversation rather than on conjugating verbs and all that boring formal language study stuff. In other words, it was fun. Each course had a book of phrases and a tape recorder. This tape recorder was special. The recorder would play a phrase spoken in the native dialect. Then I would repeat the phrase into a microphone. The machine recorded my attempt to say the phrase. Depending on which buttons I pressed, I could then repeat a playback of the example phrase, listen to my own recording of that phrase, or compare the two to see how close I was getting to sounding like the real thing.

Not really high tech, but a specialized machine nonetheless, and hot stuff, I thought, for the late 1950s. Then I saw "My Fair Lady," and realized that 'enry 'iggins had something similar but implemented with cylinders rather than tape. The only drawback to the one I used was that, unless I wanted to do a lot of rewinding and fast forwarding, I had to take the phrases in the order that the machine had them recorded. Dinner hour was not long enough for a lot of random tape streaming accesses.

Recently, I have wondered whether the agency still has that lab (they still have foreign interests) and whether they still use anything like the old tape machine. I have not been to a formal language class or school since then, but I am sure that the technology has advanced a lot.

It occurred to me that a machine such as the one we used could have other uses, and that any computer with a sound card could be such a machine. Furthermore, it would not have that serial playback drawback. Learning languages is not the only discipline wherein someone wants to make noises that sound just like the noises that someone (or something) else can make. Suppose you want to do bird calls, teach Liza Doolittle to speak properly, play Charlie Parker licks, or impersonate Humphrey Bogart.

Impersonations have always fascinated me. How does a person learn to accurately imitate the voices of Bogie, Jimmy Stewart, Mortimer Snerd? Our voices do not sound to ourselves as they do to others, so how does a would-be impersonator know when the other voice sounds just right?

Most impersonators use caricatures of the vocal eccentricities of the people they impersonate, and they make sure that you know in advance who they are doing. Guys like Bogie, Cagney, Gomer Pyle, and so on, are good subjects to impersonate because they have distinctive vocal and verbal idioms ("Of all the gin joints in all the towns ..." "You dirty rat!" "Shazam!") If you just say, "Jew-dee, Jew-dee, Jew-dee," everyone thinks you are doing Cary Grant. No one does people like Dan Quayle because there is nothing distinctive about his voice. (Or anything else, for that matter.)

Then there are the real impersonators, the ones whose impressions are not voice and gesture caricatures but who generate very close reproductions of the voices of their subjects. I know of only two who are that good, and neither one is known principally as an impersonator except among other impersonators. One is Jonathan Winters, whose wacky other-worldly humor overshadows his talent to mimic any voice he hears. The other is Larry Storch, the actor who played Cpl. Agarn on the old "F Troop" sitcom. I played the piano for Larry Storch's standup routine a few years ago at a nearby community center, and, being that close, I paid careful attention to his impersonations. They were perfect. I did not ask him how he learned to do it, but I always wondered. He must have had one of those machines.

I wanted one of those machines, not because I want to do Bogie or relearn French, but just because I wanted one, so I decided to build it. Its name is Storch, and it is a Windows dialog-based application that uses the Win32 Multimedia API to play the sample phrases, record your own phrases, and let you compare the two.

The Storch application is a simple dialog box with a listbox control and six command buttons. Figure 1 shows the dialog. It resembles my Jukebox application from a couple of months ago except that Storch plays back WAV files instead of .MID files and includes an audio record function.

Storch reads WAV files from a list that you prepare from a standard File Open dialog. Obviously, to use Storch, you need a collection of WAV files that make the sounds you want to duplicate. Storch keeps a record of the files you listed in the Windows Registry so that it comes up with your list intact. There are Add File and Delete File buttons to let you maintain the list in the listbox control.

When you click the Play File button, Storch plays the sound clip represented by the WAV file currently selected in the listbox. It runs a timer to determine the length of the clip. When you click the Record button, Storch starts recording from the WAV input device for a length of time equal to the clip's length plus a second. The Playback button plays back your most recent recording. The Compare button first plays back the selected .WAV file and then the most recent recording.

Your recordings stay in memory and are never written to a file. That is not Storch's purpose. If you want to record all the phrases that Bogie utters in Casablanca, or all the bird calls you captured on tape during your last trip to the wilderness, you can use the Windows Sound Recorder applet to build the necessary WAV files.

Storch uses the high-level MCI functions from the Multimedia API. These functions suffice for the simple task that Storch supports. There is nothing tricky about Storch except perhaps the way it computes the duration in milliseconds of the sound clip that it plays. The program uses the Win32 CWnd::SetTimer and CWnd::OnTimer functions and uses durations of 100 milliseconds. While the sound is being played, the timer accumulates the elapsed time in increments of 100 milliseconds. I tried using smaller durations, but the klutzy Win32 timer functions do not have a sufficiently high resolution. The MCI record function requires a duration in milliseconds argument so that it knows how much of a buffer to allocate for the record operation.

The source code for Storch is available electronically from DDJ; see "Resource Center," page 5. There are no WAV clips included; you'll have to provide your own. Who knows, with Storch and diligent practice you might become the next Dana Carvey, Rich Little, or Jim Carey. You might even get good enough to get lucky in a dark little dive in some far-away place. Here's lookin' at you, kid.

DDJ


Copyright © 1999, Dr. Dobb's Journal

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.