Java Glossary : MIDI

CMP home Java glossary home Menu no menu Last updated 2004-06-28 by Roedy Green ©1996-2004 Canadian Mind Products

Java definitions: 0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

You are here : home : Java Glossary : M words : MIDI.

MIDI
Musical Instrument Digital Interface. Java 1.1 does not officially support MIDI music files, but on some browsers this trick will work:

getAppletContext().showDocument ( new URL ( getCodeBase(), "test.mid" ) );

They would need a Midi player like Crescendo installed. The music must exist in a file accessible via URL. You can't use this trick to play some music you have sitting in a byte array.

With JDK 1.3, Java supports MIDI in a massive way. javax.media.sound.midi provides interfaces and classes for I/O, sequencing, and synthesis of MIDI. javax.media.sound.midi.spi supplies interfaces for service providers to implement when offering new MIDI devices, MIDI file readers and writers, or sound bank readers.

To embed a MIDI file on your web page, all you need do is add some HTML like this: <a href="sound/bach2.mid">. You usually want some sort of gif to indicate a playable link. So long as the browser has a midi player installed, just clicking on that link will cause it to play. Try it here:

Bach Bach: Suite 2

Here is a simple way to embed a midi file and have it automatically play <EMBED SRC="sound/bach2.mid" HIDDEN="TRUE" AUTOSTART="TRUE" ALIGN=LEFT> It appears to work with Opera, IE and Netscape.

Using JavaScript, it is also possible to cause a song to start playing automatically as soon as a page is loaded. The Crescendo people have written a tutorial on how to do that. Be warned, the tutorial is strongly biased in favour of using the Crescendo player. They also have a wizard that will modify an existing page for you to add the necessary html to play a midi or MP3 file when the page first loads.

Digital Ear : Real-time Audio (.wav ) to MIDI converter ! is a $120.00 USD real time utility to convert midi to wav format, and astoundingly, wav to midi. That utility does much what a human would do listening to music and writing down the equivalent notation. The raw result needs touch up, at least to assign a voice, and requires a monphonic (single voice, no chords or polyphony) source, but it is a way of extracting compact, malleable midi from ordinary sound sources. If you use your own voice as input, it can correct pitch but preserve vibrato.

MIDI came out in 1991. An augmented, upward compatible MIDI-2 came out in 1999. DLS (Downloadable Sounds) enables sampling, making sounds with a wavetable sound capture rather than mathematicallly. XMF (eXtensible Music Format) combines MIDI and DLS in one file.

The MIDI stream sent to instruments over the 5-pin DIN serial connection contains no embedded timing information. The notes are sent the instant they are intended to be played. MIDI files on the other hand need embedded timing information to track when to send the commands.


CMP logo
CMP_home
home
Canadian Mind Products CSS
HTML Checked!
ICRA ratings logo
mindprod.com IP:[24.87.56.253]
Your IP:[80.134.30.163]
You are visitor number 2210.
Please send errors, omissions and suggestions
to improve this page to Roedy Green.
You can get a fresh copy of this page from: or possibly from your local J: drive mirror:
http://mindprod.com/jgloss/midi.html J:\mindprod\jgloss\midi.html