Sunday, January 13, 2008

Psytrance in Csound. 3 - Bass

So I'm happy enough with the kick, let's start building the groove. Next, I'll add a simple bassline to build the foundation of the track. I'm thinking something simple and typical: a filtered sawtooth with a touch of reverb. For the sake of saving space, I'll leave out the portion of the code that has already been used for the kick.

;=== ORCHESTRA ===


instr 2

p5 = 32768*p5
klvl expseg 1, .050, .5, .450, 0.00003
aosc vco p5*klvl, cpspch(p4), 1, .5, 1
kcut linseg 1, .030, .1
afilt moogladder aosc, 5000*kcut, .4
al,ar freeverb afilt, afilt, 0.8, 0.35, sr, 0
al = afilt+al*p6
ar = afilt+ar*p6
outs al, ar

endin


;=== SCORE ===


; instr start dur pitch level reverb
i 2 0.50 6 5.09 .8 .04
i 2 1.50 6 6.09 .8 .04
i 2 2.50 6 5.09 .8 .04
i 2 2.75 6 6.07 .8 .04
i 2 3.50 6 6.09 .8 .04

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

About the code... I used an exponential envelope for the amplitude, and the 0.00003 comes from the fact you can't use 0 in exponential envelopes in Csound. If you divide 1 by 32768 (to get the smallest 16-bit value) you get 0.0000305... in other words, 0.00003 is a "practical zero". Another thing I like about Csound is the ability to control filter frequencies with ultimate precision. In this case, the envelope takes the cutoff from 5000 to 500 in 30ms. In the score, note the long 6-beat duration of each note, to allow the reverb to come through.

It all sounds nice enough, but why not fatten it up a little? Let's add two more oscillators, detuned slightly.

;=== ORCHESTRA ===


instr 2

p5 = 32768*p5
klvl expseg 1, .050, .5, .450, 0.00003
aosc1 vco p5*klvl, cpspch(p4), 1, .5, 1
aosc2 vco p5*klvl, cpspch(p4)*1.01, 1, .5, 1
aosc3 vco p5*klvl, cpspch(p4)*0.99, 1, .5, 1
aoscall = aosc1+aosc2+aosc3
kcut linseg 1, .030, .1
afilt moogladder aoscall, 5000*kcut, .4
al,ar freeverb afilt, afilt, 0.8, 0.35, sr, 0
al = afilt+al*p6
ar = afilt+ar*p6
outs al, ar

endin

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

I could improve it even further by adding random detuning to the oscillators, or by adding more oscillators, plus effects like chorus or delay, adding pitch tracking to the filter, etc. Maybe later, but we'll stick with that for now.

No comments: