Monday, January 9, 2012

Flux

In some ways, I have found that making music on a computer to be the exact opposite of making music on a traditional instrument. With a traditional instrument, one is always striving for perfection. With a computer, everything can be done "perfectly" right at the beginning. In fact, it is so perfect that doesn't sound musical at all. So while a traditional musician would spend his time striving for perfection, a computer musician would find himself chipping away at it.

Today I decided to play around a little with the idea of fluctuations ("flux," for the hip folks out there.)

Take a listen to these two Csound instruments I made, playing identical pieces of music:


Flux by The Zebra Project

Instrument A is nothing more than a simple triangle-wave oscillator with a volume envelope. Instrument B sounds very similar to instrument A, except with a few modifications. This was accomplished using two simple techniques:

1. Doubling and Wideness

A common producers technique is to duplicate an audio signal, add subtle variation to one of them, and then hard-pan each one left and right so that the two signals come out of separate speakers. This creates a very "wide" effect which can be especially heard in headphones.

To make this "wide" effect in instrument B, I made two oscillators with slight variations in tuning and in their volume envelopes, and sent one to the left speaker, and other to the right speaker.

2. Sample and Hold

Real instruments don't have perfect intonation, and neither should instrument B. Nuance is the key to creating expressive musical sounds. Pitch nuances can be made using a what is called a sample and hold generator. What exactly sample and hold generators do is beyond the scope of this post, so I highly recommend you read the synth secret article on it.

Instrument B has a sample and hold generator which generates a random number between 0 and 1 8 times a second. A value of 1 indicates that the pitch will get shifted by the maximum amount, and a value of 0 indicates no change at all. The depth of this change is determined by the variable idepth Instrument B.


For those interested, here is the code.


<CsoundSynthesizer>
<CsOptions>
;-odac ;realtime output
-o flux.aiff ;render to audio file

</CsOptions>
<CsInstruments>
sr = 96000
ksmps = 32
nchnls = 2
0dbfs = 1
instr 1
iamp = .2
ipch = cpspch(p4)

;one volume envelope
kamp1 linsegr 0, .0003, 1, .5, .05, .2, 0

;basic oscilator with no modulation
a1 oscil iamp*kamp1, ipch, 1

outs a1, a1
endin

instr 2
iamp = .2
ipch = cpspch(p4)
;sample and hold generator
krand randi 1, 8
;depth of modulation, where modulation is a number between 0-1 (best results < .05)
idepth = ipch* .005

;two volume envelopes, with subtle differences
kamp1 linsegr 0, .0003, 1, .5, .05, .2, 0
kamp2 linsegr 0, .0005, 1, .51, .05, .2, 0

;two oscillators with slight variations
a1 oscil iamp*kamp1, ipch*.998 + idepth*krand, 1
a2 oscil iamp*kamp2, ipch*1.002 + idepth*krand, 1

outs a2, a1 ;each oscillator sent to a different speaker
endin



</CsInstruments>
<CsScore>
f1 0 2048 7 1 1024 -1 1024 1 ;Triangle Wave
;Score Generated from a MIDI file made in Renoise and converted using another Csound instrument
i1 0.000000 0.913379 8.020000
i1 0.260771 1.304762 8.090000
i1 0.391383 1.434921 9.040000
i1 0.652154 1.434921 9.070000
i1 0.913152 1.173923 8.050000
i1 1.565306 0.521769 8.040000
i1 1.826077 0.260998 8.090000
i1 2.086848 0.913379 8.020000
i1 2.347846 1.304535 8.090000
i1 2.478231 1.435147 9.040000
i1 3.000000 1.174150 8.050000
i1 3.652154 0.782766 8.040000
i1 3.913152 0.652381 8.090000
i1 2.739229 2.087075 9.070000
i1 4.173923 0.913152 8.020000
i1 4.434694 0.913379 8.090000
i1 4.565306 0.913152 9.060000
i1 4.826077 0.913379 9.040000
i1 5.086848 0.913379 8.000000
i1 5.347846 0.652381 8.070000
i1 5.478231 0.521995 9.040000
i1 5.739229 0.260998 9.020000
i1 6.000000 1.304535 9.010000
i1 6.000000 1.304535 8.020000
i1 6.000000 1.304535 8.059999

i2 8.347846 0.913152 8.020000
i2 8.608617 1.304762 8.090000
i2 8.739229 1.434921 9.040000
i2 9.000000 1.434921 9.070000
i2 9.260771 1.174150 8.050000
i2 9.913152 0.521769 8.040000
i2 10.173923 0.260998 8.090000
i2 10.434694 0.913379 8.020000
i2 10.695692 1.304535 8.090000
i2 10.826077 1.434921 9.040000
i2 11.347846 1.174150 8.050000
i2 12.000000 0.782766 8.040000
i2 12.260771 0.652608 8.090000
i2 11.086847 2.087302 9.070000
i2 12.521770 0.913152 8.020000
i2 12.782539 0.913379 8.090000
i2 12.913153 0.913152 9.060000
i2 13.173923 0.913152 9.040000
i2 13.434694 0.913379 8.000000
i2 13.695692 0.652381 8.070000
i2 13.826077 0.521995 9.040000
i2 14.086848 0.261225 9.020000
i2 14.347846 1.304535 8.059999
i2 14.347846 1.304535 8.020000
i2 14.347846 1.304535 9.010000
</CsScore>
</CsoundSynthesizer>


No comments:

Post a Comment