TidalCycles and Processing

TidalCycles is close friends with SuperDirt but can be configured to send trigger messages to anything that accepts Open Sound Control network messages (or MIDI).

A while back I made a quick example of how to live code Processing sketch from Tidal. You can find an example sketch and tidal file on github. See what can be done with this sort of approach here:

Atsushi Tadokoro is doing similar things in Tokyo, I think with openframeworks.

Yecto has been working on this sort of thing for a while too, check out his spine-tingling sh2hs2 system.

Atom Package v0.11.0: custom Tidal boot path

A new release (version 0.11.0) of the TidalCycles package for Atom is available today. With this version you can now specify a path to your own boot file in the package settings:

This means that you no longer need to modify the provided BootTidal.hs file in the package with your own custom logic (e.g. custom functions, additional modules, etc).

If you want to create your own boot file:

  1. Create a copy of the original (available here)
  2. Save it anywhere on your computer
  3. Modify the TidalCycles package settings to point to where you saved the new file

Interview with Malitzin Cortes a.k.a. CNDSD

The second in a series of interviews with TidalCycles people, this one with the awesome Malitzin Cortes, who is based in Mexico City and performs music as CNDSD, including with SuperCollider and Tidal. Follow her on Twitter and Facebook, and be sure to check out her work on soundcloud, tumblr and vimeo. You can also read a pro interview with her en Español in Noisey.

Hi Malitzin, are there particular ‘strategies’ you have developed/collected for
using Tidal? e.g. combinations of functions you like to use together,
particular ways you like to twist patterns etc. Feel free to share
particular examples!

Personally, my knowledge about Tidal has grown, studying the guide on the website and experimenting with these codes, as well with tutorials, testing with my own sounds to the extreme, sometimes simple sounds work best to test and understand how some functions affect the sound.

An extremely seductive quality of the tides is the way of writing, in which I find the logic and emotion of the sequence that I am beginning to compose.
It seems to me extremely poetic, we can write with grammatical sense and algorithmic sense at the same time, some converters like superimposition or palindrome, to mention two, that, combined with iterations can create deep and complex sonorous experiences.

CNDSD performing at Mutek with visualist Ivan Abreu (Photos: Leonardo de la O)

Or to phrase that question another way, what parts of tidal do you
feel drawn to most? Has this changed over time, are their
techniques/functions you explore in depth but then grow bored with?

In the beginning some options lead me to a rhythm more quickly and predictably, but then I found complexity in these same functions through combination with others, leaving the common rhythm behind.

Playing with different sound parameters, the tempo of a sequence of patterns can be extended and become a mass of sound that doesn’t seem to have an identity as a rhythmic pattern, although in the background it is still there!

On the contrary it is difficult for me to get bored, for the moment I don’t think I have reached 5% of the potential of Tidal, I’m always testing functions and combinations and when I do not write well (due to a bad syntax) I learn, and discover that the correct syntax generates new effects and behaviors depending on the number of samples or synthdefs used.

To what extent do you use the standard dirt samples? If you use your
own samples as well do you feel this is important in some way?

I think that as in every library of whatever : images, cats or sounds, there are some more beautiful and interesting that you can not just discard. The default library was the first door to understanding how Tidal worked and what potential it has since you start with the first pattern and by continuing to use it, you discover and understand (especially if you are not a programmer) how a function transforms the sound.

I began to get ideas and the frantic desire to experiment with other sounds.

Personally I keep sounds extremely clean and forceful of this default library and I have dedicated to create one, which is the identity of what I compose and of my music: recorded sounds, voice samples, midi and endless synthdefs.

How do you see the tidal community/communities in relation to the
tidal language?

The community is extremely important in the process of learning and understanding the use of Tidal, as well as in the personal search for a sound identity and to know the work of other people who use it.

Some extremely committed and brilliant people in technical matters (Mike Hodnick) have really supported me in solving doubts and understanding Tidal better, also you learn a lot from the questions of others and from all the deductions that can come out when answering these questions.

