Connecting the dots
|
Making OSCAR's agents work together
|
OSCAR's three agents, |harmgen|, |melplayer|, and |tempo_duple|, work together to generate new output notes. To accomplish this, the agents are interconnected in a number of complex ways; these connections are maintained inside the |manager| patch, which was introduced earlier.
|
Manager
|
|
The simplest manner in which these agents interact is via their timing. |tempo_duple| accepts an input MIDI stream from the user and outputs a series of BANG messages (which establish tempo) and beat period measurements (which establish note duration). |tempo_duple|'s interaction with the other agents is simple: when the other agents receive a BANG from |tempo_duple|, they generate a new note, with the duration specified by |tempo_duple|'s last output beat period.
The interaction between |harmgen| and |melplayer| is much more complex; these agents work together to produce new output notes. A BANG from |tempo_duple| prompts both agents to generate suggestions for new output notes. Each agent makes three suggestions, which are handled by |manager| in a subpatch (contained in the object called |pd|).
|
Coordinator subpatch
|
|
|
The agents' suggestions for new output are sent to this |coordinator| subpatch. |melplayer| outputs suggested melodic intervals relative to the system's last output, and |harmgen| outputs suggested harmonic intervals relative to the current user input; both of these intervals must be converted to actual note numbers before they can be compared.
|
The three suggestions from |harmgen| are received and stored in the right inlet of three |-| objects. The user's input is sent to the left inlet of the |-| objects; the suggested harmonic intervals (which will generate the lower voice) are subtracted from the user's input (the upper voice) to yield note numbers. Similarly, the suggestions from |melplayer| (which can be positive or negative intervals) are added to the note number of the last generated output note, yielding three note numbers that are |melplayer|'s suggestions for the next output. The converted suggestions from both agents are sent into the |pd| "comparer" object at the bottom of the patch.
|
Comparer subpatch
|
|
The |comparer| subpatch looks for agreement between |harmgen| and |melplayer|. If the two agents both suggest the same note number, the mutually-suggested note is output. If no agreement is found, |harmgen|'s first suggested note is output. Once leaving this subpatch, the selected note number is used to generate OSCAR's next output note.
|
|
|
|