Snapping a signal to musical scale?


    Jul 01 2021 | 7:57 pm
    Is it possible to "snap" a signal to a desired values?
    Let's say I have [rand~ 0.5] and after it [scale~ -1 1 0 2000] and this controls a frequency of an oscillator and the signal flies around randomly between 0 and 2000 Hz, but I want it to gradually slow down at desired frequencies of a musical scale and eventually totally stop at these frequencies, something alike sample and hold.
    How do I achieve this?

    • Jul 02 2021 | 10:18 am
      i would use [trunc~] to truncate to full integers - or [round~] to round to the next integer - and then you can use [+~] to remap these integers to every value you wish. same story as with [mtof~] output.
    • Jul 02 2021 | 10:37 am
      oh wait, i forgot something.
    • Jul 02 2021 | 11:27 am
      so, for major and minor you could use the signal version of [110.chrom2majmin] - which does this: expr (((($i1+((($i2==1)*5)+1))*12)/7)-((($i2==1)*9)+1))+$i3 for the signal version, copy the blue patch. (ignore the missing subpatch) input: signal (notenumber), major/minor 0/1, transpose 0-11 int output: signal (diatonic scale) if you want to use more church modes than major and minor, simply add numbers to the the [* 5]---[+ 1], but replace [* 5]---[+ 1] by a [+ 5] and substitute the 0/1 input from the toggle with a menu with the numbers of a diatonic scale (or with all 12 keys from 0-11 if you think its fun) expr ( int((notenumber + 1 + mode) * 12) / 7 + 3 + transpose ) as you can see, ionian - or modern-major - will be "+6" already, that is where the * 5 comes from.
    • Jul 02 2021 | 7:22 pm
      thanks, ill check a lot it out