播放MIDI的最佳方式听起来使用C#听起来、方式、MIDI

由网友((耏)°(誐)°)分享简介:我试图重建使用MFC在C ++中使用C#编写的.NET最初是一个古老的节拍器应用程序。其中一个我快到播放​​时用来重新present节拍器点击的MIDI文件的问题。I'm trying to rebuild an old metronome application that was originally writte...

我试图重建使用MFC在C ++中使用C#编写的.NET最初是一个古老的节拍器应用程序。其中一个我快到播放​​时用来重新present节拍器点击的MIDI文件的问题。

I'm trying to rebuild an old metronome application that was originally written using MFC in C++ to be written in .NET using C#. One of the issues I'm running into is playing the midi files that are used to represent the metronome "clicks".

我找到了几篇文章网上有关.NET中播放MIDI,但大多数人似乎依赖于有人拼凑起来,并提供自定义库。我不反对使用这些,但我宁愿理解自己如何正在做的,因为它看起来像它的应的是大多是平凡的工作。

I've found a few articles online about playing MIDI in .NET, but most of them seem to rely on custom libraries that someone has cobbled together and made available. I'm not averse to using these, but I'd rather understand for myself how this is being done, since it seems like it should be a mostly trivial exercise.

所以,我失去了一些东西?抑或只是很难用MIDI .NET应用程序内?

So, am I missing something? Or is it just difficult to use MIDI inside of a .NET application?

推荐答案

我想你需要的P / Invoke出来的Windows API,以便能够从.NET播放MIDI文件。

I think you'll need to p/invoke out to the windows api to be able to play midi files from .net.

这$ C $的CProject文章做讲解如何做到这一点的工作: vb.net文章,播放MIDI文件

This codeproject article does a good job on explaining how to do this: vb.net article to play midi files

要改写,这是你需要的mciSendString以下import语句C#:

To rewrite this is c# you'd need the following import statement for mciSendString:

[DllImport("winmm.dll")] 
static extern Int32 mciSendString(String command, StringBuilder buffer, 
                                  Int32 bufferSize, IntPtr hwndCallback);

希望这有助于 - 好运气

Hope this helps - good luck!

阅读全文

相关推荐

最新文章