Chapter 24. Executing Scores

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.

Which kind of player a user should use—internal, using JavaSound, or external, using an operating-system-dependent executable—is the user’s choice. Some platforms may have good JavaSound support but no installed executable player. Others may have a great player with looping and pause support and a graphic equalizer, and JavaSound may not provide the best option (even if the score support module were to implement such features). So this chapter will demonstrate how to let the user decide, in general ...

Get NetBeans: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.