Improve your programs with practical audio

Learn 3 ways to produce sound in Java applications and applets -- and how to grab sounds from JAR files

1 2 Page 2
Page 2 of 2

Sun also announced for Java 1.2 the Java Sound engine, which is implemented with the existing public sound APIs from JDK 1.02 and 1.1. The benefit of this new engine is its ability to play a wider variety of sound types, including WAV, MIDI, RMF, AIFF, and more AU sound formats. At JavaOne '98, Sun announced a public specification for interfacing with the sound engine. This public Java Sound API allows user inspection and manipulation of the sound data.

Conclusion

In this article I have demonstrated several alternative ways to play sound in a Java applet or application, and have shown how simple it is to play sounds in a Java program. I also have shown how to package and extract sounds from developer- or user-provided "sound-scheme" files. Sounds are easy to package in JAR files using published names, ordinal positions, or naming conventions. You can offer users a lot of options for customizing their environments to make them sound just right (from the individual user perspective). As is clear from the Sun announcements, Sun will offer additional and more flexible alternatives in the future. For now, however, these examples show several current options for programmers that want to include sound in their Java programs today.

Dan Becker works in the Network Computing Software Division of IBM Corp. in Austin, TX. He is currently working on Java 1.2 and other Java extensions for IBM Operating System/2. Before that Dan worked on porting previous Java virtual machines, the multimedia plug-ins for Netscape Navigator for OS/2, OpenDoc, and the Multimedia parts for OS/2 Warp Version 4.0. Dan can be reached at his public Webpage at http://www.io.com/~beckerdo.

Learn more about this topic

  • Sun's Java Media API page shows all media-related developments in Java related to playing sound and video http://java.sun.com/products/java-media
  • Sun's Java Media Frameworks Java Extension page shows an advanced extension to Java that allows playing many sound and video formats http://java.sun.com/products/java-media/jmf/index.html
  • Sun's Java Sound API for Java 1.2 page shows upcoming changes to Java 1.2 that allow playing, mixing, and editing many sound formats http://java.sun.com/products/java-media/sound/index.html
  • Sun's Java Tutorials page contains a tutorial on playing Java sounds, as well as other tutorials http://java.sun.com/docs/books/tutorial/TOC.html
1 2 Page 2
Page 2 of 2