Map binary values?

I remember seeing a function that would allow mapping of binary values, but I can't seem to find it anymore...

Given a binary value...

binaryN 8 12345678

I'd like to have the 0's map to one value, and the 1's map to another. Ideally for sample values and or amp/legato for subtler effects.

stitch can do this with two values

s "moog"
# ampbus "a" (stitch (binaryN 16 48170) "0.5" "0.1")
# cut 1
note (stitch (binaryN 16 48170) "d" "g")
# s "moog"
# cut 1

[edit] a little tutorial I wrote:

2 Likes

Amazing, thanks -- that's way more concise than what I was previously doing!

1 Like

No worries! Further to this, something I've used is to take (for example) a pattern of notes:

let bass =  "[4 0 0 0 3 0 0 0 4 0 4 5]"

and convert that to a binary pattern, where 0 in the note pattern are 0 in the binary pattern, anything else becomes 1 in the binary pattern

binpat = (/= 0) <$> (bass:: Pattern Int)

Not sure if that's of interest too?

3 Likes