[LAD] Quantise MIDI note/frequency to musical scale: algorithm?

Sam Kuper sampablokuper at posteo.net
Fri Dec 31 09:25:36 CET 2021

On Thu, Dec 30, 2021 at 11:38:52PM +0100, Jeanette C. wrote:
> But, how to best quantise chromatic notes to a given musical scale
> like C minor or B Dorian? I would probably need some method to do it
> for both MIDI notes and in frequencies.

It sounds to me like you are asking for an algorithm that would decide,
for some input note or frequency that is not in the scale, which note or
frequency should be output.

For example: if the scale is C major, and the input is C#, then what
should the output be?

Reasonable answers might include C or D, because these are the closest
notes (i.e. have the smallest distance from input to output, along the

So, your algorithm could simply "quantize down" (yielding C in the
example).  Or, alternatively, you might prefer an algorithm that simply
"quantizes up" (yielding D in the example).

But I think you - entirely reasonably - hope for an algorithm that gives
the most musical result, and you also hope that this might be a topic on
which prior research has established such an algorithm.

Is my understanding correct?

If so, I'm afraid I don't know the answer - but perhaps somebody else on
the list will know it.

Good luck!

More information about the Linux-audio-dev mailing list