I'm brand new to Max, and I'm trying to build a counterpoint generator that outputs notes using random stepwise motion, but I'm having a little trouble in one specific area. In the patch I'm including here I'm trying to model stepwise motion in a diatonic scale. My approach was to randomly generate a number that indicates step up or step down and then to modify a stored value to get the next scale step. I have a number that stores scale degree and a number that stores octave. Later on I convert from scale degree to pitch class and then to midi note value, but I can't seem to get my step function to work.
Metro sets a clock for the Random 2 to send a 1 or 0 to a Select. If a 0 was sent, a message goes to the Add to add a -1 to the number box in the middle (current note). If a 1 was sent, a message goes to the Add to add a 1 to the current note. (The 0 button is simply a reset for testing purposes) If the current note number box reaches a -1 (ti below do) the number is supposed to be reset to 6, and the current octave should be decremented. If the current note number box reaches a 7, the number is supposed to be reset to 0, and the octave should be incremented. It's sort of working, but after a while the current note number box starts behaving bizarrely and I can't tell why...
Surely this function is possible in max -- can anyone show me the 'max' way to do this?