views:

35

answers:

1

Hello!

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, it's not ready files from my server (or they should be created first).

Any approaches will be welcommed.

+1  A: 

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. ;)

Nik Reiman
Don't get me wrong, the user is not supposed to submit any midi, he will just tell (thru the UI) what he desires to be played, the server's engine should generate midi.In other words, the user shouldn't even know it's MIDI, also, it doesn't have to be synchronous, i.e. the user makes his selections then clicks 'Play', then I have to generate mid, record to mp3 and upload back to client.
Shimmy
Best idea looks like generate the playable wave (or mp3 or whatever) on the server and play it on the client. This way I can also asure that the sounds are always like configured in the server, even if the user has a crappy midi device. The questions are: 1) how long will take this conversion? 2) How do I do it, do you know any conversion tool; something like the following: data (note, velocity etc.) -> MIDI player on server -> MIDI<>Wave engine -> play generated wave file on client. I want to have the option to download a mid file as well.
Shimmy
I hadn't meant that the user is directly uploading MIDI files; presumably your user interface is taking notes and generating MIDI events from them. Either way, if you are going with a server-side MIDI->MP3 conversion, you're going to have to deal with MIDI files at some point or another. ;)
Nik Reiman
Regarding your other questions: 1. This depends a lot on the instruments you use. I recommend trying all plugins you are going to use in a real sequencer first to get a better idea of server CPU requirements. 2. This question is a bit beyond the scope here, but I see you already have a better idea about what you need to do based on your question here: http://stackoverflow.com/questions/3087277/
Nik Reiman
I made a little more research.I wouldn't want to give the user the raw MIDI, or at least not this is what I want to impress him with.I want to have my virtual MIDI, that its sound fonts are brilliant and doesn't depend on the client midi kazoo. so I actually need a MIDI server, that can play (it has to be played streaming audio, cuz the user has to be able to stop/pause/resume/seek etc.) many streams at once.
Shimmy