Sunday, January 13, 2008

Psytrance in Csound. 2 - Kick

The common Psytrance kick is simple: a sweeping sine wave that starts high and quickly decays to a low pitch. When made in a sound editor like Sound Forge, it starts as a sine wave at a low frequency around 50-60 Hz, maybe even lower. Pitch shifting is applied to the first few milliseconds of the waveform until the kick feels right. The only problem with this process is that these shifts are performed almost randomly until the very last one. If the kick doesn't feel right, you have to undo and redo these shifts until you find the right combination of decay times and shifting amounts. Trying to duplicate the result is nearly impossible because of this haphazard method.


In Csound we can control these sweeps one by one, and tweak them until we find the right kick. In fact, the very makeup of the kick could be automated -- I'm not going there, but it's definitely possible. So I started with a simple architecture: three envelopes controlling the pitch of a sine wave. One for the main downward sweep (a small one of an octave or two spanning the full length of the kick), another for the initial decay of the wave, and the last one (a quick "thunk") for impact. This is what I came up with:

;=== ORCHESTRA ===

sr = 44100
kr = 44100
ksmps = 1
nchnls = 2

instr 1

p5 = 32768*p5
k1 linseg 1.5, .200, .5
k2 linseg 2, .060, 1
k3 linseg 4, .010, 1
akick oscil p5, p4*k1*k2*k3, 1
al = akick
ar = akick
outs al, ar

endin


;=== SCORE ===

f 1 0 8192 10 1
t 0 150

; instr start dur freq level
i 1 0 .5 44 .8
i 1 1 .5 44 .8
i 1 2 .5 44 .8
i 1 3 .5 44 .8

e

Listen (psy2-1.mp3) or Download Code & WAV (psy2-1.zip)

To briefly explain the code... I like notating levels and other parameters from 0 to 1, hence the p5 conversion in the first line. k1 sweeps the pitch from 1.5 octaves above the base pitch down to an octave below. It's a more dramatic sweep than you'd normally find in your common kick, but I like it like that. k2 adds a 60ms 2-octave sweep for the decay and k3 adds a 10ms 4-octave sweep for the attack. In the score file, I have one bar with 4 kicks for testing, each one an eighth-note long (half a beat). I picked 44Hz for the base frequency because it's "related" to A (440Hz, although a low A is 55Hz), so we'll keep this song in A. Some producers like to offset the kick perfectly to the 3rd or 5th of the key of the song, or pitch the kick by ear, but I'll keep it like this for now.

It's getting there, but it's missing a few things. The attack needs a little more bite, so I'll add another envelope for that. There's no dynamic control, that's why there's a click at the end of each kick, so I'll add an amplitude envelope too. Finally, a touch of reverb, gated to the duration of the kick, to add a bit of air. To make the amount of reverb more dynamic in the future, we'll add p6 to the score to control the wet/dry mix.

;=== ORCHESTRA ===

sr = 44100
kr = 44100
ksmps = 1
nchnls = 2


instr 1

p5 = 32768*p5
k1 linseg 1.5, .200, .5
k2 linseg 2, .060, 1
k3 linseg 4, .010, 1
k4 linseg 4, .002, 1
klvl linseg 0, .0002, 1, .030, .8, .080, .7, p3-.1102, 0
akick oscil p5*klvl, p4*k1*k2*k3*k4, 1
al,ar freeverb akick, akick, 0.8, 0.35, sr, 0
al = (akick*(1-p6))+(al*p6)
ar = (akick*(1-p6))+(ar*p6)
outs al, ar

endin


;=== SCORE ===

f 1 0 8192 10 1
t 0 150

; instr start dur freq level reverb
i 1 0 .5 44 .8 .01
i 1 1 .5 44 .8 .01
i 1 2 .5 44 .8 .01
i 1 3 .5 44 .8 .01

e

Listen (psy2-2.mp3) or Download Code & WAV (psy2-2.zip)

I like it. Next I'll add a simple bassline to go with it and create macros in the score to save on typing.

2 comments:

Anonymous said...

mate a low A is 55Hz not 44Hz

Joe Maffei said...

Ouch! How did I let that one slip? Thanks for the correction. I already edited the article accordingly. I guess the idea was for the song to be in A, so I picked a number that related to A somehow. It seems that multiples of 11 work well harmonically in the key of A.