advertisement

December 2004 Archives

O´Reilly´s Digital Media Blogs have been expanded and are now located at a new home. To find our new blogs, please visit:
David Battino

AddThis Social Bookmark Button

One of my favorite music-production techniques is applying tempo-synchronized effects to musical phrases. A generic percussion pattern really perks up when you add a dotted-eighth-note echo. A subtle eighth- or quarter-note echo imparts a spaciousness to vocal lines that reverb would just blur. And a four-bar filter sweep adds ear-catching movement to a phrase.

You can hear some examples of tempo sync in my article “Sync and Grow Rich,” on O’Reilly’s Digital Audio site. Because I also enjoy messing around with JavaScript, I created a Web-based calculator for that article; it calculates the duration of a quarter-note at whatever tempo you input. (The magic formula is duration in milliseconds = 60,000 / tempo in bpm.)

As I was developing the calculator script, I noticed that it often spat out an annoyingly large number of digits to the right of the decimal point. Searching for JavaScript rounding techniques, I discovered that some people are converting numbers to characters and truncating them with string operations. That was the technique I used in the sync article:

    // STRING METHOD FOR ROUNDING
    var DivideIt = eval(6000000 / thebpm); // Quarter-note with 2 extra zeroes for rounding
    var TheDuration = "" + Math.round(DivideIt); // Round, then convert to a string
    var dec_point=TheDuration.length-2; // Shift decimal point two spaces left
    var first_part=TheDuration.substring(0,dec_point); // Grab characters to left of decimal
    var second_part=TheDuration.substring(dec_point,TheDuration.length); // Grab char to right
    var result=first_part+"."+second_part; // Join L and R strings with a period between
    var sixteenth = result - 0 // Convert string back to number
  

After publishing the article, I realized it would be useful if the calculator could display multiple note values at once. Deriving them was a simple matter of multiplying the basic quarter-note duration by different factors (0.5 for an eighth-note, 8 for two bars, etc.). But I wanted a more efficient way to do the rounding. On the handy Internet Related Technologies site, I came across a pure arithmetic rounding method, which I implemented as a function:

function roundIt(bignum,decplaces) {
     roundNum = Math.round(bignum * Math.pow(10,decplaces))/Math.pow(10,decplaces);
     return roundNum;
   }

I then added a selection menu so I could specify the number of decimal places. For the single-note durations (expressed in milliseconds), I typically specify zero decimal places, whereas for the multibar durations (expressed in seconds), I’ll specify one to three.

Try it: Enter a tempo and click the button to see the duration at various note values.

Tempo in bpm:   Round results to this many decimal places: 
       
…of notes (in milliseconds)
1/4:
1/8:
3/16:
1/16:
…of bars (in seconds)
1 bar:
2 bars:
4 bars:
8 bars:

To see the complete JavaScript with comments, view this page’s source code. I’m just a JavaScript enthusiast, not a trained programmer, so I’m sure there are better ways to do these calculations. (For instance, I haven’t been able to get the script to work in Netscape yet. Maybe it’s the doctype?) But the process of writing it gave me some insight into the math behind music, and provided a handy reference for those numerous times I want to set up a tempo-synced effect.

—David Battino

How can I improve this script or solve other musical problems with JavaScript?

Rick Jelliffe

AddThis Social Bookmark Button

Related link: http://www.my8848.net/emall/getinfor.asp?shopid=&sid=00020179&adsid=-999&gdsflag…

Trolling around on Google for news of relatives, I discovered some pages that suggest that my 1997 book, with another publisher, The XML & SGML Cookbook was translated into simplified Chinese and published in mainland China in 2000.
This rather surprised me. I wonder what it is like. If anyone has sighted a copy, please let me know.

I rather wish I had known about it, because my old site Chinese XML Now! at Academia Sinica in Taiwan was getting over a half million hits a year at that time, and it would have been nice to have mentioned that the book existed, if indeed it ever did. Actually, it would have been nicer to have been able to adjust the book first: a lot happened in the first 4 years of XML. And to have had the translation checked.

