Exercises

If you want to delve deeper into the Java Sound API, read the JavaSound Programmer’s Guide included with the Java SDK documentation bundle. Also visit the jsresources.org web site for a useful FAQ and many more example programs. When working with MIDI programs, you may need information from the MIDI specification. Unfortunately, this spec is not available online. It can be ordered in printed form from the official midi.org web site, but you can often find the information you need by searching the Web.

These exercises will start you on your way to JavaSound fun:

  • Exercise 17-1. Convert the Drums program so that it runs as an applet within a web browser.

  • Exercise 17-2. Modify the PlayerPiano program to play percussion instead of piano notes. Define your own grammar for percussive scores, and have the program play your percussion Sequence repeatedly, creating a rhythm track.

  • Exercise 17-3. Read up on the details of the PCM audio format, and then implement an AudioInputStream subclass that synthesizes audio data (such as a pure sine wave) in this format. (This is an advanced exercise.)

Get Java Examples in a Nutshell, 3rd Edition 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.