Skip to content

Instantly share code, notes, and snippets.

@kindohm
Last active August 30, 2017 20:16
Show Gist options
  • Save kindohm/1e05ad0b66395427a11a58cbcc740437 to your computer and use it in GitHub Desktop.
Save kindohm/1e05ad0b66395427a11a58cbcc740437 to your computer and use it in GitHub Desktop.
d-code info

d-code info

https://soundcloud.com/kindohm/d-code

This is a de-construction of the above linked track and how it was composed and built with TidalCycles.

sample composition strategy

The real crux of this track and how it is composed in code depends on kick/snare pairs, located in the name sample folder. This is really the important part. You have to know how that folder is structured before digging into the code:

name--|
      |-kick01.wav
      |-snare01.wav
      |-kick02.wav
      |-snare02.wav
      |-kick03.wav
      |-snare03.wav
      |-kick04.wav
      |-snare04.wav

The code literally depends on the exact ordering of these files, as above.

The npat pattern defines the progression of the kick samples:

let npat = "[0 2 4 6]/16"

sound "name([3 5 7]/3,16)" # n npat

Then the snares are offset by n+1:

slow 2 $ (|+| n "1") $ sound "~ name [~ name] ~" # n npat

The key is that npat changes every 4 cycles, and keep the kicks and snares cycling through different sound pairs.

Code Composition Strategy

Basically, there's the kick/snare pairs, a background synth texture, and a drum break.

background synth texture

There's a weird background synth stab/pad/texture thing happening under the name namesy:

slow 2 $ rep 6 $ sound "namesy" # n "[0 1]/8" # cut "23" # gain "1" # speed "0.5" # shape "0.4"

It's two samples (n "[0 1]/8) that cut each other.

drum break

A drum break:

degradeBy 0.3 $ brakk "fur1*8" # gain "0.9"

I use a custom function called brakk which constructs a cohesive random break out of break slices. More on that below.

The Stack (and Transform/Glitching Functions)

I tend to put everything in d1 and use a stack to sandwich all patterns together into one parent pattern. Child patterns inside the stack might have some transforms or special functions performed on them. I also put top-level transform functions on top of the whole stack. This is kind of my signature approach to a Tidal composition.

I also have a nested stack in this code. I don't do that a lot. For reasons I cannot remember, I used the nested stack to accomplish something specific in this case. At a glance, it doesn't look like it is doing anything useful.

The top-level transforms on top of the stack:

whenmod 14 11 (iter 8) $
move $
whenmod 13 11 (|=| accelerate "1") $
every 9 (rev) $
every 4 (chop 4) $
every 7 (rip 0.5 0.1) $
every 6 (rip' 0 1 8 0.25 0.1) $
every 5 (|=| coarse (shift' 3 $ choose [4,6..18])) $
every 8 (|=| accelerate "0.5 -0.5") $

Those functions are what really glitch everything up. My favorite things :)

rip is a custom glitching function that creates a backwards "rush" effect. move just shifts time around at given cycles.

Sound Design

Okay this is the really interesting part. It's important to me to come up with sounds I like and that make me feel good. This d-code track kind of caps off an experiment I've been doing with additive synthesis, re-synthesis, and creating weird alien sounds.

Drum re-synthesis

I built four pairs of kicks and snares in an Elektron Analog RYTM, then sampled the one-shots. I then imported the samples into a VST synth called "Harmor" (available as a VST from image-line.com). Harmor is a very special synth to me and I have fallen in love with it.

Harmor has the ability to "re-synthesize" samples by converting a sample into individual harmonic partials (sine waves). It isn't time stretching or granualization; it literally deconstructs a sample into sine waves. The eight drum samples were individually re-synthesized in Harmor, and each one got a unique treatment. Treatment may have included adding unison voices, detuning, pitch envelope changes, harmonic blurring, time stretching, formant filter tweaking, etc, etc, etc blah blah blah. All kinds of weird stuff. The result is drum samples that take on a weird alien quality - at least that's what I hear.

Background Synths

The namesy samples were also created with Harmor. I created original sounds inside Harmor, rendered them as one-shot samples, then re-synthesized them inside Harmor. So kind of a two-step resynthesis treatment in Harmor. Again, this just results in odd harmonic alient weirdness.

Drum Break

I used an existing break I've had for a long time. It was part of a "Dave Akuma" break pack, and as I recall, was called "Nick Fury Break #1". Not sure where you can obtain this now; it might exist on a forum in a zip file somewhere.

The "brakk" function

This is a custom Tidal function I created to assist with creating random drum break patterns. It requires me to pre-slice a break loop into eight individual slices (e.g. eight note divisions).

So the function is defined like this:

let brakk samps = ((|=| unit "c") . (|=| speed "8")) $ sound (samples samps (irand 30))

And is used like this:

d1 $ brakk "breakslices*8"

So let's deconstruct what brakk is doing:

  • unit "c" will stretch each slice to a full cycle length
  • speed "8" will shrink each slice to an eighth of a cycle when used with unit "c"
  • sound (samples samps (irand 30)) will just play a random slice from "breakslices*8"

brakk could be re-written today like this:

let brakk samps = ((# unit "c") . (# speed "8")) $ sound samps # n (irand 30)

or a more flexible version:

let brakk samps num slices = density num $ ((# unit "c") . (# speed num)) $ sound samps # n (irand slices)
bps (180/120)
let npat = "[0 2 4 6]/16"
let rip a b p = within (0.25, 0.75) (slow 2 . rev . stut 8 a b) p
rip' a b c d e p = within (a, b) (slow 2 . rev . stut c d e) p
move p = foldEvery [3,4] (0.25 <~) $ p
brakk samps = ((|=| unit "c") . (|=| speed "8")) $ sound (samples samps (irand 30))
rep n p = stut' (n-1) (0.125*3) (|*| gain "1") $ p
shift p = (1024 <~) p
shift' x p = (x <~) p
d1 $ whenmod 14 11 (iter 8) $
move $
whenmod 13 11 (|=| accelerate "1") $
every 9 (rev) $
every 4 (chop 4) $
every 7 (rip 0.5 0.1) $
every 6 (rip' 0 1 8 0.25 0.1) $
every 5 (|=| coarse (shift' 3 $ choose [4,6..18])) $
every 8 (|=| accelerate "0.5 -0.5") $
stack [
degradeBy 0.3 $ brakk "fur1*8" # gain "0.9",
stack [
rarely (stut' 1 (0.0625) (|*| gain "1")) $ sound "name([3 5 7]/3,16)" # n npat,
slow 2 $ (|+| n "1") $ sound "~ name [~ name] ~" # n npat # shape "0.2"],
slow 2 $ rep 6 $ sound "namesy" # n "[0 1]/8" # cut "23" # gain "1" # speed "0.5" # shape "0.4"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment