Hi!
I want to use binaryN to create a list of ones and zeroes that I can subset.
I want to this...
do
let amps = [1,1,0,1,0,1]
d1
$ s "superfm"
# amp1 (amps !! 0)
# amp2 (amps !! 1)
# amp3 (amps !! 2)
# amp4 (amps !! 3)
# amp5 (amps !! 4)
# amp6 (amps !! 5)
# ratio1 1
# ratio2 0.99
# ratio3 0.88
# ratio4 0.77
# ratio5 0.66
# ratio6 0.55
...using a list created by binaryN
do
let amps = binaryN 6 123
d1
$ s "superfm"
# amp1 (amps !! 0)
# amp2 (amps !! 1)
# amp3 (amps !! 2)
# amp4 (amps !! 3)
# amp5 (amps !! 4)
# amp6 (amps !! 5)
# ratio1 1
# ratio2 0.99
# ratio3 0.88
# ratio4 0.77
# ratio5 0.66
# ratio6 0.55
I’m away from where I can test this right now, but you should be able to do:
let amps = bool 0 1 <$> binaryN 6 123
That did not work, unfortunately.
I got this error message
Variable not in scope: bool :: t0 -> t1 -> Bool -> b
I really need to learn Haskell
yaxu
August 13, 2023, 3:56pm
4
You could do:
onezero boolpat = stitch boolpat 1 0
For:
onezero $ binaryN 6 123
Thanks! This works for generating a pattern 1s and 0s. But is it possible to create a list using this function? I trying to create a list of 1s and 0s that I can subset.
When I put square brackets around the function it only contained one element.
Sorry about that. You’ll need to import Data.Bool
The function I provided works with any Bool, and fmap (seen as <$>) works with any Functor, so you can use it on a list just the same as you’d use it on a tidal pattern.
Great! Thanks @mvdirty ! I got the brilliant idea to upgrade macOS, so now nothing works. I will try this out later
I got it to work. Thanks again @mvdirty and @yaxu !
I also used patternToList function from this thread: https://club.tidalcycles.org/t/pattern-to-list/2982
mvdirty's solution:
import Data.Bool
import Data.List
do
let
booleans = bool 0 1 <$> binaryN 6 "123"
patternToList pat = map value $ sortOn whole $ queryArc pat (Arc 0 1)
amps = patternToList booleans
d1
$ s "superfm"
# amp1 (amps !! 0)
# amp2 (amps !! 1)
# amp3 (amps !! 2)
# amp4 (amps !! 3)
# amp5 (amps !! 4)
# amp6 (amps !! 5)
# ratio1 1
# ratio2 0.99
# ratio3 0.88
# ratio4 0.77
# ratio5 0.66
# ratio6 0.55
Yaxu's solution:
import Data.List
do
let onezero boolpat = stitch boolpat 1 0
booleans = onezero $ binaryN 6 123
patternToList pat = map value $ sortOn whole $ queryArc pat (Arc 0 1)
amps = patternToList booleans
d1
$ s "superfm"
# amp1 (amps !! 0)
# amp2 (amps !! 1)
# amp3 (amps !! 2)
# amp4 (amps !! 3)
# amp5 (amps !! 4)
# amp6 (amps !! 5)
# ratio1 1
# ratio2 0.99
# ratio3 0.88
# ratio4 0.77
# ratio5 0.66
# ratio6 0.55
I'm planning to add more lists of 1s and 0s to create random noise using superfm
1 Like