note that the inversion of the fourth interval is therefore 12 - 5 = 7 semitones
note that if both intervals start on the same note (MIDI 57 in this case, of A), the ending notes of the interval and its inversion (62 and 50 in this case) will be an octave apart (12 semitones)
Playing an Interval Using a Broadcast
note the need for a broadcast / when I receive pair
note the difference between broadcast vs. broadcast and wait
Creating a Generic Play Fourth Stack
to a computer, a string is a series of characters (letters and numerical digits)
this code uses a new variable named direction to hold one of two strings: “up” or “down”
the value of the direction variable is set in the upper stack based on whether the value of the counter variable is even or odd
the mod function essentially gives the remainder of an integer division
thus counter mod 2 means to divide the value of the counter variable by 2 and tell us the remainder
for example, 1 mod 2 = 1, while 2 mod 2 = 0, and 3 mod 2 = 1
this little arithmetic trick differentiates odd and even numbers
as the counter increases, this little calculation alternates between returning 1 and 0
thus, if we increase the counter by 1 each time through the loop, it’ll alternate between setting the direction variable to “up” and setting it to “down”
the lower stack plays the starting note and then looks to see if the value of the direction variable is “up” or “down”
if it’s “up,” the lower stack plays the fourth interval (5 semitones above the starting note)
otherwise (else), the lower stack plays the inversion of the fourth interval (7 semitones below the starting note)
the final trick is not to increase (change) the counter by 1, but to use the pick random function to change it by either 0 (no change) or 1
this is the last block in the repeat 10 loop in the upper stack
the pick random function picks a number at random between the two numbers specified, which are 0 and 1 in this case
since there are only two choices (0 and 1), 50% of the time we’ll get 0 and 50% of the time we’ll get 1
in other words, 50% of the time the interval will stay the same (when 0 is selected) and 50% of the time the interval will change (when 1 is selected)
this plays more interesting music because it is unpredictable