Lab 12b Sound World
Game change
5.3.5

Lab 12b

Lab 12b Sound World

The goal of this lab is to show you how you can add musical and sound effects to your game.

Game change

The library javalib.soundworld.jar supports the design of the interactive games using imperative style (mutation) with the additional support for playing MIDI tunes. The sounds are specifies as notes to be played on the given instruments as the onTick and onKeyEvent requests are processed. In the case of onTick method, you also specify the duration (how many ticks should a sound be played.) The sounds initiated by the onKeyEvent method play while the corresponding key is pressed.

The tests for the methods with effects are even more difficult. The sample program illustrates how you can test that the program is playing the desired sounds, but this is a truly difficult task. In your work, do the best you can, but we will not require a complete code coverage for testing that the correct sounds are played.

The sample program files

Download the file Lab12b.zip and unzip it. It contains the following files:

Build a project, import into it the given source code and the image. Add to your project the downloaded jar file and run the game.

Read the code to see how the sound is generated. The complete documentation with samples and explanation can be found at the javalib worlds web pages.