1) how can one design a max patch which only lets through incoming notes belonging to a certain scale, such as D major scale?
2)how can one design a max patch which only lets through notes belonging to a certain scale, such as D major scale, and where every note played below midi note number 60 is being accompanied by a fifth and an octave above.
3)how can 1 design a max patch which adds 2 randomly pitched notes within an octave above an incoming note.
Number 2 and 3 are dead simple, look to the comparison and arithmetic operators. You can do whatever you want with these.
Number 1 is a bit trickier, but when I did this I used % 12 on the incoming notes, then sent them through [select]. The [select] had all the note numbers that weren’t in the scale, so any that were would come through the rightmost outlet. In the case of a major scale, the notes are:
0 2 4 5 7 9 11
where 0 is "C" and 11 is "B", though it’s abstracted to any major scale.
so you use
[select 1 3 6 8 10]
and anything that gets through is in the major scale. Making it "D major" versus "C major" or "X major" (just the raw set of whole-half steps) is up to you to determine, but it can be done with an arithmetic operator placed appropriately… like take the incoming note, subtract 2 (half-steps), then on through the % 12 and the [select]. This would give you D major.
If you want tons of scales, you probably won’t want tons of [select] objects, so use a [coll] or a [matrixctrl], then you can compare the given note with the whole list using [iter] or better yet, one of the [zl] comparison functions. The [matrixctrl] is probably the best route as it gives the user a way to make any scale, and can have tons of presets stored in it.