Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
In Chapter 21, we explored how to support execution
of scores in a simple fashion: by directly interpreting the textual
stream of the score using the Score class and
converting it to a JavaSound audio stream to be played immediately.
However, since then we have added the ability to compile scores into standard audio files. These could be played instead of the score file itself. One way of playing these audio files is similar to what we did before: the audio file can be opened as a byte stream by the IDE when Execute is selected by the user, and this stream fed to a sound channel to be played.
There is another possibility. Most operating systems that support
sound output include some kind of player that can play sound files
when run as a command. The common AU format that our compiler
produces is generally understood by such players. For example, on
Windows 2000, the mplayer2.exe command can be
passed an audio file; on many Linux systems, play
does the same.