Most Popular


The EM Poll




CURRENT ISSUE

SUBSCRIBE
$1.84 an issue!

EM DIGITAL EDITION
Try it for free today!

browse back issues


Follow Us On...




JAVA Jive

Nov 1, 2000 12:00 PM, Peter Hamlin



         Subscribe in NewsGator Online   Subscribe in Bloglines
 

CURRENT NEWSSTAND ISSUE

Read the full Table of Contents for the issue on sale now! Click here

Subscribe for only $1.84 an issue!

Please tell us about yourself so we can better serve you. Click here to take our user survey.

MixBooks Logo
Life in the Fast Lane

This collection of St.CroixÕs columns was assembled during the two years following his death of cancer in May 2006. Included are many of his most-read columns, as well as personal notes, drawings and photographs.

Click for more books
EM Podcasts

Listen to these latest podcasts and more:
Bela Fleck on recording Jingle All the Way.Go

What's New: software and sound products. Go

eDeals Newsletter for Discounts on Gear

Get First Dibs on Hot Gear Discounts, Manufacturer Close-Outs and Job Opportunities when you sign up to receive eDeals E-newsletter, sent twice a month. Check out an issue get advertising info or subscribe

IS JAVA THE ELECTRONIC MUSICIAN'S CUP OF TEA? Anybody who has been around computers for the past few years has probably heard about Java. This isn't the kind of java that keeps musicians and producers awake during late-night recording or composing sessions. This Java is a computer language. So why is another computer language important, especially for those of us who long ago traded in music paper for computer screens?

The reason for all the buzz is that the same Java program can run on any platform: Windows, Mac, and even a Linux or Solaris system. Moreover, you can embed special Java programs called applets in a Web page, and visitors can run them over the Internet using almost any browser. The frustrations of hardware and software incompatibility are, at least in theory, not an issue for Java programs.

What makes Java especially interesting for musicians is that it includes support for both MIDI and digital audio. What's more, Java 1.3, the latest version at this writing, supports impressive features for recording, playing, and processing sound. It also comes packaged with an excellent software synthesizer. All this means that more Java applications and applets rich in multimedia content should be appearing on our desktops.

To give you a feel for what Java can do, I'm going to present several examples. In the process, you'll see the interactivity and multimedia features that Java offers. You'll also learn how to set up your computer to run Java applets and applications easily and efficiently.

JAVA APPLETS First, let's look at three Java applets: an interactive "graphic" synthesizer, a tool for developing musical skills, and a demonstration of the physics of sound. If you can browse the Web as you're reading, you'll be able to see all the features I describe. Otherwise, just read along, then check out the examples later. If you have trouble running any of these applets, have a look at the sidebar "Setting Up Your Computer to Run Java Programs."

