Trigger different sections/code blocks?

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
let
  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 !

3 Likes