Play Sound

PlaySound is not implemented i the Javascript version of GeoGebra yet. For that reason, the worksheets on this page must be viewed on GeoGebraTube using "View as Java applet" .

 

piano
Try it on GeoGebraTube: Piano.

As of GeoGebra 4.0, you can play sound in GeoGebra. You can play a sequence of notes by specifying the notes, or you can play sound from a MIDI file, or you can play the sound of a function. At Trigonometry - Music it is shown how to play the sound of a function.

Play notes

To play the note A in octave 5 using the instrument piano, use the command:

	PlaySound["A",0]

If you want to play a note in another octave than 5, you specify the number of the octave after the note. Specifying "A4" as note, plays the note A in octave 4. The names of the notes are the names used in the topmost applet on this page. If you want to use another instrument, change the second parameter to another integer. A trumpet has the number 56, the code PlaySound["A",56] plays note A using a trumpet.

You can play a sequence of notes by separating them by blanks in the first parameter. If you want to use different instruments for the notes in the sequence, specify the instrument m by I[m] before the note/notes. The code PlaySound["A B C",0], plays the notes A, B, C using a piano. The code PlaySound["I[0] A B I[56] C", 0], plays A and B using a piano, and C using a trumpet.

Play a MIDI file

piano
Try it on GeoGebraTube: Play composers!

You can play a MIDI file (.mid-file) by using the command PlaySound["filename"]. You turn off the sound that is currently being played by using the command PlaySound[false], and you resume playing the sound using the command PlaySound[true].

Using the command PlaySound[true] may cause trouble on a web page. By turning several sounds on and off, you may get to a situation where two songs are playing and you cannot turn them off. Also note that if this happens, navigating to another page does not turn off the music.

references:

The notation of the notes from Wikipedia - Note, the notation varies in different countries

More information about the command PlaySound on GeoGebra - Manual:PlaySound Command

A list of the MIDI instruments is shown at General MIDI GM Mode Explained

The Beethoven, Grieg and Chopin MIDI files from Classical Piano Midi Page

by Malin Christersson under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 Sweden License

www.malinc.se