Skip to main content
Home Forums Silverlight Design Video and Media Playing MIDI through Silverlight
8 replies. Latest Post by odahan on November 3, 2009.
(0)
generalg...
Member
6 points
5 Posts
09-08-2007 12:06 AM |
More specifically, would it be possible to create a MIDI file in memory and then load it into some media playing object that silverlight might have? I'm not looking to communicate with MIDI devices, just play MIDI files...
chad.cam...
Participant
1918 points
332 Posts
09-08-2007 8:56 AM |
Hello generalgoodtimes,
Silverlight does not support the MIDI format. However, you could create a MIDI file in memory and then encode it into the .mp3 file format using a workflow that uses a command line application. You could then play the MP3 file within a MediaElement.
If this answers your question, please select "mark as answer", otherwise, please post a follow up question.
Thank you,
Chad Campbell
09-08-2007 10:50 AM |
Hi Chad,
Thank you for your reply. While that is good news, its only slightly what I'm looking for. Let me ask you this - do you suppose it would be possible to both create the MIDI file in memory and then encode it into an MP3 file within the same Silverlight application? I see no reason why that would not be possible - but then here's the big question - can MediaElement play a file that was created in memory? I spent a good deal of time investigating this on MSDN last night, and I don't think it can - but maybe I'm missing something... Any help or other ideas would be greatly appreciated.
Rob
09-08-2007 12:14 PM |
You could encode the .midi file as an MP3 file, then use the SetSource method and an downloader object.
09-08-2007 2:25 PM |
That is what I was thinking, but I'm trying to do this without saving the MP3 file to disk, whether locally or remotely. I want to do this all in memory - and my understanding is I can't give a byte buffer to Downloader.SetSource - did I just miss something in the documentation that would allow this, or is there another way to go about that?
Thanks,
electrog...
15 points
20 Posts
11-10-2008 5:14 PM |
Hi,
I find it very interesting, but ...
" using a workflow that uses a command line application. "
could u explain, these phrase, with a little more of detail?, thank you very much
djprod
334 points
65 Posts
11-10-2008 9:19 PM |
Why not just add the Windows Media Player to your html page it plays midi files:-
<object id="Player" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" style="position:absolute;top:10px;width:64px;height:54px;" ><param name="autoStart" value="false"/><param name="UImode" value="none"/><param name="stretchtofit" value="true"/><param name="volume" value="100"/><param name="Url" value="12popcorn.mid"/><param name="windowlessVideo" value="true"/></object>
Accessing it is easy:-
HtmlPage
Regards
Marc.
loarabia
80 points
25 Posts
11-15-2008 2:53 AM |
It seems to me like you should be able to create the MIDI content, encode it in memory into an Mp3 (or WMA) where the contents are written to a MemoryStream and then use MediaElement.SetSource to set the source to the MemoryStream containing the freshly encoded Mp3 content. The only place I can think of here where you might run into trouble is if you continued adding to the MemoryStream after you had already passed it to the MediaElement for playback.
odahan
1625 points
291 Posts
11-03-2009 4:51 PM |
I just looked at this thread and I'm feeling a bit like a martian discovering strange human behavior :-) It seems obvious for everyone here "to encode a Midi file into a MP3".
Well.. I'm not bad at C#, I'm also a composer using a lot of midi devices and digital things...So I know a little bit about all this stuff, and I can say one thing : it is not obvious to "encode" a Midi into a MP3 !
Midi file does not carry any sound, just some data about what notes are played, when and how long (plus some other info).
The only way to "encode a midi file into a MP3" is to create a synthesizer that will play the score, get the resulting Wav and then, ok, encode the latter into MP3. Two things that are far to be obvious !
But it seems to be simple for everyone in this thread so, I'll just add : Good luck guys ! :-)
(and do not forget to publish your source code, just the little tricky part that can "encore a midi into a mp3", I'd love to get it :-) )