Getting Tidal Cycles to talk to Pure Data
This post describes how to make Tidal Cycles communicate with Pure Data over MIDI on Linux. The pattern should be applicable to communicate between Tidal and any kind of DAW. The gist of this post is short, and it's mostly about which two things to put together, and how. The TL;DR is in the setup section.
Motivation
I like programming audio to create music. I find there is something deeply satisfying about live-coding sounds and manipulating them, and playing with temporal sequences in Tidal Cycles is lots of fun.
Recently I have also been introduced to Pure Data, which is a node-based visual programming environment that allows you to very easily incorporate audio and midi input to create sounds and visuals from basic building blocks in the form of nodes. If you have never seen it, here is a 15 minute video of an artist using only a few simple objects to create pleasant drone sounds.
The two tools use quite different approaches, but I've often seen them used together. Often Tidal is used for the audio while pd is used for the visual part of a performance.
My idea was to use Tidal for rhythmic and scheduled parts and pd for more free-form experimentation with sampling, looping and effects. Communication is happening via MIDI. I'll document what I did here to maybe save somebody else some time.
Setup
The basic idea is to have Tidal continually send messages over a MIDI device and receive and read them in pd.
This can be done using a loopback MIDI device that echoes all the messages sent to it. The snd_seq_dummy linux driver sets one up, and on my machine it's already loaded. To verify that it's loaded, check that this output is non-empty:
lsmod | grep '^snd_seq_dummy'
The output will look roughly like this:
snd_seq_dummy 12288 2
If it doesn't, run sudo modprobe snd_seq_dummy to load the driver.
SuperDirt now needs to know about the midi device to make it addressable from Tidal. The loopback device is visible in SuperCollider as "Midi Through Port-0", so I slightly modified a snippet from the Tidal docs and added it after the code to boot SuperDirt:
// set up midi
MIDIClient.init; // this will print a list of all found midi devices
~midiOut = MIDIOut.newByName("Midi Through", "Midi Through Port-0");
~dirt.soundLibrary.addMIDI(\midiout, ~midiOut);
Tidal should now be able to send midi messages to midiout:
d1 $ stack [
ccv "<1 2 3 4>(5,8,<2!3 0>)" # ccn 10,
n "c5'min"
] # s "midiout"
You can receive this in pd using the ctlin or a notein objects.