views:

231

answers:

2

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 newfweiler.com -- 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.

+1  A: 

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.

John Gietzen
A: 

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.

http://translate.google.com/translate?prev=hp&hl=en&js=n&u=http%3A%2F%2Fflash.html.it%2Fguide%2Flezione%2F2936%2Fmidi-player%2F&sl=it&tl=en&history_state0=

sehugg