Playing .MIDI files on a Windows Mobile 5.0 Smartphone

Does anyone know how I might be able to play a .MIDI file on a Windows Mobile 5.0 smartphone

The PlaySound() API plays .WAV files, but not .MIDI files. Without using a 3rd party MIDI SDK, is there any built-in WinCE APIs that can play .MIDI files

My platform is .NET CF 2.0.

Thanks,

Rob



Answer this question

Playing .MIDI files on a Windows Mobile 5.0 Smartphone

  • NextCodec

    Perhaps this will help you in your quest for one-line-MIDI solution.

    http://msdn.microsoft.com/chats/transcripts/mobileembedded/06_0628_msdn_wince.aspx

    andyraf_msft (Expert):
    Q: I know there is support to play .MIDI files on Windows CE using the Wave audio APIs, but this requires that you manually understand the MIDI file format. How can I play something like Alarm4.mid using sndPlaySound API The documentation suggests ..(more)
    A: sndPlaySound only understands .wav file formats. The MIDI file format is quite different, so you can't use sndPlaySound. I should also note that the sample MIDI synth only supports basic sine-waves, so you can't play an arbitrary MIDI file and expect it to sound good.

    andyraf_msft (Expert):
    Q: ...you can do something like sndPlaySound("Alarm4") and it will look up the sound in the registry and play it for you, but I've had no success. Is it possible to play .MID files on Windows CE 5.0 without the use of a third party MIDI SDK player
    A: You might be able to google WAVEFORMAT_MIDI to find some sample code that shows how to parse a MIDI file and play it back through waveOut.

    andyraf_msft (Expert):
    Q: Follow up re: MIDI files: How can I get the phone to play Alarm4.mid I just want to be able to reference/play the Notification sound, which by default is Alarm4.mid, etc. How do I do this programatically without a third party like fMod. Q: re: WAVEFORMAT_MIDI. Isn't there some way to just tell the phone to "play" Alarm4.mid or whatever the current configured Notification sound file is Windows Mobile OS does this when a notification event is triggered.
    A: If you're an OEM, you can use the PlayEventSound or PreviewEventSound functions that are defined in the oak. However, those aren't available as part of the SDK. Feel free to send me email and if I find a better solution I'll let you know.



  • sam1996

    No versions of Windows Media Player for Pocket PC or Smartphone are available for download from Microsoft. for more details:

    http://www.microsoft.com/windows/windowsmedia/player/windowsmobile/faq.aspx#2_1



  • vijayalakshmi

    Yeah, I do understand that I can learn the MIDI file specification and figure out how to open up "\Windows\Alarm4.mid" and play it using the WaveOut APIs, but all I really want to do is pass the .MID file to Windows PlaySound() and have it play--just like it does with .WAV files.

    Clearly the OS is capable of doing this because Alarm4.mid, for example, is the sound that is played by default for Notifications on a WM5 smartphone device.

    Does anyone know of any (undocumented ) APIs that might be able to do this Perhaps controlling Windows Media player silently from .NET is another method of accomplishing this

    Thanks,

    Rob


  • Mystagogue

    I've even better idea: you should be able to simply tell VS what your application should do without complicated mumbo-jumbo stuff like PlaySound(). Too bad, it does not work this way (yet), so you have to parse MIDI file and call into waveOut*, it’s not that hard. Clearly WM 5.0 notification program does just that as it can play Alarm4.mid without any OS level support and undocumented APIs. Alternatively you can try wrapping Media Player OM which I believe is available starting MP 10.



  • Caml01

    Ilya--all sarcasm and kidding around aside, I am serious and have no expectations that programs write themselves.

    I am not in the business of wanting to know and learn the MIDI file specification--or any other sound specification. It is not unreasonable to expect that the OS may provide services that can play .MIDI files just as it does for .WAV files. I am asking if anyone here has useful (note keyword: useful) information on such an (undocumented ) API.

    Windows Media Player automation is another idea that I had considered, but would prefer an alternative since I'd rather stay away from any potential side effects of automating and relying on Windows Media Player.

    Rob


  • montechristo

    waveOut* API can play MIDI. You would need to parse MIDI files. Keep in mind there are no instruments banks (good instruments bank might be bigger than Windows Mobile itself), so music quality might be not so good.

    http://msdn.microsoft.com/library/default.asp url=/library/en-us/mobilesdk5/html/wce51conmidisupport.asp



  • walter_verhoeven

    heh, those are my questions--Andy was responding to me.

    The APIs he references are for OEMs and not for the rest of us. Ah well.

    Rob


  • Simmy7

    Hi ,

    May i know how to play .wav file in the windows CE 4.2 device. is playsound() API is available for windows CE 4.2. where i can find this API.

    kind Regards,



  • Playing .MIDI files on a Windows Mobile 5.0 Smartphone