Maybe no-one thought it was their job, either at the US or the Chinese ends, to inform the author. Maybe I should assume a more blasé stance: Actually, one is a little bored that one’s every word illuminates the literary skies of a thousand countries

I am swinging between slight nausea (is it good quality?) and vague excitement (do other translations exist? Swahilli? AusLan? Yakut?) Or is that just too many Christmas parties? But did they include my typographical jokes: the dinosaur glyph or the teardrop bullet points?

Nowadays I really enjoy writing for O’Reilly online sites such as XML.COM much more than I enjoyed writing for print: fewer surprises.

David Battino

AddThis Social Bookmark Button

Related link: http://www.computerhistory.org/music_12142004

Surprisingly, computers have now been making music for almost half a century.
I just returned from a fascinating
lecture
by Max Mathews, who developed
the first software synthesizers back in the 1950s. (The graphic music programming
software Max was named after him.)

Sitting on the stage at the Computer
History Museum
with his Linux laptop, Mathews (78) played us the world’s
first digitally synthesized music, “In
the Silver Scale
,” by Newman Guttman. The 17-second melody, realized
on Mathews’s Music I program in May 1957, sounded like a bad wristwatch
alarm. “After hearing ‘Sliver,’ you’re probably asking, ‘Why
didn’t we quit?’” grinned Mathews. The answer came in a
groundbreaking article that he wrote for Science in 1963. Called “The
Digital Computer as a Musical Instrument,” it included the assertion,

There are no theoretical limitations to the performance of the computer
as a source of musical sounds, in contrast to the performance of ordinary instruments.
At present, the range of computer music is limited principally by cost and
by our knowledge of psychoacoustics.

Indeed, just four years after unleashing the wretched silver scale, Mathews
had his Bell Labs computers singing “Bicycle Built for Two.” Science
fiction author Arthur C. Clarke, visiting the labs, was so impressed that he
later immortalized the event in 2001: A Space Odyssey. Remember when
the dying HAL computer reverts to singing, “Daisy, Daisy….”?

The breakthroughs continued. Mathews described how his associate, Jean-Claude
Risset, discovered that it’s the shifting frequency spectrum that makes
acoustic sounds so rich. Risset also found that the first 20 milliseconds of
a sound have a huge impact on how we perceive it. Twenty years later, that
discovery led to the Roland D-50 synthesizer, which grafted complex sampled
transients onto easily synthesized sustaining tones.

John
Chowning
, the other half of the panel, then described his research in
frequency modulation (FM) synthesis, which spawned the hugely successful
Yamaha DX7, followed by millions of soundcards and cell phone synthesizers.
Again, the core factor in generating rich sound was varying the pitch and
timbre. Chowning played some examples in which simply adding a bit of vibrato
to a synthetic tone made it sound startlingly vocal. He also showed how changing
the bandwidth and amplitude of a sound in parallel produced the complex bell
and brass tones FM does so well.

The event ended with a performance of Risset’s “Duet for One Pianist,” in
which a live pianist and a computer (running Max) simultaneously played a Yamaha
Disklavier player piano. The Disklavier transmitted the human’s performance
into the computer via MIDI. The computer then improvised complementary parts
on the piano by triggering solenoids under the keys. When an audience member
later asked the panel where it thought computer music was going, Chowning predicted
there’d be more of that type of human-machine interaction. Mathews envisioned
having a helmet that would scan the composer’s brainwaves and convert
them to music.

I wonder what future musicians will think of today’s computer-music
tools and techniques in 2051.

What do you think were the most important computer-music breakthroughs—and what’s next?

Joshua Paul

AddThis Social Bookmark Button

Related link: http://www.eff.org/news/archives/2004_12.php

Over a year ago I wrote and published an article for the Producer’s Guild of America on file-sharing’s effects on the Motion Picture Industry, including the television industry. At that time I felt it would be three to five years before the industry began to feel the effects of disruptive technologies, like P2P and TiVo. I now feel I should have said one to two years.

Within the article I stated my opinion that a majority of industries have had to deal with the effects of the internet. From bookstores to Wall Street, each industry has had to make adjustments in order to adapt. The Entertainment Industry has been able to avoid adapting…until recently.

