如何在 C# 中将 midi 转换为 wav/mp3?

发布于 2024-07-29 20:33:39 字数 85 浏览 5 评论 0 原文

我开始了一个小项目,其中包括处理 MIDI 文件。 我一直想知道,是否有任何 C# 或 VB.Net 代码可以在 MIDI 和 WAV 文件之间进行转换?

I started a small project which includes working with MIDI files. I've been wondering, is there any C# or VB.Net code that peforms that cast between MIDI and WAV files?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

勿挽旧人 2024-08-05 20:33:39

您可以尝试以某种方式与开源的 Timidity 进行交互:

TiMidity++ 是一个软件合成器。 可以将MIDI文件转换为PCM波形数据来播放; 给它一个 MIDI 数据和数字乐器数据文件,然后它实时合成它们并播放。 它不仅可以播放声音,还可以将生成的波形以各种音频文件格式保存到硬盘中。

FluidSynth 是一个最近更新的开源项目,其风格类似:

FluidSynth 是一款基于 SoundFont 2 规范的实时软件合成器。

您可以从 此列表

You could try to somehow interface with Timidity, which is Open Source:

TiMidity++ is a software synthesizer. It can play MIDI files by converting them into PCM waveform data; give it a MIDI data along with digital instrument data files, then it synthesizes them in real-time, and plays. It can not only play sounds, but also can save the generated waveforms into hard disks as various audio file formats.

FluidSynth is a more recently updated Open Source project in a similar vein:

FluidSynth is a real-time software synthesizer based on the SoundFont 2 specifications.

You can download some free SoundFonts (the actual PCM data used by these synthesizers to "render" the MIDI files) from the sites on this list.

血之狂魔 2024-08-05 20:33:39

MIDI 文件仅包含音符和控制器信息,不包含声音。 为了从 MIDI 文件中获取声音,您必须将该文件传递给音乐合成器或采样器,这会将音符和控制器信息转换为实际的声音。

实际上,这意味着任何给定的 MIDI 文件都没有特定的声音。 将 MIDI 文件转换为音频所产生的声音将根据合成器或样本库的质量以及选择执行转换的声音而有所不同。

许多声卡都能够从 MIDI 文件产生声音。 他们可以做到这一点,因为许多 MIDI 文件遵循称为通用 MIDI 规范< 的标准/a>. 通用 MIDI 规范提供了映射特定乐器分配的标准化方法。 如果您的 MIDI 文件符合此标准,您可以通过通用 MIDI 声音发生器播放它,并期望军鼓听起来像军鼓,而不是像小号。

如果您有复杂的音乐制作包,例如 Cakewalk,您可以加载 MIDI文件放入其中,它将使用其板载声音库为您渲染声音文件,这实际上可以比实时更快地完成(即它不必通过声卡播放声音并捕获输出)。

我想我想说的是这里面有很多变化的部分。 没有任何一段代码或类模块可以为您执行此操作。

MIDI files contain only note and controller information, not sounds. In order to get sounds from a MIDI file, you have to pass the file through a music synthesizer or sampler, which will convert the note and controller information into actual sounds.

In practice this means that any given MIDI file doesn't have a specific sound to it. The sound that results from converting a MIDI file to audio will vary depending on the quality of the synthesizer or sample library, and the sounds that are selected to perform the conversion.

Many sound cards have the capability of producing sound from MIDI files. They can do this because many MIDI files follow a standard called the General MIDI specification. The General MIDI Specification provides a standardized way to map specific instrument assignments. If your MIDI file conforms to this standard, you can play it through a General MIDI sound generator and expect a snare drum to sound like a snare drum, and not like a trumpet.

If you have a sophisticated music production package like Cakewalk, you can load a MIDI file into it, and it will use its on-board sound libraries to render a sound file for you, and this can actually be done faster than real-time (i.e. it doesn't have to play the sound through the sound card and capture the output).

I guess what I'm trying to say is there's a lot of moving parts to this. There isn't a single piece of code or a class module that will do this for you.

猫腻 2024-08-05 20:33:39

您可以购买许多程序来执行此操作(谷歌“将 midi 转换为 WAV”),但我从未遇到过可以执行此操作的公开可用的 .Net 代码(我认为其中一些程序是用 . Net,但源代码不可用)。

我有一个在线朋友正在开发一个商业 MIDI 到 WAV 转换器,但它不在 .Net 中,也不会开源。 正如罗伯特·哈维(Robert Harvey)提到的,这根本不是一个简单的任务,因为它基本上涉及编写自己的软件合成器(这是我自己内心的任务)。

There are a number of programs you can purchase that will do this (google "convert midi to WAV"), but I've never come across publically-available .Net code that does this (I think some of these programs are written in .Net, but the source code is not available).

I have an online friend who is working on a commercial MIDI-to-WAV converter, but it isn't in .Net and it won't be open source. As Robert Harvey mentioned, this is not a simple task at all, as it basically involves writing your own software synthesizer (a task after my own heart).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文