Write Midi Sequence to file

317 views Asked by At

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?

1

There are 1 answers

0
RCramiro On

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.