Index | Next Week | Previous Week |
The common conversion between one form and another are:
Index
The next example takes p5 from the score in pch notation and glisses down one octave.
The next example applies a ramp and causes the sound to move from the left channel to the right channel. Since we are multiplying the output of the control by the audio signal, the range of 1 to 0 is appropriate.
In any of the above examples, line could be replaced by a more complex control such as expon, linseg or expseg.
Index
Index
In a vibrato, the control is added to the frequency argument of the audio oscillator. The addition must be made to frequency in cps - adding the value to pch or oct encoded frequency will produce strange results. The amplitude of the control vibrato indicates the amount (in cps) above and below the centre frequency that the pitch will deviate. In the example below, it will move 20 cycles above and below cpspch(p5).
Index
Creating composite envelopes with linseg and expseg
To increase control over the decay characteristics of an envelope, it is sometimes necessary to mix two envelopes together. This is normally done by creating a expseg envelope (with an exponential decay) and MULTIPLYING it by a linseg envelope which sits at 1 for the beginning part of the sound and increases while the expseg is decaying. The result of multiplying the two functions is a modified exponential decay that tends to sound more natural.
k1 expseg .0001, .01, 1, .01, .5, p3 - .02, .001 ; decaying expseg
k2 linseg 1, .02, 1, p3-.02, 2.5 ; rising linseg
k3 = k1 * k2
Applying envelope controls to other aspects of the sound
line, expon, linseg and expseg are very useful for amplitude envelopes, but they can be used as a control on virtually any aspect of the sound. However, you must ensure that the values that will be returned from the control are appropriate values for the receiving generator. For example, if you want to apply a ramp (i.e. a line) on the frequency of a sound, the starting and ending values of the line should be appropriate frequency values - a line moving from 1 to 0 will not produce audible sound. The example below creates a glissando from 1200 cps to 400 cps
kgliss line 1200, p3, 400 ; line from 1200 to 400
asig oscil p4, kgliss, 1 ; oscillator
istart = cpspch(p5) ; starting pitch
ifin = cpspch(p5 - 1.00) ; end pitch octave down
kgliss line istart, p3, ifin ; line from 1200 to 400
asig oscil p4, kgliss, 1 ; oscillator
asig oscil p4, cpspch(p5), 1 ; oscillator
kpan line 1 p3, 0 ; line from 1 to 0 for pan
outs asig * kpan, asig * (1-kpan) ; output complementary values in right and left channels
Additive synthesis
Additive synthesis is th process of creating a complex sound by ADDING component sine waves each with independent amplitude envelopes. We have already created compex waveforms using GEN-9 and GEN-10, but these waveforms were used by a single oscillator. In additive synthesis, we want to use sinewaves as the waveform function and to add multiple oscillators each with an independent amplitude envelope. In the example below, two audio signals are added together: the first produces the fundamental, the second produces the second partial (frequency is ifund * 2).
ifund = cpspch(p5) ; fundamental
kenv1 expseg .0001, .01, 1, .01, .5, p3 - .02, .0001 ; envelope 1
asig1 oscil p4 * kenv1, ifund, 1 ; oscillator 1
kenv2 expseg .0001, .01, .7, .03, .4, p3 - .04, .0001 ; envelope 2
asig2 oscil p4 * kenv2, ifund*2, 1 ; oscillator 2
outs (asig1 + asig2)/2, (asig1 + asig2)/2 ; output mix
Notice that when two audio signals are added together, the output is divided by two. It is necessary to scale down the overall amplitude so that it doesn't produce samples out of range. We could create a much more complex instrument by adding together more partials, and perhaps even adding a control on the frequency.
Using oscil as a control to produce vibrato and tremolo
Most commercial synthesizers use a LFO (low frequency oscillator) to create vibrato and tremolo effects. In Csound, we can create a similar effect by using an oscil as to effect the amplitude or frequency of a second audio oscil. The control oscil is passed to a k- variable, and the k- variable is used within the subsequent a- variable oscil. When this is done properly, the control oscil creates a periodic change in the audio signal which is perceived as either tremolo (when applied to amplitude) or vibrato (when applied to frequency). However, to create these effects, the speed of the control oscil must be slow (ie. less that 12 times a second) and the amplitude must be low - otherwise the control oscillator will have too great an effect on the audio signal. In the tremolo example below, the control oscillator has an amplitude that is 1/100 of the total amplitude (.01 * p4), and the speed of the tremolo is 8 cps. The output from the control oscillator is ADDED in the amplitude argument of the audio oscil.
ktrem oscil .01 * p4, 8, 1 ; tremolo at 8 times per second
asig oscil p4 + ktrem, cpspch(p5), 2 ; audio oscillator
outs asig, asig
If an amplitude envelope is added to the above example, we would want it to affect both the tremolo and the total amplitude - (p4 + ktrem) * kenv rather than (p4 * kenv) + ktrem. These reduces the strenght of the tremolo as the sound gets quieter.
kenv expon 1, p3, .0001 ; ampitude envelope
ktrem oscil .01 * p4, 8, 1 ; tremolo at 8 times per second
asig oscil (p4 + ktrem) * kenv, cpspch(p5), 2 ; audio oscillator
outs asig, asig
kenv expon 1, p3, .0001 ; amplitude envelope
kvib oscil 20, 6, 1 ; vibrato at 6 times per second
asig oscil p4 * kenv, cpspch(p5) + kvib, 2 ; audio oscillator
outs asig, asig
It is sometimes a good idea to relate your vibrato depth (the amplitude of the control oscil) to the main frequency. If you do this, an even vibrato will be created across registers - Remember - 20 cycles is a large interval in very low sounds and a tiny interval in high sounds.
idepth = cpspch(p5) * .05 ; 1/20 of the main freq
kvib oscil idepth, 6, 1 ; vibrato at 6 times per second
asig oscil p4 * kenv, cpspch(p5) + kvib, 2 ; audio oscillator
outs asig, asig
Suggested Assignment
Index | Next Week | Previous Week |