#### snowsh

##### Well-known member

I have a function that generates numbers. I need to "quantise" these numbers to the nearest number that fits a desired scale.

example of the array that holds the allowed notes as intervals from a set key:

Code:

```
uint8_t key = 60; // 60 = c4
uint8_t intervalArray[7] = {0,2,4,5,7,9,11,12}
```

my number generator could spit out any number within a defined range. How do I go about mapping these numbers to my interval array. It needs to first off determine what the entire map is raange 24 (c1) to 108 (c8) based on the given root note and interval map, and then adjust up or down the generated number to match to the closest allowed note. Point me in the right direction!