Basic list enumeration with omloop.
pgmout,omloop, omif and om<.
In this example notes are generated and are parsed onto two midi channels depending on their pitch range. All notes from and above 6000 midicents will be played on channel one. Other notes falling under 6000 midics will be played on channel 2 in order to get different instruments playing the melodic line in the CHORD-SEQ module.
This patch contains two different sections: Section A which task is to send midi messages, and section B-C-D which concerns note generation.
A: pgmout is a midi function which sends program change messages to midi internal or external devices, such as Quicktime midi instruments or via the Macintosh port to an external expander or synthesizer. This function returns nil value in the listener. Evaluating x-append which is connected to the outputs of the two pgmout modules is a practical way to evaluate simultaneously these modules. the first pgmout sends the program change 56 to channel one, while the second module sends program change 1 to channel 2.
B: In B we have created a red patch as in tutorial 8.
In this patch we have reproduced the pitch random generation patch (A ) found in tutorial 12. This is a practical way to abstract our processes we oftenly use. Notice that we have added an input for the <times> argument of repeat-n in order to access this parameter from within the main patch. Notice that note generator (B) is in eval-once mode.This is because its output is connected to two modules (CHORD-SEQ and omloop) . Remember if our patch note generator was in its normal mode it would have yeilded two different results one in the CHORD-SEQ module, the other in omloop resulting in a mismatching elements (notes and channels).
C: In order to understand the control structure of omloop we will see in this example a basic and most commonly used way of iteration applyed to a list.
omloop being a special module ( not a class ) is the only function which must be edited, and so the user must double-click on its icon in order to open omloop's editing patch.
Opening it, we distinguish three groups of modules: the iterators, the accumulators and the output modules. (For further information about these, please consult the OpenMusic Reference.) .These modules are specific to omloop and can only be accessed within this module. When omloop is in its editing mode (i.e opened) , it cannot be evaluated. One must first close the module and evaluate its output as any other function. Notice that omloop doesn't have any output/input icons. In order to add inputs one must select omloop's icon first and then option-right arrow to add a new input, or option-left arrow to remove one. These newly added inputs will be found inside omloop's editing window.
Let us now examine our loop patch. We will use omloop to test each member of the list output from our note generator patch. As we can see, the patch is divided into four functional parts. First we will use the listloop iterator (B), which will enumerate each member of a list and send it to C. In C, the enumerated element will be an argument to any process we choose. Here a midicent will be tested using omif (c.f tutorial 14) with the om<. If the midicent is smaller than 6000, omif will output 2, else 1. This result will be collected by the collect module. The result in a list form will be output by the module finally. The collectors in most general cases are always connected that way (i.e the first output to eachtime which launches the evaluation sequentialy, and the second output to finally which outputs the total result).
D: Now let us verify our result in theCHORD-SEQ editor choosing in the left menu the 'channel' mode.
If we play this example on a midi device after sending our program change with pgmout, we will notice that this melodic line is played by two different instruments depending on the pitch range.