The vOICe. The vOICe (http://ourworld.compuserve.com/homepages/ Peter_Meijer/javoice.htm) was created by Peter B. L. Meijer. The first thing you'll notice when you access this page is that Java applets often take longer to load than typical Web pages. Find the applet display - a large grid filled with a digitized photograph of a car - just below the top of the page (see Fig. 1a). Click on the display with your mouse, and the screen goes blank. Then click-drag your mouse over the screen, and you'll see tiny pixels form in response to your mouse movements. Each pixel immediately triggers a short sound (shades of MetaSynth!).

On the graph, the x axis represents time and the y axis represents pitch, and the drawing you make "loops" repeatedly. Everything updates in real time; add a continuous tone by adding a straight line from left to right or a burst of sound by drawing a circular blob of pixels. Single pixels placed at random points around the screen result in sparkles of sound, and small, curvy lines create wispy melodic riffs. You can also choose shades of gray for your drawing: the brighter the color, the louder the sound.

By clicking on the Load From button, you'll hear how the digitized photograph sounds when the light and dark pixels are translated into pitches. If you click on the Reset button, you get a screen full of options that enables you to change the applet's settings. For example, you can change the number of columns (time slots) to create a longer musical segment. The Clear button lets you erase the screen and start over, and the Mute button instantly mutes the sound. Finally, clicking on the Wave button shows you a picture of the sound wave you've created (see Fig. 1b).

The vOICe also supports animation. You can create several frames of pictures and cycle through them for a visual as well as an audio show. Farther down the page is a discussion of how you can use The vOICe to demonstrate auditory effects. And there's one more nice trick: you can load a WAV file and work in reverse, creating a sonogram (a pictorial representation of that sound) on the computer screen. You'll also find links to some interesting Web sites on which The vOICe has been used.

If you can think of an interesting use for The vOICe on your Web site, the applet's creator offers a free site license for personal, noncommercial use. You might find that this or another applet is perfect for sprucing up your site (see the sidebar "Adding Applets to Web Sites"). If you'd rather just experiment with the program, The vOICe is available as a stand-alone application for your computer.

Scale Building. Java's interactivity and multimedia support are ideally suited for creating musical skill-training exercises that run on the Internet. The Hamilton College Software Project has produced a large number of Java applets that are good examples of this approach. The applets were written by Rob Whelan and are based on designs by Samuel Pellman and G. Roberts Kolb. We'll look at the Scale Building applet (http://academics.hamilton.edu/music/spellman/JavaMusic/ ScaleBuilding.html), which lets you practice constructing different kinds of scales.

This applet takes a while to start, and then you need to wait a bit more for the sound files to load. When all is ready, click on the Options button. (On my laptop, the screen is compressed and unreadable, so I need to make the application window larger before using it.) Select which scales you want to practice; you can make the drills easier or harder by including more scale types to work with. Notice that there are two drop-down option windows: the one labeled "Shortcuts" lets you quickly select or deselect all scales or choose scales by category, and the other window lets you choose the starting pitches from which the scales are built.

When you've selected all your desired options, click on Done to return to the applet. Next press Start, and you are presented with a starting note and the name of a scale (see Fig. 2). You need to build the scale by choosing the correct notes from a palette and clicking them into the correct position on the musical staff. While you're working, you can audition the scale you're trying to build. (A great way to test your knowledge is to try singing the scale first, then listen to it to see if it's correct.) As you build the scale, mistakes are indicated by an obnoxious "oogah" horn, a good incentive to improve your scale-building skills as quickly as possible.

An interactive applet is ideal for this kind of exercise. You can work at your own pace, you receive constant feedback about how you're doing, you get to relate the notation to the musical sound, the level of difficulty is up to you, and you can customize the drills to focus on areas you need to work on. Because it's a Java applet, it's already been "distributed" to everyone who has an Internet connection and a browser that supports Java, no matter what kind of computer they have. The Java Music Theory Web site has many other good examples of interactive applets, and no doubt you'll find something of interest. You can reach them from the Web site's main page: http://academics.hamilton.edu/music/ spellman/JavaMusic.

Other music-theory and ear-training applets can be found all over the Web. For example, the Teoria Web site (www .teoria.com/java/eng/java.htm) has excellent skill-building applets by Jose Rodriguez Alvira. These applets use notation only (no sound), but they are still very effective teaching tools. If you want to try a little of the hard stuff, visit Matthew H. Fields's Twelve Tone Toy Box at the University of Michigan's Web site (www.personal.umich.edu/~fields/ TTTB). This applet is musically interesting and has some great-looking animated graphics to go with it.

Fourier Synthesis. Java's combination of sound, graphics (including animation), and interactivity also makes it an excellent tool for teaching acoustics. For example, Fu-Kwun Hwang's Fourier Synthesis (www.phy.ntnu.edu.tw/java/sound/sound.html) demonstrates the technique of the same name, which is the process of creating a complex sound by combining sine waves.

When Fourier Synthesis is loaded, you see two rows of faders on the left, a picture of a waveform on the right, and some settings at the top (see Fig. 3). A single sine wave is initially drawn at the fundamental frequency of 220 Hz (press Play to hear it), and you add harmonics by moving the faders. For example, move the top-row fader marked "2f" (twice the fundamental frequency) and listen to how this harmonic affects the sound. The bottom-row faders let you add cosine components (that is, phase-shifted sine waves). As you move the faders, the waveform display immediately updates to reflect the sound's spectrum.

The Fourier Synthesis Java applet is effective because it provides immediate feedback to your input. The way it lets you see the waveform and constantly hear the effects of the changes you make is, again, a good example of the use of interactive and multimedia content on the Web, a particular strength of Java applets. For other interesting online demonstrations of acoustics, direct your Web browser to www.phy.duke.edu/ %7Edtl/36linka.html. Also check out the sidebar "Outta Sites" for even more applets.

GREAT APPS! The creators of Java applications are attracted to its cross-platform nature and programming power. As a result, a number of stand-alone applications written in Java are starting to appear. Intended to run on the desk-top, these programs require that you have Java configured on your computer (see the sidebar, "Setting Up Your Computer to Run Java Programs").

CPS. Written by Niels Gorisse, CPS (www.bonneville .nl/cps) is a real-time, programmable sound environment that can control and process digital audio and MIDI signals. Some of its modules bring sound into the program, others process sound in various ways, and still others output audio or MIDI or write files to disk.

Java applications such as CPS run on what is called a Java Virtual Machine (JVM), the software that interprets the Java code for a given platform. The JVM is part of the Java Runtime Environment (JRE). The sidebar "Setting Up Your Computer to Run Java Programs" provides instructions on how to install Sun Microsystems' JRE, but CPS works under Windows with a JVM from Microsoft. If you install CPS and find it doesn't run, you should install the Microsoft JVM (it's free) by following the link on the CPS home page. If the program runs but acts strangely (for example, if the main window closes at unexpected times), then you have an out-of-date JVM and need to download the current version.

You launch CPS by double-clicking on the file CPS.exe in the Program directory, which was created when you installed the program. Two windows appear: an empty window that serves as a work space and a small console for system messages. The Insert menu provides a list of 20 categories of objects that you can place in the work space. (You can also right-click anywhere on the work space to insert objects from a floating pop-up menu.) In addition to audio and MIDI input and output objects, the program has objects for display, data conversion, oscillators, filters, amplifiers, noise, envelopes, and much more.

When you insert an object, it appears on the screen as a rectangle (see Fig. 4). Control inputs and outputs appear at the top and bottom of an object, and audio inputs and outputs are found on an object's left and right sides. (Of course, not all objects have all types of ins and outs.) A lot of contextual help is available, and it's easy to move, delete, and interconnect the objects to create a "patch" that generates the sounds and processes you're after.

When you start working with CPS, you will notice many similarities to Csound, the powerful sound-synthesis programming language created at MIT and used widely by electronic-music composers (see "Master Class: Building Blocks" in the October 2000 issue of EM). CPS is actually based on an audio standard called MPEG-4, which is based on Csound. (To find out more about MPEG-4, visit http://sound.media.mit.edu/mpeg4.) But unlike Csound, CPS is a live, interactive visual environment. CPS lets you add and rewire the elements while they're playing, offering a spontaneity that is not available with Csound.

Fig. 4 shows a CPS patch that multiplies a sound file's output with a variable-pitch sine oscillator; in other words, it's a ring modulator. The frequency of the oscil object is derived from the envelope-generator object, called aline. The oscil's waveshape is programmed in the table object; double-clicking on the table object brings up a table editor in which you can create whatever waveform you desire. The audioFromDisc object produces audio output that is multiplied by the output of the oscillator (shown by the superscript * object), and the resulting signal is sent to the audioOut object, where the sound is heard.

Notice that the display objects freq and oscil ampl show the oscillator's instantaneous frequency and amplitude. The decimate objects are also needed for the display: they read in values at the audio sample rate and display them at a much slower rate so you can read them. The System Messages window is available for error messages and other information.

Another interesting component of CPS is CPSChat, which lets you communicate with other users over the Internet and even send musical signals to them. It is easy to imagine CPS as the basis for interactive Internet improvisation. The creator of CPS has also written a program called MidiChat that allows people connected to the Internet to jam together with MIDI signals that they send and receive in real time.

At the time of this writing, CPS was available only for Windows. (Java itself works across platforms, but CPS handles MIDI and audio using high-performance, Windows-only libraries that aren't written in Java.) However, the author is developing versions for other platforms. The program costs $125, but you can try the shareware version before you purchase.

HPKComposer. HPKComposer (hplank.inetpc.com/ hpkcomposer.html) was created by Didier Debril and Jean-Pierre Lemoine of the French research group HplanK, and like CPS, it is related to Csound. The Csound language generates music using an orchestra file, which describes the virtual instruments or "patches," and a score file, which indicates exactly when each instrument sounds, its duration, its amplitude, and any number of other programmable parameters.

HPKComposer provides a variety of sophisticated visual and mathematical tools for creating Csound orchestra and score files. You must have Csound on your computer to generate sound files from the score and orchestra files created by HPKComposer. You can download Csound from www.csound.org, where you'll also find information about installing the program. HPKComposer uses the Sun Microsystems JRE (see the sidebar "Setting Up Your Computer to Run Java Programs").

Another feature of the program is support for Virtual Reality Markup Language (VRML), a three-dimensional interactive scripting language. (A scripting language uses a text script to describe the scene to be produced.) HPKComposer can be set up to create VRML scenes that respond to elements of a Csound score. It's refreshing to see a music application that also creates visual art to go along with the sounds it produces. To view VRML scenes, you need to install a VRML plug-in for your Web browser. I use the Cosmo VRML player (www.cai.com/cosmo) with Microsoft's Internet Explorer.

HPKComposer has an idiosyncratic user interface that was confusing at first, but I quickly adjusted to it and came to like it. It's certainly beautiful to look at (see Fig. 5). The program has three basic work areas: the Score Editor, which generates Csound score files; the Soft Synthesizer, where you create Csound orchestra files; and the VRML 3D Builder, which can create three-dimensional graphics to go with your music.

HPK Composer's Score Editor enables you to specify the time at which each note sounds, its duration, its pitch (single notes or chords), its amplitude, and any controllers you wish to define (more in a moment). You can type in a value for any of a sound's parameters, or you can use various functions, such as probability curves or fractal functions, to specify values. Another possibility is to use the Composer, a sophisticated tool for creating sound clusters, chord morphings, and note patterns.

The Soft Synthesizer is an onscreen representation of a classic modular synthesizer that provides access to Csound's sound-generating and sound-processing functions. You can create up to eight virtual instruments, each containing up to four sound sources. The sound sources can be drawn from any one of 18 selectable sound generators. The outputs of these sound sources can be processed with pitch and amplitude modulation, filters, a ring modulator, a morpher, a panner, and a multi-effects unit. Any parameter - such as amplitude modulation, panning, or "wetness" of effects - can be set by controller data specified in the score. This controller data can be as simple as a constant value, or it can change over time in very complex ways.

After you've set up the Score Editor and Soft Synthesizer, click on a button that generates the Csound score and orchestra files, then launch Csound to create the sound file. I use Csound under Windows, and I have a shortcut defined on the task bar at the bottom of my screen, so launching Csound is just a click away. You can also configure HPKComposer so that you can load Csound from within the program.

HPKComposer runs on Sun's JVM and is platform independent by nature. Because Csound has been ported to just about every platform, HPKComposer can run nearly anywhere as well. When you run HPKComposer (by double-clicking on the file HPKComposer.bat), you will notice a few things that are characteristic of Java. First, you click on a batch file to start the program. This is necessary because you're actually running the JVM, and the batch file tells it which Java elements it has to load. Once things are loaded, there's little evidence that you're not using your favorite desktop audio software.

FAST-FORWARD Java offers a lot of promise as a way to create multiplatform, multimedia applications and Web sites. But what is the future of Java for electronic musicians? Is it worth taking the time to master the language or even configure it on your computer?

Java is a strong addition to the multimedia field. Its inherent power, platform independence, and music support and the fact that it is available for free are all significant assets. But it also exhibits a few frustrating limitations in practice. The average Web surfer won't spend 30 minutes downloading a plug-in, which is how long it took me to get the core Java components via my modem connection. The need to install the JVM in your system before you can run applications might also be a deterrent to some users. And although the language is universally compatible in theory, you will definitely notice problems in some circumstances (for example, when you're using certain versions on certain browsers on certain platforms).

Web developers face yet another frustrating trade-off: if you use the impressive music features found only in the most recent versions of Java, fewer people will be able to use your applets. (This is not an issue with stand-alone Java applications, because all required files can be distributed with the application itself.) On the other hand, if you are creating applets for a network, such as a school, college, or business intranet, for which you have fast network connections and control over browser versions and user setups, Java is an ideal tool.

Java's performance can be noticeably slower than optimized platform-specific programs. Add to this the bandwidth limitations of the Internet when it's running Java applets, and you'll understand my anxiety when I see the words "loading Java applet." Fortunately, JVMs are getting much faster and more powerful, and the dramatic speed increases of computer hardware should reduce Java's performance disadvantages. And of course, increases in online speed as more people move to broadband connections will also be a big help.

It will be interesting to see if and how major software developers use Java. Programs that demand the most of a computer's resources - such as sophisticated notation programs and sequencers - will probably not be candidates for Java in the foreseeable future. It seems more likely that ambitious and creative programmers, such as the creators of CPS, HPKComposer, and the applets we have examined, will use Java to do interesting and inventive things on the Internet. It's exciting to think about all the Java teaching tools - from ear-training exercises to acoustics demonstrations to interactive creative projects - that could be created. The possibilities for interactivity and communication will make Java on the Internet an important new creative-performance medium for computer musicians.

I expect Java to be a significant player in the coming years. Because of its extensive support for sound, it will be especially important for electronic musicians. No one can predict exactly how big a role it will play down the road, but Java will certainly be part of most musicians' futures.

Java programs run on a Java Virtual Machine (JVM), software that acts as an intermediary between the program code and whatever hardware and OS you're using. The JVM is part of the Java Runtime Environment (JRE), which must be installed on your computer before you can run Java programs.

To install version 1.3 of the Windows JRE, head to http://java.sun.com/j2se/1.3/jre/download-windows.html. This is the site of Sun Microsystems, Java's creator. Look for the heading, "Downloading the Java 2 Runtime Environment, v 1.3.0." The download is only about 5 MB, and it's free. When downloading is complete, double-click on the file to run the installer. If you need help, the Sun Web site has a link to installation instructions, and it offers troubleshooting help if things don't work properly. Many excellent books on the market also provide installation assistance and more information about Java. My favorite is Core Java, vol. I: Fundamentals by Cay Horstmann and Gary Cornell (Prentice Hall, 1998). It is a clear, practical, and thorough introduction that serves as an excellent reference.

Many Java applets will run in a standard browser, although you should have at least version 4 of Netscape's Navigator or Microsoft's Internet Explorer for optimal support. If you find applets that won't run in your browser, the solution is Java Plug-in. It tells the browser not to run its own built-in version of Java, but instead to use the JRE on your computer. If you've installed a current JRE, the plug-in is automatically added to the Windows Control Panel. (Anyone with earlier versions of Java will notice that the process is a lot simpler than it used to be.)

Information about Java downloads for the Mac can be found at http://developer.apple.com/Java/text/download.html, and you can look for Solaris and Linux support at Sun's main Java-products page (http://Java.sun.com/products). If you want to write your own Java programs, you need the Sun Developer's Kit (SDK), a download of about 30 MB, plus 20 MB more for documentation. The SDK is available at Sun's site, and it's also free.

Many applets are available for free, and others are available for purchase. Even if you're not a programmer, you can download an applet and add it to your Web site (assuming, of course, that the applet is cleared for public use). And depending on how the applet is constructed, you might even be able to customize it. So once you have an applet, how do you add it to your Web site?

Hypertext Markup Language (HTML), the standard language used for displaying Web pages, includes an tag. Let's say you have an applet called test.class that requires a 300-by-300-pixel display area on the screen. Assuming that the test.class file is in the same directory as your Web page, insert the applet into the page with the following HTML code:

(Depending on the applet, you might need to include other parameters.) Place the tag in the page on which you'd like the applet to appear.

The tag works with a browser's built-in Java support, but if you want the user to run the applet with Java Plug-in, you must use tags for Navigator browsers and tags for Internet Explorer browsers. (Unfortunately, each browser uses the plug-in differently.) Java's creator, Sun Microsystems, makes a tool that simplifies this process. You can create the page with tags and run it through a free HTML converter, and the page will automatically be rewritten with both and tags. If either Navigator or Internet Explorer finds your site, it will view the applet correctly. Sun posts the HTML converter at http://Java.sun.com/products/plugin/ converter.html.

We've looked at a few good Java applets, but a vast number of other applets are available online. Here are some starting points for finding additional examples, perhaps to use on your own Web site.

Gamelan http://gamelan.earthweb.com

Jars.com (a Java review service) www.jars.com

Java Boutique http://Javaboutique.internet.com

Java Music Projects http://music.calarts.edu/~tre/JavaMusic.html

Sun Microsystems http://Java.sun.com/applets/index.html

Most of these sites are general, but they typically have one or more categories of multimedia applets. Java Music Projects, created by Tom Erbe at the CalArts School of Music, is especially interesting for musicians. To find other sites, try running a search engine. Add the words java and applet to the keywords representing your interest.

Get Copyright ClearanceWant to use this article? Click here for options!
© 2010 Penton Media, Inc.



Acceptable Use Policy
blog comments powered by Disqus

Back to Top