First time here? Check out the FAQ!
x

How do I quantize MIDI note numbers to a scale?

0 votes
317 views
It's not coming into my mind: How could I quantize integers 0-127 to a scale like the d harmonic minor scale. Thank you in advance!
asked Jan 10, 2016 in Capytalk & Smalltalk by knut-kaulke (Adept) (1,870 points)

1 Answer

+2 votes
You could construct an array of what the pitch class intervals should be for harmonic minor:

#(0 2 3 5 7 8 11)

then use (!KeyNumber mod: 12) to index into that array,

(!KeyNumber mod: 12) of: #(0 2 3 5 7 8 11)

Then add the tonic and the octave to that interval for the Frequency field:

!Tonic nn + (((!KeyNumber  - !Tonic) mod: 12) of: #(0 2 3 5 7 8 11)) nn + ((!KeyNumber - !Tonic) // 12 * 12) nn

Does this do what you had in mind?
answered Jan 10, 2016 by ssc (Savant) (114,570 points)
Thank you for your prompt reply :) It works fine for me. I knew it has something to do with an array like of #:(....) but scaling back to tonic and octave in CapyTalk  was a challenge for me.
...