Index | Next Week | Previous Week |
amod oscil p4*.2, cpspch(p5), 1 ; modulator asig oscil p4*.8, cpspch(p5) + amod, 1 ; carrier outs asig, asig
but foscil simplifies the process and is much easier to control. In essence though, a foscil is performing the computations shown above.
A foscil normal operates at audio (a-) rate and its arguments are:
asig foscil amp, freq, carrier, modulator, index, function
The amp and frequency are identical to oscil (they can include envelopes, cpspch conversion, vibrato, tremolo etc.). The function should normally be a sine wave - F. M. naturally produces rich spectra from sine waves, if you use complex waves as your source, you will get extremely complex sounds as your result. The carrier and modulator are expressed as a ratio (i.e carrier has the value 1, and modulator has the value 4). This is possible since you already have a frequency argument. The index value is noramlly close to 1 (rarely above 15 or 20).
asig foscil p4*kenv, cpspch(p5), 1, 3, 2, 1 ; simple f.m. with 1:3 ratio outs asig, asig ; and index of 2
asig foscil p4*kenv, cpspch(p5), 1, 2.17, 8, 1 ; complex f.m. with 1:2.17 outs asig, asig ; ratio and index of 8
kenv expon 1, p3, .0001 ; expon envelope kline line 1, p3, 8 ; sweep index from 1 to 8 asig foscil p4 * kenv, cpspch(p5), 1, 1.414, kline, 1 ; bell with index sweep outs asig, asig ; stereo output
asig foscil p4, cpspch(p5), 1, 2.01, 1, 1 ; f.m. instrument arev reverb asig, 2.0 ; 2 second reverb outs arev + asig, arev + asig ; output both signals
asig foscil p4, cpspch(p5), 1, 2.01, 1, 1 ; f.m. instrument arev reverb asig, 2.0 ; 2 second reverb kctrl line 1, p3, 0 ; line from 1 to 0 outs1 (asig* kctrl) + (arev * (1-kctrl)) ; output mix (increasing reverb) outs2 (asig* kctrl) + (arev * (1-kctrl)) ; output mix (increasing reverb)
instr 99 ga1 init 0 ; initialize to 0 asig reverb ga1, 1.75 ; reverb time 1.75 outs asig * .5, asig * .5 ; output reverb ga1 = 0 ; clear ga1 endin
This instrument must be turned on (in the score) for the duration of the composition (or whenever any instrument might require the reverb instrument)
i99 0 40 ; turn on for 40 seconds
The reverb instrument contains a global variable (ga1). Global variables can be specified as ga-, gk- or gi- for audio, control or initialization rates. A global variable is available to all instruments at any time. This is different from the local variables we have been using which are available only to a particular copy of an instrument - the asig variable in an instrument starting at time 0 will never be confused with the asig variable in an overlapping instrument starting at time .5. Because global variables are available to all instruments, they can be used to transfer audio signals to a reverb instrument. In the instrument designed above, the reverb unit expects to receive an audio signal in the variable ga1 - it then creates reverberation of this sound and sends it out. The instrument below, creates an audio signal in asig and outputs it. The audio signal is also added to ga1 so that it can be sent (along with any other other audio signals currently active) to the reverb instrument (which must also be running at the time).
kenv expon 1, p3, .0001 ; expon envelope asig foscil p4*kenv, cpspch(p5), 1, 1.01, 3, 1 ; fm ratio 1 : 1.01 outs asig, asig ; output audio singal ga1 = ga1 + asig ; add asig to ga1 ; reverb will receive ga1
Warning: In this design, ga1 accumulates the audio signals from all active copies of the instrument and the reverberation instrument creates the reverb. If you have too many copies of an instrument playing at once (say 20), the value of ga1 may become so high that distortion will occur - in this case you may want to adjust the amount of the original audio signal that is being reverberated:
ga1 = ga1 + (asig * .2) ; reverberate only 1/5
Similarly, if your reverb time is excessively long (say 15 seconds) you may also want to reduce the amount of signal being passed to the reverb.
Index | Next Week | Previous Week |