XNA Creators Club Online
Page 1 of 1 (4 items)
Sort Posts: Previous Next

Ideal Way to Play MIDI Sounds in C#

Last post 10-04-2008 5:37 PM by dud88dud. 3 replies.
  • 08-14-2008 3:46 PM

    Ideal Way to Play MIDI Sounds in C#

    Is there a way to dynamically load (on the fly) .mid files and play them in C#, allowing me to play multiple files at the same time while also being able to change volume and frequency/speed?
    I've tried using multiple Libraries like:
    DirectX.DirectSound (only for .wav's),
    DirectX.AudioVideoPlayback (works with MIDI's, but is outdated and no control over speed or frequency),
    DirectX.DirectMusic (sounds perfect, but isn't managed and I'm working in C#...), and
    XNA.Framework.Audio (can't load files at runtime, to my knowlege).

    At this point AudioVideoPlayback seems to be my best option, but I'm sure one of you knows better than I do, so if you think you know a way to use any of these Libraries or a different one to do what I'm asking, please post a reply!

    Also, I'm sure at this point someone's about to suggest not using MIDI files. I understand where you're comming from, but I'm trying to make my program be able to load, play and mix a variety of audio types, to be as user friendly as possible.

    If it helps, here's a brief description of my project:
    -uses XNA (though, I don't think that makes much of a difference)
    -is a Windows App
    -designed to help the user create RPG-esque games (thus the dynamic loading of sounds)

    Thank you in advance for any help you can give me! I await you reply.

    P.S. I know I've probably said something silly at this point, but please bear with me. I've a right to foolish aspirations!

    -Thomas
    -Thomas
  • 08-14-2008 5:20 PM In reply to

    Re: Ideal Way to Play MIDI Sounds in C#

    MIDI sucks on modern Windows. They even went so far as to remove MIDI class device support under Vista 64.

    The best you can do is to use DirectMusic (which is deprecated) and write a managed wrapper for it, or call it using P/Invoke.


    Jon Watte, Direct3D MVP kW X-port 3ds Max .X exporter kW Animation source code
  • 08-15-2008 2:20 AM In reply to

    Re: Ideal Way to Play MIDI Sounds in C#

    I agree, MIDI's not the greatest thing ever, but like I said, I'm trying to accommodate different file types. So, making a managed wrapper for DirectMusic sounds ideal, but I've never done anything like that before. Can you point me to a resource that could  help me out?
    -Thomas
  • 10-04-2008 5:37 PM In reply to

    Re: Ideal Way to Play MIDI Sounds in C#

    Hey guys. If anyone wanted an answer, I found one. Direct music has a C# port, that's been working alright for me. You can find it here. It's called DirectMidi.Net, and it's basically what I asked for: a C# wrapper of a C++ wrapper for DirectMusic. It's a great tool for MIDI in C#.
    -Thomas
Page 1 of 1 (4 items) Previous Next