The assignment for Patcher4 is a little tricky. Given what you learned in the first Max MIDI tutorial, you can see how a comparison object can be used to control a graphic gate. Comparison objects include == (is equal to), < (less than), > (greater than), != (is not equal to), <= (less than or equal to), and >= (greater than or equal to).
Comparison objects (Boolean objects) compare two values. Values coming in the left inlet are compared to the object’s arguments. If the comparison is true, the object outputs a 1; false comparisons output a 0.
To use a comparison object to route data you need to first perform the comparison, and then use the result of the comparison to control a gate that allows the data to pass through. Since the arrangement of objects in a patcher can affect execution order, it is important to control that order.
In example patcher 4 (download RandomNotePatcher4.maxpat), the arrangement of the graphic gate below the comparison object means that data is first being passed to the gate and then to the comparison object – reversed from what we want. Max executes not only right-to-left, but also bottom-to-top. To solve the ordering problem I added a trigger object (t) to explicitly first send data to the comparison and afterwards send it to the gate.
To fix the ordering problem without using a trigger object you need to bring the graphic gate up to the same horizontal level of as the comparison, placed to the left of the comparison. That gets rid of the bottom-to-top ordering issue. Right-to-left ordering sends the data first to the comparison and then to the gate. You can download RandomNotePatcher4-fixed.maxpat to see it.
A simpler way to look for data matches (==) is to use the select object. The select object compares incoming data to its arguments. A data match causes a bang to be sent to the corresponding outlet. Since data is stripped away, you need to reintroduce it with messages. Download RandomNotePatcher4Select.maxpat to see it work.
Since the select object strips matching data but passes through non-matching data, you can do a “reverse” select. Type the data you don’t want as arguments to select, and then connect the non-matching data outlet to the note playing part of the patcher. RandomNotePatcher4SelectV2.maxpat shows this technique. If the number of non-matches is not too large to make typing problematic, this technique can be more efficient to program. You don’t need all the buttons – I included them just for illustration of what is happening.
Leave a Reply