简体   繁体   English

将Midi Sequence写入文件

[英]Write Midi Sequence to file

I Have a console program, written in C, which generates short random musical compositions using the PortMidi library. 我有一个用C编写的控制台程序,它使用PortMidi库生成短随机音乐作品。 Ultimately I would like to write these sequences as either a midi or audio file. 最后我想把这些序列写成midi或音频文件。

I have found some explanations of reading and writing functions within the portmidi library: Pm_read() , and Pm_write() ; 我在portmidi库中找到了一些读写函数的解释: Pm_read()Pm_write() ; but, without examples, I am struggling to understand and implement this. 但是,没有例子,我正在努力理解和实现这一点。

Is there anyway I can export the entire sequence at once? 无论如何我可以一次导出整个序列吗?

If not, is it necesary to recursively read into a buffer and save individual midi notes? 如果没有,是否需要递归读入缓冲区并保存单个midi音符? Or do I need to read the whole sequence into the buffer and then save it? 或者我需要将整个序列读入缓冲区然后保存吗?

PortMidi doesn't have any way to do do the whole thing in one shebang (as far as I can tell), so you have to manually buffer all the output MIDI messages into an array and then save them to a file. PortMidi没有任何方法可以在一个shebang中完成所有操作(据我所知),因此您必须手动将所有输出MIDI消息缓冲到一个数组中,然后将它们保存到文件中。 A good example of this can be found in the receive_sysex() function at http://audacity.googlecode.com/svn/audacity-src/trunk/lib-src/portmidi/pm_test/sysex.c . 可以在http://audacity.googlecode.com/svn/audacity-src/trunk/lib-src/portmidi/pm_test/sysex.c上receive_sysex()函数中找到一个很好的例子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM