播放MIDI的最佳方式听起来使用C# [英] Best way to play MIDI sounds using C#

查看:682
本文介绍了播放MIDI的最佳方式听起来使用C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图重建使用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!

这篇关于播放MIDI的最佳方式听起来使用C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