An array is created from external sensors and that array is constrained to a scale.
Here's the sample code:
(
~weight = 70;
~array = ((~weight - 12) .. ~weight);
l = Scale.majorPentatonic.degrees; // pentatonic scale
j = (~array).collect { |i| i.nearestInScale(l, 12)}
)
This produces an array, but repeats notes that it matches to the scale, for example:
[ 57, 57, 60, 62, 62, 64, 64, 64, 67, 67, 69, 69, 69 ]
How do I filter this array to only unique values so it looks like this:
[ 57, 60, 62, 64, 67, 69 ]