3-Way Branch, Part 2

Here is another way to do the same thing, to start with random pitches between 24 and 48, and separate them out so that the low octave is constrained to a major triad, the upper octave is constrained to 5ths and octaves, and the two octaves in the middle play the major scale.

In this example, we simply switch the processed values through a 3 input switch. It is less general than the first example, perhaps more efficient. Mostly, it is just another way to do the same thing.

The first few steps are the same as the previous example:

1. Start with a Clock and a RandInt. Connect the Clock strobe Out to the RandInt Strobe input. Set the RandInt Range to 48.

Now you are getting a random stream 4 octaves wide. The task will be to separate that into the 3 streams and to constrain the streams as described above.

2. To test for the upper octave, values 37-48, use the Logic/Greater module. Connect In A to the output of the RandInt; set In B to 36. Now, whenever you get a value greater than 36, the output of the Greater will go True (1), otherwise it will stay at 0.

3. Blinky lights make visulaizing these kinds of tasks much easier, so throw in a Widgets/LED that will turn on when the Greater module goes True. Also, it may help if you document which of the three branches you are testing for, with the Toolbar "Document Workspace" tool. You see this in the example image, below.

4. To test for the lower octave, use GrEqual (Greater than or Equal) module, and reverse the test inputs, so the module tests for Less than or Equal. Connect the output of the RanInt module to the In B of the GrEqual, and set In A to 12. Thus, the module will go True (1) when the RandInt value is 12 or less.

5. Set up a blinky LED and doc label as in step 3.

The next step is not needed for the actual circuit, it is just to give the 3rd blinky LED.

6. As before, use OR logic to flag the in between values from 13-36. Connect the two test modules, Greater & GrEqual to the 2 inputs of an OR module. This gives False (0) values, when they are in the middle range.

There is no reason to invert the output from the OR module because the LED module can be set to turn on when it gets a 0 value. Get the 3rd Widget/LEd and click on the properties, and then click on the check box in the bottom left that says "On if = 0." This gives you the 3 indicator LEDS as before.

Here is where this patch becomes different from the first. This one uses a selection switch instead of on/off flags. One select number instead of 3 separate on/off values.

7. Get a Logic/Bits2Num module. Click on the Properties button, and click the Fewer button once, so there are only 2 inputs. Connect the outputs from the Greater and the GrEqual module into the 2 inputs. This makes the output 1 if the Greater (high octave) module is True; 2 if the GrEqual (low octave) module is True, and 0 if neither is True (mid 2 octaves).

8. Set up a Switch and then a FitScale module. Plug the Bits2Num into the Select input. Then type the values of the FitScale Scale inputs you need into the Select inputs. Sel 0 gets 1; Sel 1 gets 5; Sel 2 gets 7. Hold the mouse cursor over the FitScale Scale input label to see why those values are used. Plug the RanInt output into the FitScale In input, and the Switch output into the FitScale Scale input.

Now for each step the value of the RandInt will be tested, and according to the octave range, its value will be scaled by the FitScale module.

8. Set up a MIDIVoice module. Connect the Clock strobe Out to the MIDI module Clock input. Connect the FitScale modules to the Note input of the MIDI module. Connect the System module Play output to the MIDI module Play input. When you set the Toolbar Play button, you should hear sound.

[Return to Part 1] [Return to Tutorial Page]