Using the Java Sound API
- The Java Sound API
- A Complete Java Sound API Application
- Java Media Framework (JMF)
The term mashup is very trendy these days, and it reflects the way in which different software-based technologies are being mixed together to create interesting new conglomerates. One company that's doing interesting things with a variety of media is AOL. AOL has a rich mix of web-based APIs for manipulating video, pictures, authentication, etc. The video API (called Truveo) allows registered users to provide video search and delivery from within their own web sites. In other words, if I have a basic web site and I want to allow searches on the AOL video library, using Truveo makes it pretty easy for me to do.
The area of mashups is in its infancy, and what makes it more interesting is the backdrop of commodity broadband and the growing interest that huge numbers of people have in expressing themselves! One only has to look at sites such as YouTube and MySpace to see the way people are using the new media tools. One thing that underpins pretty much all of the new media is the base technology of sound.
Not surprisingly, Java provides rich support for sound-based applications. What was more surprising for me is the relative ease with which very sophisticated sound software can be written. As you'll see, Java Sound provides a solid foundation for creating software for manipulating the all-important medium of sound.
Let's look first at the main elements of the Java Sound API.
The Java Sound API
I'm often struck when application areas appear to be so complex that only someone with superhuman intelligence could master them! For some reason, sound engineering has often seemed like one of these fields. It's similar to when Richard Feynman once remarked that even rocket science isn't rocket science! So, I was surprised to learn so much about sound engineering when I studied the Java Sound API.
The Java Sound API provides an implementation of the lowest level of sound support available on the Java platform. This API enables programmers to control sound operations in a very granular fashion—for example, the Java Sound API allows for the installation of, access to, and manipulation of a range of system resources. The latter includes audio mixers, MIDI synthesizers, MIDI devices, file readers and writers, as well as sound format converters. I'll illustrate all of these in this article. Interested readers can turn to Sun Microsystems' web site for more in-depth material. Suffice to say, the Java Sound API provides low-level sound control well beyond the expectations of most end users.
Figure 1 illustrates some of the important elements of the Java Sound API.
Figure 1 The Java API
The key element in Figure 1 is the software mixer. The mixer plays the part of the sound desk and serves to mix all the incoming audio inputs to produce (or render) a single output stream. As you can see, the output device can be a speaker, a headphone, or a downstream device. Notice that the software mixer can mix sound coming from a range of sources including files, networks, applications as well as physical input devices. The broad capabilities of software mixers provide the Java Sound API with a large part of its flexibility and power.