Thanks Roman. For the actual pitch quantisation I used a similar approach in the end. Though for the MIDI case I stuck with the temporary 128 element array. Though this is simply calculated from the same set of 12 element arrays.

Best wishes,

Jeanette

Jan 1 2022, Roman Sommer has written:

Hi Jeanette,

If you want to reduce the amount of table elements, you could calculate
the offset from the key base note, take it mod 12 and have a 12-element
array for every scale you want to implement (pseudo-C ahead):

     bool minor[] = [true, false, true, true, false, true, false, true,
     true, false, true, false];
     uint32_t offset = 2; // key: D
     // add offset instead of subtract to ensure the result is positive
     uint32_t additive_offset = 12 - offset
     uint32_t index = (note + additive_offset) % 12;

     if minor[index]
        play_note(note);

Won't probably make much of a difference in performance really, but it
should make it easier to implement all scales in all keys.
Hope that helps! :)

keep grooving

Roman

"Jeanette C." <jul...@mail.upb.de> writes:

Gopod morning Fons!
Dec 31 2021, Fons Adriaensen has written:
...
There is code doing this [quantise frequency to scale] in zita-at1 (the 
autotuner). It has some
refinements such as an optional preference for the previous note.
I will look this up and isolate it - it may be difficult to find
as it is integrated with other functionality.
Many thanks, this is great! You are, as always, very kind.

Best wishes,

Jeanette

Ciao,

--
FA




--
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

I thought love was just a tingling of the skin <3
(Britney Spears)
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
https://lists.linuxaudio.org/listinfo/linux-audio-dev


--
 * Website: http://juliencoder.de - for summer is a state of sound
 * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
 * Audiobombs: https://www.audiobombs.com/users/jeanette_c
 * GitHub: https://github.com/jeanette-c

Our imagination
Taking us to places
We have never been before... <3
(Britney Spears)
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
https://lists.linuxaudio.org/listinfo/linux-audio-dev

Reply via email to