We will build a random series of fifteen notes withing a range of 5000 and 8000 midicents. We defined a series of constraints.
Om-random returns a random value within the given range.
At each step of the loop, collect stores the value.
The resulting list is returned to remove-dup, which removes equal values and octaves, give or take a quarter tone.
Length returns the number of items in the list.
This number is compared to 15 by om<.
The process goes on as long as the list has less then 15 items, as specified by whileloop.
The resulting chord-seq is returned to the outside of OMLoop by Finally.
Usually, remove-dup checks if two values are strictly equal. We have modified this predicate with a lambda patch. Indeed, here is what happens if two pitches make almost an octave – 1200 midicents : |
The values tested by the remove-dup are returned by two inputs, and substracted by om-.
The difference is divided by 1200 and rounded give or take a multiple of 1200.
It is then multiplied again by 1200 to calculate the rest of the original difference.
If this value is inferior to 50, it will be rounded so that we will get an octave or its multiple in the score.
The absolute value of the rest is compared with 50 by om-.
If om- returns "true", the value is rejected by remove-dup
If the test is applied to 6000 and 7187 midicents – preceding values –, we get the following evaluations :
Om< returns "t", and pitches are considered equal.