使用 OpenAL 和 SF2 以编程方式播放 MIDI

发布于 2024-10-04 13:08:10 字数 189 浏览 1 评论 0原文

我可以使用 TiMidity++ 从头开始​​创建一个基本的 MIDI 文件并进行验证,并且我了解足够的 OpenAL 来播放文件中的流媒体源。

我只是想知道是否可以用 C 创建一个程序来通过读取 SF2 和 MIDI 文件并使用 OpenAL 播放声音来播放 MIDI 文件。我需要使用另一个库吗?我想提前知道,因为 SF2 格式看起来相当复杂。

I can create a basic MIDI file from scratch verified using TiMidity++, and I know enough OpenAL to play a streamed source from a file.

I'm just wondering if it's possible to create a program in C to play MIDI files by reading in a SF2 and MIDI file and using OpenAL to play the sound. Do I need to use another library? I want to know beforehand because the SF2 format looks pretty complicated.

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

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

发布评论

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

评论(2

梦在深巷 2024-10-11 13:08:10

核心音频就在这里!

如果您在 Mac 上执行此操作,DLSMusicDevice 会执行您想要的操作。

如果您使用的是 iOS,则需要“手动”完成很多工作,但这是可以管理的(也很乏味)。如果您选择这条路线,请查看示例代码“mixer host”。

Core audio is where it's at!

If you are doing this on a mac, DLSMusicDevice does what you want.

if you are on iOS, you will need to do much 'by hand' but it is manageable (tedious, as well). If you go this route, look at the sample code 'mixer host'.

糖果控 2024-10-11 13:08:10

您需要使用 CoreAudio。使用连接到 IOUnit 的采样器创建 AUGraph。查看AudioUnit框架中的头文件AUComponent.h。完成音频图设置后,您可以使用以下函数来播放音符:

MusicDeviceMIDIEvent(sampler, status, note, velocity, 0);

You need to use an CoreAudio. Create an AUGraph with a Sampler connected to an IOUnit. Look at header files AUComponent.h in the AudioUnit framework. Once you've got your audio graph setup you can play a note using the following function:

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