This example demonstrates how to harmonize a single MIDI note with multiple pitches.
This is an example that generates a sixteenth-note rhythm, formats the information as MIDI note messages with midiformat, and stores them in a seq object, which can be saved as a MIDI file with the write message.
To create a poly-rhythm generator, this example chooses a division and articulates every attack point of that division. Use a metro synched to the transport to specify the divisions (or the tempo object, if preferred), and then use a counter (or a % object with the output of tempo) to specify the articulation points.
Load a MIDI file into detonate, send it a “start” message, then send it “next” messages to output each note. Notice that the leftmost outlet sends out the delta time (in ms) until the next note in the score; that value can be tested, and if it’s sufficiently small, say under 50 ms for example, that means that the next note is practically simultaneous with the current one. The example then sends an additional ‘next’ message.
This exmaple demonstrates how to synchronize MIDI note length with a tempo determined by the transport object. The translate object has a "transport" attribute which allows control through the transport object.
This example shows how to get a complete list with all currently played notes using bag object. In this example we are also using the thresh 0 object in order to output all notes being held by bag as a single list.
For producing a score out of time and then saving as a standard MIDI file, detonate is the best way to go, and it can save in either format 0 or format 1. Admittedly, you could save a format 0 MIDI file with text and seq by writing the text file, reading it back into seq, then writing that as MIDI, and it could all happen in a few milliseconds.