I broke my brain while riffing on this video. Switching the commented stuff on and off = my brain. My poor brain. Alex, this is so cool. I can't wait to get really good at understanding efficient ways to structure the code, and building fairly hefty compositions, installations, etc.
Also, quick question, with stuff like repeatCycles, is it possible to have that fed a random number? I tried to give it repeatCycles (irand 5) for example but it returns an error. I tried using choose as well, but that similarly didn't work as it seems the integer that xCycles is expecting is of a different data type or something?
The thoughts on randomness in this video were very interesting, thanks. I have to confess I was slighly dreading watching it, as I also have strong ideas about this area. To me, being able to ask the machine to make arbitrary decisions – agreed, let's not call them random – is fundamental to the business of algorithmic composition. I like to be able to create a high level structure and let the computer fill in the details: I see that as a fascinating way to discover 'what works' in music. James McCartney talks this somewhere, sorry I can't find the exact reference, as being able to create a class of compositions and then listen to various instances of the class.
To take an rather wonderful example from your worksheet:
d1 $ sound "bd*8? clap:4"
To me, this is asks and answers an interesting musical question, something like: 'What about… half a bar of arbitrarily syncopated kick drum hits followed by an offbeat clap? Would that work?' And yes, it does.
Thanks @tedthetrumpet and @vin for taking on my polemic. I started out with some wariness about random number generators, then spent the rest of the video having fun using them, so take what I said with a pinch of salt!
For me the emergence of live coding was in part a reaction against "generative art", in particular the idea that by using random numbers, you can create infinite variation, and gasp at the creative system you've made which holds a mirror to the beauty of the universe. The problem is that the more you listen to infinite variation, the more it sounds the same.
I like the idea of creativity as search and discovery. You define a space of possibilities (e.g., all the possible 8 step kick-snare rhythms), and look for things in it. You can use a random number generator for picking rhythms from that space, and listen out for good ones to use.. This is the approach taken by algorithmic composers such as David Cope. But there is a slight of hand here. The value comes not from the random number generator part (which comes up with all kinds of nonsense), but the act of listening out for good ones. I.e., this isn't algorithmic composition, but simply composition lead by the ear. That's be completely fine of course, but all the posturing around chance operations, creative systems, automatic composers etc is missing the point, when the whole process still revolves around human perception.
So that's where the chip on my shoulder comes from.. But really, I do use random number generation a lot, and a point I was trying to make in the video is that using Tidal often feels a bit like hand-making a random number generator.. Really all a random number generator does is make an interference pattern, and by making your own you are finding that sweet spot between noise and mundane predictability, which is where you could say is where all the music lies!
Yes the first parameter is an Int, rather than a Pattern Int, so you can't put a pattern there:
repeatCycles :: Int -> Pattern a -> Pattern a
There are ways around this, e.g. using 'do' notation, and <- to take values out of patterns:
d1 $ do n <- "<2 3 4>"
repeatCycles n $ sound "<bd(3,8) cp(3,8)>"
However this probably won't do what you expect. The above switches between different versions of the pattern every cycle, and they will be repeating at different rates, so you won't hear an orderly repetition.
(n.b., rather than taking values out of patterns, I'd say the <- there is really doing something more like taking the computation into the pattern, but this gets hard to think about.. This is the 'monadic' stuff that Haskell people waggle their eyebrows around a lot)
Anyway a version of repeatCycles' with the patternable repeat:
repeatCycles' pn pat = innerJoin $ (\n -> repeatCycles n pat) <$> pn
Hey @yaxu. Didn't you mention that this was a 'bug' with repeatCycles in the other thread over here?
Looking at the repeatCycles type:
repeatCycles :: Int -> Pattern a -> Pattern a
That first parameter is an 'int', and not a pattern of ints. Actually it's only in the last couple of years that you've been able to use patterns as parameters in this way in Tidal.. (the inner workings of this are quite something to behold, it's amazing that it works so well in general..) So this is kind of a bug in Tidal that this parameter isn't 'patternable'. I've made a note to fix it Make repeatCycles patternable · Issue #645 · tidalcycles/Tidal · GitHub
Thanks @yaxu, that is going to take some mental gymnastics (and trial and error) to understand the structures. Am I right in understanding that you can use haskell variables across TC more generally? In particular can you declare global variables that can be used in multiple OSC sends?
To borrow the SuperCollider global variable vernacular a bit. Sorry, this is probably for a different topic.
do
~globalVar1 = "some pattern"
~globalVar2 = "some other pattern"
d1 $ n ~globalVar1|~globalVar2 # s "bd -- mininotation pipe
d2 $ n ~globalVar1 # s "synth"
d3 $ n ~globalVar2 # s "bass"
Hey @julianmrn5, in the above it is pseudocode. But in reality it encapsulates everything below it that is indented by one tab (or more) into a single execution. I’m not sure how variable scopes work in Haskell/Tidal but to my mind if in the above pseudocode the subsequent Dirt connections were indebted correctly then those variables would be local in scope. When I get in front of a computer I can paste in some actual code if that would be helpful? I can’t answer about the necessity for variables but I reckon @yaxu or @eris (I think) can give better answers around variable creation and scope!
I tried the snippet myself and I'll give you my interpretation: since you are asking scramble to create 8 pieces from a 4-piece long pattern, it will fill the pattern up with some fictive steps of silence.
That is, the pattern to scramble might look something like n "0 1 2 3 ~!4"
And that is probably why I hear silence now and then when I play it.
(although I would love @yaxu to confirm or refute)