358
Chapter 10
C H A P T E R T E N
Audio
Hacks 70–78
Sound is underrated as a useful tool for building good user interfaces. A lot
of developers balk at the thought of sound support, imagining an office full
of noisy machines, emitting a beeping cacophony more like a 1980s video-
game arcade than a place of business. But on the other hand, don’t you
appreciate it when you get a nice little audible cue? For example:
When your IM buddy logs in
When your CD has finished burning
When your gigantic upload has finished
When someone is trying to hack into your network and you’re not even
looking at the screen
And beyond these kinds of uses, don’t forget the whole realm of applica-
tions that are, by their nature, all about sound: music players, sound editors,
voice chat, and VoIP, etc. Clearly,
java.awt.Toolkit.beep( ) is not going to
cut it.
Java has two built-in options for playing simple sounds in memory: applet
AudioClips and JavaSound. Because of their limitations, this chapter will also
look at two extensions: Java Media Framework (JMF) and QuickTime for
Java (QTJ). Later in the chapter, you’ll find more sophisticated JavaSound
coverage, including how to visualize an in-memory sound clip, and how to
play sounds too big to fit in memory.

Get Swing Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.