I think the best way to remove the "threat" of P2P networks is to embrace them. I heard a saying a while back that has stuck with me: "If I make my enemy my friend, do I not destroy him?"* Essentially, I feel the Motion Picture Industry needs to find a way to befriend the P2P networks.

There are already many concepts on how to embrace P2P being discussed publicly. There are a lot of very smart and very creative people discussing possible solutions. However, and more importantly, Jun Group is doing more than talking.

Within the last week, Jun Group released The Scene as a P2P-only television show. It has been reported that there were hundreds of thousands of downloads, within a few hours of its release. Imagine what could happen if a large studio released a show…

…or if you did.

* If anyone knows who said that, please let me know.

Do you think the Entertainment Industry should embrace P2P networks? If so, how?

Marc Loy

AddThis Social Bookmark Button

Related link: http://www.computerweekly.com/articles/article.asp?liArticleID=135729&liArticleT…

Well, looks like the next volley has been heard. Computer Weekly is carrying a story about Disney’s decision to back Blu-Ray (the higher-capacity but reportedly less video-friendly format) DVDs. That’s gotta carry weight. Probably a bit less weight since Disney lost Pixar, though. (Of course, now Pixar is in trouble over delays for their next film, but we’re wandering way off topic here.)

Toshiba is also reporting a new dual-layer disc that contains one standard format DVD layer and one HD DVD layer. My guess is that’s where we’re headed. There are still arguments out there over the -R/+R formats, but those of us in the consumer world have pretty much forgotten about it because they both work. More or less, anyway. I have stacks of both formats and they both work fine in every Mac, PC, or standalone burner I’ve bought in the last 18 months. Both formats play back fine in all of the players I have so I usually just grab whichever stack is handy. I still author on -R media for duplication houses, but I really think that’s habit more than anything else.

I know the technology to flip between Blu-Ray and HD DVD will be trickier than the +/- problem, but it’s bound to be doable. In the meantime, the war between the two will certainly help those of us in end user land. Companies are driving to get their products to market so they can “beat the other guy” and gain credibility. The faster they can perfect the technology, the faster it’ll get to a price point consumers can tolerate.

But while I’m all for getting the next generation of DVDs underway, what I really want is the next-next generation. I want to archive my terabyte RAID to a single shiny disc that I can store offsite. Or take with me on the road, you know, ‘cuz I need to have the Star Wars trilogy available in HD for viewing in bad light on my 12″ PowerBook. Even if they did mess with the story. (Han Solo so shot first. But now we’re back in off-topic land…)

So is bigger better? The 10G difference in layer capacity seems like a big deal to me, but clearly that’s not the only consideration. Who are you cheering for?

Roger Weeks

AddThis Social Bookmark Button


After our recent move, our household is now located way beyond the reach of broadband. Trees and hills make wireless a very dubious prospect. We’ll probably have to settle for ISDN if our local ILEC can provide it.


This presents a few problems. Until ISDN gets ordered, we’re stuck with dial-up. Problem #1: No modem in our primary desktop PC, and I have no plans on attaching one. Problem #2: Need to use more than one laptop and desktop in the house at a time. Our Linksys WRT54G used to be the access point and router for the house, but no longer.


Enter the box of old computer stuff that I couldn’t throw away but had no immediate use for when we moved. Item #1: Dell Latitude notebook with a broken LCD. Item #2: Linksys WPC55AG 802.11a/b/g wireless card. Item #3: Engenius 802.11b (Prism II chipset) wireless card.


Since I also have a PCI version of the Linksys a/b/g card for my desktop, this seemed simple enough:

  1. Install a linux distro on the Dell Latitude.
  2. Get wireless drivers working for one of the wireless cards.
  3. Set up the wireless card in master mode as an AP for the house.
  4. Set up pppd on the Dell using the 56k modem.
  5. Use iptables to make the Dell a NAT router.
  6. Put the dell in a corner somewhere next to a phone jack.
  7. When ISDN is installed, hook up an ISDN TA to the Dell.

