Tutorial

This browser does not have a Java Plug-in.
Get the latest Java Plug-in here.

MIDI Output - Sending music to an external synthesizer Reload page to restart example
Playing back music with the internal JavaSound synthesizer limits the sounds and sound quality of your music. It take advantage of the array of external music synthesizers SoundCipher can send its output via the computers Musical Instrument Digital Interface (MIDI) output.

A note of warning to users of Apple's OS X operating system that external JavaSound output is not supported on Apple's Java implementation but you can install the Mandalone extension to use this feature. It  is available at www.mandalone.co.uk



The first line imports the SoundCipher library into the sketch. The second line sets up a SoundCipher instance called sc for use in the program.

The setup() method calls a static method that gets the current MIDI devices and prints them to the console window. This is for you information really and you may need to use this to change the next line that sets the desired MIDI output device. The number 1 may or may not be appropriate for your system. Be aware that the devices that are reported to the console include both input and output devices. Finally, the frameRate is set to 1 frame per second. This is used to control how often the draw() method is called; which in this program controls the music playback.

The draw() method is used to play a note which should be sent to the desired MIDI output. The pitch is a randomly selected from a C pentatonic scale between note 60 and 72; the octave starting at middle C.