Samples for the Sound library
The Java code and applets for samples of programs that use the sound library.
The reason musical sounds make an interesting programming problems is that a musical composition has a number of dimensions: the pitch, the duration, the instrument that is played, the velocity (loudness), and the distance of the sound origin from the listener, to name a few. We do not deal with the velocity and distance (yet). The notes form chords (collections that do not have any ordering), chords or notes form sequences of tunes, and then we can play several of these sequences on several different instruments. Furthermore, the musical sequences can be represented visually in a number of different ways and the programmer can also design a number of variants for how the user triggers the playing of different sounds or musical sequences.
The first example illustrates the basic functionality of the library. The second is the classical interactive game with simple sound effects. The goal of the third one is to inspire the teacher and the student to explore the possibilities this library offers. Finally, we include two examples of student work: two very different implementations of the frogger game.
Warning Apparently Windows 7 does not make the MIDI synthesizer available in the web browsers unless there is an earphone or a microphone plugged in to carry the sound.
A simple example that uses the key press, mouse click, and the timer to play music.
Source code alone for this applet is here.
A worm game the classical game with added simple sound effects.
A comprehensive example of the potential uses of the sound library for musical explorations: Tunes Demo. It illustrates the variety of ways in which musical information can be displayed and manipulated. One can simulate a piano keyboard, play a piano roll, show the notes in the staff notation, color the notes that are played, and more.
Sample student work, The assignment was to make a frogger-like game and use the SoundLib to add sound. These projects used the first, very primitive version of the library.
A very musical frogger: student work.
A frogger with nice graphics and sound effects: student work.
|last updated on Thu Oct 28 14:32:14 EDT 2010||generated with DrRacket|