所以我终于找到了一篇帮助我上课的帖子
using System;
using System.Text;
using System.Runtime.InteropServices;
using System.IO;
namespace MidiProgram
{
/// <summary>
/// MCIPlayer is based off code by Slain.
/// Found here: http://www.sadeveloper.net/Articles_View.aspx?articleID=212
/// </summary>
public class MCIPlayer
{
private static readonly string sAlias = "TeaTimerAudio";
[DllImport("winmm.dll")]
private static extern long mciSendString(string strCommand, StringBuilder strReturn, int iReturnLength, IntPtr hwndCallback);
[DllImport("Winmm.dll")]
private static extern long PlaySound(byte[] data, IntPtr hMod, UInt32 dwFlags);
public static void Play(string sFile)
{
_Open(sFile);
_Play();
}
public static void Stop()
{
_Close();
}
private static void _Open(string sFileName)
{
if (_Status() != "")
_Close();
string sCommand = "open \"" + sFileName + "\" alias " + sAlias;
mciSendString(sCommand, null, 0, IntPtr.Zero);
}
private static void _Close()
{
string sCommand = "close " + sAlias;
mciSendString(sCommand, null, 0, IntPtr.Zero);
}
private static void _Play()
{
string sCommand = "play " + sAlias;
mciSendString(sCommand, null, 0, IntPtr.Zero);
}
private static string _Status()
{
StringBuilder sBuffer = new StringBuilder(128);
mciSendString("status " + sAlias + " mode", sBuffer, sBuffer.Capacity, IntPtr.Zero);
return sBuffer.ToString();
}
}
}
然而,如果一个问题,我似乎找到了一点点,整个程序使得
声音但显然输出到(microsoft gs wavetable synth)
在这个类中有没有一种方法我可以改变midi输出的方式,或者它只是像那种形式的MediaPlayer一样播放,请告诉我,这是我项目的最后一步只是一个简单的代码,并且我只想说我可以这样做我可以用整数或其名称指定midi设备,通过整数我的意思是midi设备的命令!