I wrote an event capture utility that writes events generated by a MIDI keyboard to a text file.
How to use it: Start fragment_10.csd, and play your MIDI keyboard. When you are done playing, press control-c, or whatever key combination stops the Csound process. This will have generated a file called fragments_10_captured.csd. Now run fragments_playback.csd.
It doesn’t work perfectly, as the amplitude envelope in the playback file is off. However, this utility fits my needs since I’ll be re-orchestrating the output for different instruments. Since I have a deadline, I’ll squash this bug later when I revisit this topic.