I’m looking for a way (or more precisely, a better way) to apply a list of Bools to a list of notes or sounds to determine which ones get played. Sort of like mask
, but applied vertically to a stack of sounds/notes simultaneously, not to successive events in a pattern.
So that if I had a list of samples (e.g., [“bd, “sn”, “hh”, “bass”, “can”]
), I could apply a list (?) of Bool
s such as
[True, False, False, False, True]
and the result would be equivalent to
s “[bd, can]”
or applying:
[False, True, True, False, True]
,
it would be:
s “[sn, hh, can]”
.
I have kludged together something that sort of accomplishes this, but it feels awful.
I convert the Bool
list to an Int
list such that the indices of the True
elements of the Bool list are in the Int list, i.e, [True, False, False, False, True]
becomes [0,4]
or [False, True, True, False, True]
becomes [1,2,4]
Then apply parseBP_E . show
to my intList to make a pattern that I can use with fit
, like so:
d1 $ s (fit 5 [“bd, “sn”, “hh”, “bass”, “can”], myKludgilyAssembledPattern)
There has to be less awful way of doing this, and I would really appreciate some guidance. FWIW, the use case here would be applying the output of a cellular automaton.