A javascript (jsui) object that quantizes the pitch of a midi note to an 8 step scale
Create a jsui object in a Max For Live or Max MSP patcher.
Select midi2Scale.js as the javascript file in the inspector of the jsui object, this object will now be refered to as midi2Scale.
On inlet 0 of midi2Scale connect the message "midiToScale $1" using a patch cord.
To inlet 0 of the message "midiToScale $1" send an integer value that represents the pitch of a midi note.
On inlet 1 of midi2Scale connect the message "setScale $1 $2" using a patch cord.
To inlet 0 of the message "setScale $1 $2" connect a dial that sends an integer value between 1-12, this dial will set the root note of the scale.
To inlet 0 of the message "setScale $1 $2" use a UI object of your choice that sends a value between 0-6. This will set the mode that the scale is calculated with.
The values 0-6 will correspond to the following modes [ionian, dorian, phrygian, lydian, mixolydian, aeolian, locrian]
to make this look better, use "pack" to pack the two values into and array
From outlet 0 of midi2Scale you will recieve midi pitch integers that fit within the scale you select.