简体   繁体   中英

Write Midi Sequence to file

I Have a console program, written in C, which generates short random musical compositions using the PortMidi library. Ultimately I would like to write these sequences as either a midi or audio file.

I have found some explanations of reading and writing functions within the portmidi library: Pm_read() , and 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? 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. 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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