开发者

Play MIDI on client thru web?

I read this post, which explains how to play MIDI. I need to make a web-application that plays MIDI sequnces on users demand. How to do this? Should I simply make a Silverlight player that plays a MIDI file? So how do I transfer the file to the player? Or else, maybe there is a way to interact with the client's MIDI system.

NOTE: I need to create the MIDI sequences, i开发者_运维问答t's not ready files from my server (or they should be created first).

Any approaches will be welcommed.


First, it should be made perfectly clear that MIDI files are not themselves "played" in the same manner as an MP3. There is no actual music in a MIDI file; instead they just contain the notes which should be played by a synthesized music instrument.

I'm not sure if silverlight has a built-in MIDI synthesizer (like QuickTime does if you drag a MIDI file on top of it), and a bit of quick googling seems to confirm this hypothesis.

So if you are going to sequence arbitrary MIDI data, and do not have the ability to first bounce it down to MP3, then you should generate the sound on the server-side. If you have access to a .NET backend server, then you could use the VST.NET framework to create a VST host, send the MIDI through an instrument, and compress the resulting audio output to MP3. If you are working with Java, then you can use the jVSTwRapper, a similar library.

In the worst case, you can glue something together with C/C++ to load the VST plugin which will process your sound. This could then be launched as an external process by whatever server technology you are using.

But in all of these approaches, the strategy is basically the same:

  1. Get the MIDI file from the user and send it to the server.
  2. Open a VST plugin which will process the sound.
  3. Parse the events in the MIDI file, sending blocks of floating point data to the plugin with the appropriate MIDI messages.
  4. Take the output from the plugin and save it to disk somewhere.
  5. After all this has been done, take the output and convert it from raw PCM to MP3 (or whatever) via LAME or some other encoding framework.
  6. Send this file back to the user.

Note that step 3 is probably the hardest one in this process. There are lots of guides out on the internet about how to make your own VST host, including that one which I wrote. ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