Sharing music from different parts of the world makes you understand the sound and music panorama more deeply, how these artists use the same functions to create completely different realities and sound personalities.

How does Tidal compare to other music-making activities/software you have engaged with?

Contrary to what you might think, for me Tidal is extremely friendly and when you go deeper, it becomes more abstract and free than other softwares that I really love and use to compose and generate sounds.

Now Tidal has become a place where I can experiment, improvise live and also compose, the latter perhaps in a not so orderly way, not because it’s not possible, but because it’s so free that you create your own rules.

How approachable do you find the Tidal community/communities, do you think there is a language/cultural barrier and/or do you think there are separate communities growing around Spanish language and/or locality in Mexico/America?

If your knowledge of programming and English is poor, at first it can be very confusing, this is my case, but the same programming has made me want to acquire a higher level of English in order to understand Tidal better.

I think that with the existence of translate tools the barriers are becoming smaller when there is an intrinsic interest, I would like in the near future to be able to translate and give workshops in which Tidal can be understood in Spanish very clearly if the level of English of the people concerned actually represents a barrier to delve into it.

There are people in Mexico and Colombia developing their own live coding languages and in general are very willing to share their knowledge and experience, in SuperCollider mostly.

How does Tidal influence your work, when you are using it do you feel like you are composing, improvising, exploring?

I think all three, in my process the experimentation begins in the pursuit of understanding, also trying to find how I want to sound.

After mixing sounds and beginning to compose patterns improvisation is extremely easy and natural in Tidal, when you begin to listen and you propose to direct the sounds and rhythmic complexities or textures is where the composition process begins.

What do you think Tidal is?

For me it is the music of the future, not only in Tidal, it’s algorithmic music itself, but without doubt Tidal has achieved many things in terms of simplification thanks to functional programming, allowing it to go far when it comes to live coding and improvisation in a few lines.

I would like Tidal have more things, but I know that it is the beginning of something tremendous, that allows us to take sound to places uncommon and to transgress the motricity in the music. It’s that search of sounds that seem impossible and are only possible in the computer, Tidal allows you to find an unimaginable panorama of combinations.

I think I have explored little and I always want to know more and especially ask myself questions about whether it is possible that what’s in my mind musically can translate into a reality .

and always surprises me and leads me to take all sorts of decisions.

Thanks Malitzin!

Live streaming on YouTube

Here’s a guide for live streaming your TidalCycles session to YouTube.

This is the set-up I use so it’s specific to Mac with SuperDirt and Atom. There a load of ways to achieve this so it would be great to see the guide expand.

Requirements

Instructions

Soundflowerbed

  • Launch SoundFlowerbed
  • A status icon will appear in the top menu strip. Click it and tick the ‘Built-in output’ option under Soundflower (2ch)
  • Also on the top menu strip, click the speaker icon and from the output device options select Soundflower (2ch)

SuperCollider

  • Launch SuperCollider
  • Run the following command in SuperCollider by pasting it in the input window and hitting Shift + return anywhere on the line:

  • Hit Cmd + Shift + L to recompile the class library
  • Launch SuperDirt with:

In the post window you should see something like:

This confirms that SuperCollider will output to SoundFlowerbed, which will act as the audio input to OBS for the stream.

Atom / other text editor

  • Launch Atom and save a new .tidal file
  • Exit full screen if that’s how the application is currently set. This is to overcome an issue with OBS detecting full screen application windows.
  • It’s also worth increasing your editor font size a few points so it’s clear in the stream.

OBS

  • Launch OBS
  • In the Sources menu click the sign and select Window Capture from the list of available options.
    Soundflowerbed sources
  • In the next screen select the application and file name combination that matches your text editor.
  • Switch back to your text editor and set it to full screen mode. Then head back to OBS.
  • You should see a stream of your text editor being rendered in OBS.
    OBS screen capture
  • Click the sign again to add your audio stream. Select audio output capture and select Soundflower.