Okay, okay - maybe not simple, but certainly straightforward.

Since I’ve been hearing good things about Ubuntu Linux, and since I tend to prefer Debian anyway over Red Hat/Fedora/Mandrake (or Slackware, for that matter), I downloaded the ISO installer for Ubuntu and burnt the CD on my PowerBook.

Score one for Ubuntu! That’s right, the installer is a single CD. Not three, not five, just one. I almost felt like I was installing RedHat 5.1 again.

Okay, the install is still ugly. Wow, it reminds me of the RedHat 5.1 install. Let’s face it - Linux installers still need some help, as my coauthor Edd Dumbill points out. The installer for Fedora Core 3 is pretty good, although I still think that for most average users it asks way too many questions.

Kudos to the Ubuntu developers for disabling root logins from the get-go, and making you login as a non-priviliged user with sudo access. There’s no reason for every other distro not to follow their lead.

Okay, the install is over, I’m logged in. Fully expecting to have to tweak the wireless drivers, I type in `sudo iwconfig` and I am totally blown away. ath0 exists and has a blank ESSID in managed mode. Sacre bleu!

This is the first Linux distribution I’ve installed in the last year that actually detected an 802.11a or 802.11g card, and properly installed the correct driver. In this case, the Linksys card is using an Atheros chipset, and Ubuntu has set up the Madwifi driver. This happens to be one of the drivers that supports MASTER mode, or in other words lets you act as an access point.

So: `iwconfig ath0 essid f00bar mode master` and `iwpriv ath0 mode 3` (sets the card to 802.11g mode) and bing! I have an access point I can see from my PowerBook.

So Ubuntu is the distro of choice for me right now. Unfortunately, my simple plan ran into a roadblock: the 3Com 56k modem in the Dell Latitude is a “Winmodem” with no Linux drivers. Sigh… I need to dig into my box deeper and see if there’s a PC card modem hiding somewhere.

Rick Jelliffe

AddThis Social Bookmark Button

At the dawn of XML, some LISP fans would say that XML was just a crappy LISP. (The clueier LISP fans would use “s-expr” or SEXPR or S-expressions, as the Lots of Irritating Silly Parentheses syntax is known.) But Java plus XML plus the Beanshell interpreter is a pretty nice crappy LISP!

The markup-language-as-bad-sexpr notion predates XML by almost a decade with SGML: indeed, with SGML the comparison is fairer, because SGML does include features for setting delimiters and constructing little languges—SGML’s SHORTREF and ENTITY mechanism can be compared to macros in LISP, for example.

One reason XML was designed with the principle “Terseness is of minimal importance” was to cut SHORTREFs out. (SGML is still in use by people who need SHORTREFs. But vendors who cannot make a buck out of SGML won’t tell you that :-)

Syntax aside, LISPers point out that the XML infoset (i.e., the general data structure that applications may see when the text is parsed) is an attribute value tree (AVT), just like modern LISP lists. (AVTs are very convenient to have available. Certainly one of the reasons for XML’s success is that it has allowed vendors to add fairly similar AVT APIs to their libraries.) However, LISP has syntactic features to allow the recognition of numbers and symbols in data: XML just has strings. (Both can represent links between nodes, so really the data structure is an AVT with cross links, like a directed, rooted graph.)

Paul Prescod has a nice page XML is not S-Expressions on the topic. I would also add that XML’s encoding declaration is the only text format that provides a workable (though, of course, fallible) approach to the problem of world-wide variations in text encoding: LISP and probably every other programming language does not even get to first base.

S-Expressions have no standard equivalent of DTDs, for validation. XML DTDs provide a basic unit test for documents, which promotes quality testing, clearer interface definition, a separation of concerns between information providers and information recipients, and that the WWW as a data flow model.

So XML’s encoding basis is superior to LISP. Its flexibility for creating little languages is less than LISP. Their data structures are pretty much the same. LISP has marginally richer datatypes. Each have different software engineering qualitites. Parenthesis syntax is familiar to programmers; on the other hand, angle-bracket syntax is familiar to web coders.

