Trigger different sections/code blocks?

hey tidalers! I've been thinking of ways to use tidal as a sort of groove box sequencer - I usually use it as my main midi sequencer. I've been trying to think of ways to trigger different sections, for instance use a midi command to play a different block of code. Right now I use a qwerty keyboard to manually execute blocks of code.

My first thought was to do something like add amp 1 to a block, then somehow use midi to "trigger" a new block by changing the 1 to a 0, and changing a 0 to a 1 in a different block. I suppose this would be more like a crossfade.

Does anybody have any other ideas on how this might be achieved? Does this even make sense?


@pulu (or @pulusound ? ... pulu on the discord) does this - I believe she uses some emacs binding jiggery in combination with a Midi Fighter Twister unit for control:

on button presses i instead run emacsclient from the command line to execute emacs lisp functions that find, launch and/or modify code blocks in my editor

The solution you have written is similar to what I use my MFT for - there are OSC mute and solo commands that you can send via midi. Some doco here:

Because the MFT can manage the button state, I've simplified that example significantly
Basically I have a row of buttons dedicated to "momentary mute", another row dedicated to "toggle mute", next row dedicated to "solo" and I don't remember what the last row does but I'm sure it was a good idea at the time :wink:

Happy to share sc setups etc if you're interested


my approach is based on tidal.el which already had code to find blocks mentioning d1, d2 etc and run them. i've added a concept of "variations" for patterns - the variations can be separate blocks like:

-- pattern 1, variation 0
d1 $ {- ... some pattern ... -}

-- pattern 1, variation 1
d1 $ {- ... another pattern ... -}

or denoted with var/n_vars variables in a single block: (these need to be integer literals)

-- pattern 1 with 3 variations, variation 0 currently active
  var = 0
  n_vars = 3
in d1 $ {- ... some code that does different things based on the value of var ... -}

i wrote a function to "run variation m of pattern n" which goes through the text buffer to find the appropriate block, modifies the var = ... line if needed and runs the code.

then in supercollider i have some midi mappings to run emacsclient on the command line and call my elisp functions.

i can also do crossfades by dynamically replacing e.g. d1 with (xfadeIn 1 4). it's all very hacky and regex-y but quite effective :smiley:

i hope this gives you some ideas! i haven't really published the code because it's currently so deeply integrated into my personal performance setup and not many people seem to use emacs for this stuff anyway, but if there's interest i might consider it.

edit: also didn't realize i have two accounts on here, i should sort that out lol. thanks for the heads up @cleary !


Is there a vim specific solution to this? Wasn't there some kind of javascript cell based solution where clicking on a cell would execute whatever's in the cell?

I haven't played with tidal in a while, but I remember of a method to trigger code blocks from MIDI. I don't remember the exact syntax but the idea is this:

  1. get data from your MIDI knob. With a standard MIDI->OSC bridge config, you will get a float from 0 to 1,
  2. write a function that returns 0 if the value is 0, or 1 otherwise. let's call this value toggle
  3. use this trick: d1 $ every toggle $ -- your block here.

Now, if your knob is turned all the way down, toggle == 0 and the block does not play. But if you turn your knob just a little bit, toggle switch to 1 and the block plays every cycle.

Depending on how you want to use it, you might add a function so your toggle is applied only when you reach the start of the cycle - but I don't remember that function's name.