YouTube

  • Log into YouTube with an account you want to use to broadcast your performance to the world.
  • Click your user avatar in the top-right corner of the screen and select Creator Studio.
    Youtube Creator Studio
  • From the left-hand panel select Live streaming > Stream now
  • Enter basic information for your stream.
  • Under the encoder set-up section at the bottom, click Reveal to display your encoder key and copy it. This will be used to authenticate your stream with YouTube.

Back to OBS

    • Enter Settings and select Stream from the left-hand panel.
      OBS stream settings
    • Apply these settings:Stream type: Streaming Services
      Service: YouTube / YouTube Gaming
      Server: Primary YouTube ingest server
      Stream Key: paste the key you were given on YouTube

OBS Output Stream settings

You may wish to experiment with different settings for your stream (the bitrate in particular), I found these work for a decent resolution and audio quality, without encountering buffering issues.

OBS output settings

Encoder: x264
Rescale output: 1024 x 640
Rate control:  CBR
Bitrate: 500
Keyframe interval: 0
CPU usage preset: very fast
Profile: none
Tune: none

Start streaming

You’re good to go.

  • Click Start Streaming in OBS. In a few seconds the steam will be live on YouTube.
  • When you’ve finished click Stop Streaming and YouTube will create a recording in your channel. You can choose whether to share, edit, delete, and so on.

And finally, here’s one I made earlier.

How to Haskell – developing a Markov chain

One of my favorite things about Tidal is that it’s inside of Haskell, a well-developed full-blown programming language, so all sorts of tricks are available.  After some discussion on Slack I developed code for making Markov chains to use in Tidal, and here I’ll try to describe the process.

First – what’s a Markov chain? Basically it’s some kind of random sequence where each step depends only on the step immediately before it. A common way to express this is to imagine several possible “states” for each step, and then write a “transition matrix” which gives the odds of going from one state to another.

How should we represent all this in Tidal/Haskell?  We ultimately want to have the chain as a Pattern, but it’ll probably be easier to start out with an ordinary list, and then use the listToPat function to turn it into a Pattern.  Let’s number the states with integers, starting at zero.  Then the chain itself will be a list of integers.  The transition matrix is a list of lists of floating point numbers – we’ll use doubles. Then one way of writing things is to have a function that takes the transition matrix and a chain as arguments, and returns a new chain which is just the old one with one new element added. Here’s just the signature:

Next let’s start the basic structure of what the function will have to do. Let’s call the transition matrix tp and the input chain xs. We need to look at the top element of the list to see what the “from” state is, and find that row of the transition matrix: tp!!(head xs). Next we need to generate a random number r (we’ll worry about how to actually do this later) and somehow use it to choose what the “to” state for the next step of the chain should be.

For example, if the row of the matrix were [0.20, 0.30, 0.50], this would mean 20% chance of transition to state zero, 30% chance to state one, and 50% chance to state two. So if our random number (between zero and one) were between 0 and 0.2, we’d pick state zero, between 0.2 and 0.5 state one, etc. This is easier to write if we take the cumulative sum of the row, and there’s a handy Haskell function we can use for that: scanl1 (+). That’ll turn the row into [0.20, 0.50, 1.00], and now when we have a random number we just need to find the index of the first element in the row larger than our random number. That’ll be the state the chain jumps to next.

There’s a handy Haskell function for finding things in lists too: findIndex. While it doesn’t quite work yet, we have most of our function:

(the : xs at the end adds the existing chain after the new element we just made)

One problem is that findIndex doesn’t actually return an Int. It returns a Maybe Int, because it might not find anything.  If our transition probabilities for each row add to one we’ll always be safe, but if we mess up or make a typo things might go wrong.  We have two options, (1) choose a safe default or (2) throw an exception and halt.  For the first option we could use fromMaybe 0 (to default to state zero), and for the second we’d use fromJust. Both require us to import the Data.Maybe module. Since I like to immediately know when I’ve made a math mistake and don’t mind if my performance grinds to a halt, I’m choosing the second option:

The final thing to take care of is the random number. While it’s not quite the intended use, we can use the timeToRand function, which takes a rational number as an argument and hashes it to a pseudorandom result. We just have to make sure we get a different number for each step of the chain by using the length of the chain, and do type conversion as necessary:

The last touch to make this a bit more usable is to wrap markovStep in a function that will repeat the step process to build a chain n numbers long from an initial state xi, flip it around so the most recent element is at the end, and turn the whole thing into a pattern with one number per cycle.

Now it’s ready to use in Tidal:

The chain states are always integers starting at zero, and that seems rather limiting.  But we can treat the chain as an index to some other array of our choice, which needn’t even be numerical:

I’m sure there are still improvements we could make, but this is a pretty fun start!

TidalCycles Winter Solstice, Sheffield UK

We’re having a Winter Solstice party in Sheffield on 21st December at Access Space, tickets now up! Featuring some of the leading lights from the local tidalcycles community Heavy Lifting, Tich, Digital Selves, Class-Compliant Audio Interfaces, Co(n)de Zero and Nullish. It will get algorave-y at some point.. There’s a facebook event for those who are that way inclined..

Interview with Mike Hodnick a.k.a. Kindohm

The first in a series of interviews with TidalCycles people.

As I remember you started out with the 365 tidal patterns project, the first major foray into Tidal aside from myself. It must have been quite an ordeal getting tidal installed as an early adopter, can you remember what drew you in and made you put the work in?

The soul of Tidal is rhythm and patterns, and as a percussionist/drummer  (and programmer) this really resonated with me. In fact, this might be the  most important reason why I was so intrigued with Tidal. In Tidal, I saw ways  to create very complex rhythms that could evolve and change over time; I  would make a pattern with small amounts of code that would take minutes to cycle until repeating. As a music producer who liked to create complex drum rhythms, Tidal looked like endless fun!

But I think the reason I really got drawn in was because I realized I could use this type of music-making for more than just at-home fun. I really wanted  to get good enough at Tidal so that I could get out and perform with it.

I remember the date I installed it: December 5th 2013: https://github.com/tidalcycles/Tidal/issues/6

The installation process wasn’t too bad, but I knew it would be worth the wait and effort whatever time it took. I think I spent a couple of afternoons trying to get it to work. I had some prior Linux experience, and compiling classic Dirt wasn’t too bad. Linux audio and Jack were new to me though; I think that’s where most of my initial struggles came from. I also hadn’t used Emacs before, and Emacs was the best-supported editor at that time. It took some time to get the Emacs configuration correct. It definitely required a lot of trial and error with Jack and the Emacs config.

What ‘strategies’ have you developed/collected for using Tidal? e.g. combinations of functions you like to use together, particular ways you like to twist patterns etc. Feel free to share particular examples! How important are these strategies to you? I think you’ve defined a few of your own functions. Could you share some details? How has this gone as an otherwise non-Haskell programmer?

There are so many…

First, there’s the stack.

When I was working on 365 Tidal Patterns, I imposed a constraint that I had to put the pattern on a single line. Then I relaxed that constraint to only using one Dirt connection (e.g. d1). This is where I discovered I could use stack to create layers of patterns on one Dirt connection. From the start I think I’ve always been a fan of using a big stack to create layers of stuff:

The great benefit of the stack is you have two levels of transformation: one at the pattern level and one at the stack level. The pattern above has transformations at the pattern level (e.g. (0.5 <~)). Here is a pattern with transformations at the stack level:

Next, there’s moving time around. Early on when learning Tidal I started to do this a lot:

I then attempted to author my first Haskell function in Tidal to make this a first-class capability in Tidal. We called it foldEvery. My implementation didn’t work, and I think Ben Gold actually implemented the final version. It’s used like this:

Another really common thing I like to do is use different audio effects and transformations on different cycles to create constant variation in patterns:

I think that pattern will cycle 420 times before repeating. 420!!! With such little code you can get so much continuous variation. This never ceases to excite!

Another feature of Tidal that I exploit a lot is the polymeter syntax:

The above d1 pattern will play “in five” while the d2 plays in a regular division of eight (or four, depending on how you feel it). I love this type of rhythmic interplay: two patterns with the same pulse but different lengths. My favorite band when I was young was Helmet, and they did this type of thing all the time (drums in “four” while the guitars were in five, six, or some other division of time).

Another technique is to define a common rhythm for multiple patterns to use:

And as an added bonus, put that code in a do block so that you can change the rhythm and have all patterns take on the new rhythm at the same time:

As far as my own custom functions, I have defined many. Perhaps my favorite is one I call rip:

Which creates a sort of quick, backwards, rush effect.

I also use a custom function called brakk to time-stretch and create random drum breaks from pre-sliced break loops:

As a non-Haskell programmer, creating these types of shortcut functions is pretty easy because they just re-use existing common Tidal functions. It’s just like writing regular Tidal code, except you have to know how to give a function a name and express what parameters it will take. In contrast, I am not very good at lower-level Tidal functions or common Haskell language features to create new capabilities within Tidal.

Or to phrase that question another way, what parts of tidal do you feel drawn to most? Has this changed over time, are there techniques/functions/aspects you explore in depth but then grow bored with?

I haven’t really gotten bored with anything yet. It does take time and persistence, but eventually I kind of stumble across new ideas that result in something surprising. Then I try to find ways to exploit those ideas and run with them for a while. For example, I’ve kind of been exploring footwork’ish patterns by using stut' in weird ways. It’s a foundational idea that I can put all other strategies on top of. Hopefully other foundational ideas will keep emerging in the future and the strategies will stay fresh with them!

I’ve noticed you put your compositions on github. Is this just out of convenience or something you’ve made a explicit decision to do?

It’s both. I’m slightly paranoid about losing data and code, so GitHub is kind of a backup strategy. However, I’ve always liked sharing my code with others, so GitHub has this nice side effect of making everything available to the public.

I’ve always believed in giving away all of my secrets, whether it’s related to my career or in music. In my entire career I can only think of once when my work was plagiarized. I also just don’t think I have anything to gain by keeping everything to myself. I would love to make more friends in the Tidal world and use it together with more people; sharing my work will only help that.

How does Tidal influence your work, when you are using it do you feel like you are composing, improvising, exploring? Do you feel there’s some expectation for how tidal is used, that you’re going with or against?

When I use Tidal I feel like it is a varying balance of composing, improvising, and exploring. In the studio, it starts with exploring, some grain of an idea, and asking a lot of “what if?” questions. While exploring, I’m looking for something weird or odd that surprises me, or maybe I’m looking to apply a snippet I learned about on the Tidal slack channel. I think during exploration I’m trying to use code I haven’t tried before.

If the result is sonically interesting, then it might become a compositional foundation. I change my approach from code I’m not familiar with to code that can build around the foundational idea.

Improvisation is constant, really. I think one of the powers of Tidal is being able to make a change so quickly and hearing the result. Those “what if” questions can get answered immediately.

I don’t feel like there’s an expectation for how Tidal should be used. I don’t feel constrained in that way. I do feel that there are constraints due to Tidal’s architecture (e.g. a constantly running cycle, discrete events vs continuous events) but not because of an expectation. To me, “expectation” implies that there is a wrong way to use Tidal, and I’ve never felt that at all.

To what extent do you use the standard dirt samples? Do you feel it is important to use your own samples?

I don’t use many of the standard Dirt samples, but not because I don’t like them. I just have a creative desire to design sounds. Often times my sound design process is coupled with the exploratory process of live coding with Tidal. I try to couple an inspiring sound with a bit of new inspiring code.

Many Tidal artists use the standard Dirt samples and the result is an amazing transformation. I think there are nearly infinite creative possibilities in the standard samples.

How does Tidal compare to drumming/other music-making activities/software you have engaged with?

I’ve played drums and percussion since I was 12, and I think Tidal resonates with me because of this. Tidal is such a rhythmic tool and I love it.

I guess I think of Tidal as more of a composition and orchestration tool, whereas drums and percussion are more of a performance instrument. Of course I perform with Tidal, but I am more of a conductor; I orchestrate changes and direct what the parts of the composition are doing. As a percussionist, my concerns are more directed at the performance of a single instrument.

I’ve always liked working with drums in electronic music and creating drum parts that are humanly impossible to play, or that are rhythmically too difficult to “feel”. With traditional music-making software (e.g. DAWs like FL Studio) I would need to place every little note perfectly and it was a tedious process, especially if I wanted to achieve little repetition in the drum patterns. Tidal helps automate this approach and it is very satisfying as a result. I can tell Tidal how to process drums with a few lines of code and it achieves the same thing much more quickly.

How do you see the tidal community/communities in relation to the tidal language? How do you feel about tidal club, has it met your original aim for it, have new aims emerged?

I think the Tidal community and language are tightly coupled. The community has been a huge influence on language features and improvements. We’ve attempted to document Tidal as best we can on the web site, but because live coding is a creative process I think it has been very difficult to convey some concepts through documentation. In-person meetups and online communication are a critical part of spreading knowledge, sharing ideas, suggesting changes, and getting feedback.

And finally a direct but vague question – what do you think Tidal is?

At a very technical level, I think Tidal is a way to express patterns in code. Those patterns can be expressed as data in a file (e.g. an image), messages on a network (e.g. OSC messages to SuperCollider), or whatever else a programmer wants to do with those patterns.

At a more personal level, I think Tidal is the creative tool I’d been trying to find for about half of my life. I wasn’t even sure that I was looking for one. It sparked a creative part of me that I wasn’t sure existed before.

Thanks for sharing!

Some experiments: Reified duration, multi-parameter sequences in a single String, and chord sequences

These are a few new language features in an experimental branch of Tidal[1]. It uses a variant of the Pattern type called Epic. (It’s called an Epic because rather than having an implicit fixed duration of one, it can have an explicit duration of any length, including potentially infinite.)

Reified duration allows an Epic a of duration n can be glued (using the +- operator) to an Epic of duration k, to create one of duration n+k. (The duration of an Epic can be determined using the “period” function.)

Here’s the multi-parameter sequence idiom:

melody = p0 “t1%8 _bow d0 ,, d2 ,, _flute ,, t1%4 d5”

p0 turns the string into a ParamEpic, that is, something of type Epic ParamMap. The string descrbes four events, in sequence, separated by the “,,” symbol. The “t1%8” says “the following events have duration 1/8”. The subsequent “_bow d0” says “play the bow sample on scale degree 0.” The “,,” indicates that that’s the end of the description of the first event. The next event uses scale degree 2. Since the sample (bow) and duration (1/8) were specified already, those parameters carry over, so the next event is just like the first except it differs in scale degree. Then the flute plays, on (since it isn’t specified) degree 2 again, and again for a duration of 1/8. Last the duration switches to 1/4, and (because it’s not specified) the flute plays, on scale degree 5.

Other parameters (gain, speed, sustain …) can be specified in that notation — see Sound.Tidal.Epic.Parse.Cmd to see how each is written.

Here’s the scale sequence idiom:

scaleCycle = cata 1 [dim,lyd,aug]

“cata t as” turns a list (“as”) into the type “Epic a”, where each “a” has a duration of “t”. In this case, we’re creating a cycle of three scales — diminished, lydian and augmented — each with a duration of 1.

The scale cycle can be applied to the melody like this:

scaledMelody = scaleCycle <*> melody

or this:

v3 $ scaleCycle <*> melody

This code is very incomplete. In the issue tracker[2] I’ve listed some of the directions in which I’d like to take the code. Suggestions, quesitons and contributions are eagerly invited.

[1] https://github.com/JeffreyBenjaminBrown/Tidal/tree/epic
[2] https://github.com/JeffreyBenjaminBrown/Tidal/issues