So XML versus S-Expr is a draw, to me. When character set encoding and markup are important, XML wins. When terseness or recognizing numbers are important, S-Expressions win.

What about XML+Java versus LISP? That is a bit fairer.

I am very affectionate towards LISP. In the early 90s, I briefly worked for Texas Instruments supporting their Explorer LISP systems: wonderful things. TI were closing the Explorer project down at that stage: the belief was that LISP (the language) would not be needed because LISP (the bundle of features) would win. The TI boffins said that in the future (i.e. now) when you opened up a language platform, you would see standard list/AVT structures, garbage collection, object oriented-ness, message passing, dynamic linking, expression parsing, and a whole slew of other features LISPers loved and which were not available in, say, the C APIs. They were right.

But the most characteristic thing of LISP is the eval function. Can I have that in Java+XML? I have been using the BeanShell interpreter for this, to provide interpreted scripts in my company’s products. With Beanshell “Users may now freely mix loose, unstructured BeanShell scripts, method closures, and full scripted classes.” (At Topologi, we debug using Eclipse and compiled versions, then strip out some header info to generate the scripts when deploying.) I certainly don’t want to claim that XML+Java+Beanshell is as beautiful as LISP, but they go a long way towards having the equivalent power of LISP, indeed of other interpreted languages.

LISP had another strong influence on XML, because of Richard Gabriel’s paper, usually called href="http://www.naggum.no/worse-is-better.html">Worse is Better, which should be required reading for anyone who is a big fan evangelizing any language, be it Python, C#, XQuery or ASP. (For more, including “Better is Worse” see Gabriel’s site. Sun’s Jim Waldo has a recent response Worse is still worse which I think misses Gabriel’s fundamental point: Waldo paraphrases Gabriel as “Better depends on your quality metric”, while I believe Gabriel’s paper is the much more challenging “our quality metric can be wrong”.)

David Battino

AddThis Social Bookmark Button

Perhaps it’s because my first full-time job was working in a recording studio for $3.65 an hour, but I’ve long been obsessed with finding the best value. The tricky thing is that maximum value isn’t always where you might expect. In the case of that recording gig, for example, I snagged about $50,000 of free studio time and a great real-world education along with my miserable paycheck.

When chasing value, I find one of the hardest challenges is to overcome the human tendency to grab the obvious bargain. Cheap things often cost more in the long run, as 19th-century philosopher John Ruskin noted. “It’s unwise to pay too much, but it’s worse to pay too little,” he wrote. “When you pay too much, you lose a little money. When you pay too little, you sometimes lose everything, because the thing you bought is incapable of doing [what] it was bought to do.”

Of course, technology alters that equation a bit. It’s a safe bet that Ruskin never used music software. Many of today’s commercial programs deliver astonishing power for the money, and there’s some superb freeware out there as well. But Ruskin’s point still holds. A colleague and I recently wasted eight hours trying to solve an audio problem with unstable, poorly documented shareware. Value can also be measured in time and effort.

Here in Silicon Valley, we celebrated the 20th anniversary of the IBM PC a few years back. The local newspaper interviewed David Bradley, the engineer who designed the PC’s notorious Ctrl-Alt-Delete reboot command. “As I like to joke,” he said, “I may have invented it, but Microsoft made it popular.’’

I was reminded of that line when, stymied by a persistent disk-corruption problem, I picked up a book on computer troubleshooting. Standing in the checkout line, I was darkly amused to realize I was hefting a thousand-page compendium of things that could go wrong with my computer. Though I eventually found the solution online, it was one that involved more effort and expense than I’d hoped.

Many people believe the answer is to simplify. George “The Fat Man” Sanger, with well over 200 videogame soundtracks to his credit, recommends (tongue in cheek) wrapping a big roll of duct tape around your computer once it’s working so you aren’t tempted to upgrade it. Still, the creative process involves pushing boundaries, and for many of us, that’s one of the exciting things about computers.

And after all, learning to use something well is the secret to getting the most value from it.

What are some of the best and worst values you’ve found?