使用随机生成的合成器自动将 MIDI 转换为 MP3

发布于 2024-12-15 08:04:54 字数 1539 浏览 1 评论 0原文

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

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

发布评论

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

评论(1

不疑不惑不回忆 2024-12-22 08:04:54

好的,这里有几个不同的问题,每个问题都有自己的困难。

MIDI 到 MP3 转换

假设您想要 MIDI -> SF2-> MP3,Timidity++ 源代码将是一个很好的起点。 Timidity++“可以通过将MIDI文件转换为PCM波形数据来播放它们”。 Timidity++ 的最新分支可以在 Github 上找到。

要转换为 MP3,您需要一个额外的工具。 LAME 将是一个很好的起点。将 Timidity 和 LAME 结合在一起,您可以通过 SF2 从 MIDI 转换为 MP3。该脚本说明了如何在不编写自己的应用程序的情况下实现这一点。

for file in *.mid do
    timidity $file -Ow -o - | lame - $file.mp3
done

随机合成

您问题的另一个要素涉及随机生成的合成器,实际上无法通过上述方法轻松解决。如果我正确理解这个问题,您需要执行以下操作:

  • 合成一些声音,其中合成的某些方面是随机的,
  • 随机选择要分配给每个 MIDI 通道进行播放的声音

SF2 主要是基于样本的格式,如果您本质上想通过 MIDI 播放随机合成器并将输出保存到音频文件,则会引入不必要的复杂性。

为了解决您的问题,我建议跳过 SF2 步骤,并查看音频处理框架,例如 Synthesis ToolKit ( STK)。 STK能够读取MIDI文件和声音合成。然后,您可以使用 LAME 将音频缓冲区转换为 MP3。

OK, there are few different questions here, each with their own difficulties.

MIDI to MP3 conversion

Assuming you want to go MIDI -> SF2 -> MP3, the Timidity++ source code would be a good starting point. Timidity++ "can play MIDI files by converting them into PCM waveform data". A recent fork of Timidity++ can be found on Github.

To convert to MP3, you need an additional tool. LAME would be a good starting point here. Stitching together Timidity and LAME, you can go from MIDI to MP3 via an SF2. This script illustrates how this can be achieved without writing your own app.

for file in *.mid do
    timidity $file -Ow -o - | lame - $file.mp3
done

Random Synthesis

The other element of your question, which concerns randomly generated synths, can't really be addressed easily through the above approach. If I understand the question correctly, you want to do the following:

  • synthesise some sounds where some aspects of the synthesis are randomised
  • randomly select the sounds to be assigned to each MIDI channel for playback

SF2 is a primarily sample-based format, and would introduce unnecessary complexity if you essentially want to play random synths via MIDI and save the output to an audio file.

To address your problem, I would therefore suggest skipping the SF2 step, and looking at an audio processing framework like Synthesis ToolKit (STK). STK is capable of reading MIDI files, and sound synthesis. You can then use LAME for the audio buffer to MP3 conversion.

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