How can I play individual MIDI notes in a Web page?

I know of two ways to do it:

  1. Write an ActiveX control. Then it only works on Windows. I used to write ActiveX controls a long time ago, but now nobody likes to install them.

  2. Write a Java applet. This is OK if the user already has Java installed, but many users disable applets. This is the way I did it and you can see the result at -- if it happens to work on your particular setup. You'll need at least Java 5, although I suppose I could rewrite it in Java 1.2 if I had to. The "Real Time Sequencer" and "Java Sound Synthesizer" don't work for me; I think you have to install wavetables or something to make them work.

Most users have Flash installed, but I looked in the Flash and Flex documentation and did not see anything equivalent to javax.sound.midi.

There are several ways to play a MIDI file in a Web page, and you can find "Javascript Pianos" that play a one-note MIDI file whenever you press a key. You can't play multiple notes at once or hold the key down for a long note.

What I'm trying to do is the equivalent of javax.sound.midi.Receiver.send(midiMsg, -1) using only what most people typically have installed on the machine.

Was it helpful?


Use Web Audio API to play sounds and .mid-files. See example of MIDI player at

Use Web MIDI API (Chrome supports it) to listen MIDI keyboard. See example at


Java is still probably going to be your best bet, even with the few users disabling it.

I use NoScript, and I can whitelist a site. I would say that most users would probably do the same if you provide compelling content.

Found the following (translated from Italian). I'd say Flash is the way to go. If you want to be ghetto you can just get 88 or so piano samples and play them against a timeline.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow