Csound: FREQUENCYMODULATION
A vibrato is a periodical change of pitch, normally less than a halftone and with a slow changing-rate (around 5Hz). Frequency modulation is usually implemented using sine-wave oscillators.
EXAMPLE 04D01_Vibrato.csd
<CsoundSynthesizer> <CsOptions> -o dac </CsOptions> <CsInstruments> sr = 48000 ksmps = 32 nchnls = 2 0dbfs = 1 instr 1 aMod poscil 10, 5 , 1 ; 5 Hz vibrato with 10 Hz modulation-width aCar poscil 0.3, 440+aMod, 1 ; -> vibrato between 430-450 Hz outs aCar, aCar endin </CsInstruments> <CsScore> f 1 0 1024 10 1 ;Sine wave for table 1 i 1 0 2 </CsScore> </CsoundSynthesizer> ; written by Alex Hofmann (Mar. 2011)
As the depth of modulation is increased, it becomes harder to perceive the base-frequency, but it is still vibrato.
EXAMPLE 04D02_Vibrato_deep.csd
<CsoundSynthesizer> <CsOptions> -o dac </CsOptions> <CsInstruments> sr = 48000 ksmps = 32 nchnls = 2 0dbfs = 1 instr 1 aMod poscil 90, 5 , 1 ; modulate 90Hz ->vibrato from 350 to 530 hz aCar poscil 0.3, 440+aMod, 1 outs aCar, aCar endin </CsInstruments> <CsScore> f 1 0 1024 10 1 ;Sine wave for table 1 i 1 0 2 </CsScore> </CsoundSynthesizer> ; written by Alex Hofmann (Mar. 2011)
Increasing the modulation-rate leads to a different effect. Frequency-modulation with more than 20Hz is no longer recognized as vibrato. The main-oscillator frequency lays in the middle of the sound and sidebands appear above and below. The number of sidebands is related to the modulation amplitude, later this is controlled by the so called modulation-index.
EXAMPLE 04D03_FM_index.csd
<CsoundSynthesizer> <CsOptions> -o dac </CsOptions> <CsInstruments> sr = 48000 ksmps = 32 nchnls = 2 0dbfs = 1 instr 1 aRaise linseg 2, 10, 100 ;increase modulation from 2Hz to 100Hz aMod poscil 10, aRaise , 1 aCar poscil 0.3, 440+aMod, 1 outs aCar, aCar endin </CsInstruments> <CsScore> f 1 0 1024 10 1 ;Sine wave for table 1 i 1 0 12 </CsScore> </CsoundSynthesizer> ; written by Alex Hofmann (Mar. 2011)
Hereby the main-oscillator is called carrier and the one changing the carriers frequency is the modulator. The modulation-index: I = mod-amp/mod-freq. Making changes to the modulation-index, changes the amount of overtones, but not the overall volume. That gives the possibility produce drastic timbre-changes without the risk of distortion.
When carrier and modulator frequency have integer ratios like 1:1, 2:1, 3:2, 5:4.. the sidebands build a harmonic series, which leads to a sound with clear fundamental pitch.
EXAMPLE 04D04_Harmonic_FM.csd
<CsoundSynthesizer> <CsOptions> -o dac </CsOptions> <CsInstruments> sr = 48000 ksmps = 32 nchnls = 2 0dbfs = 1 instr 1 kCarFreq = 660 ; 660:440 = 3:2 -> harmonic spectrum kModFreq = 440 kIndex = 15 ; high Index.. try lower values like 1, 2, 3.. kIndexM = 0 kMaxDev = kIndex*kModFreq kMinDev = kIndexM*kModFreq kVarDev = kMaxDev-kMinDev kModAmp = kMinDev+kVarDev aModulator poscil kModAmp, kModFreq, 1 aCarrier poscil 0.3, kCarFreq+aModulator, 1 outs aCarrier, aCarrier endin </CsInstruments> <CsScore> f 1 0 1024 10 1 ;Sine wave for table 1 i 1 0 15 </CsScore> </CsoundSynthesizer> ; written by Alex Hofmann (Mar. 2011)
Otherwise the spectrum of the sound is inharmonic, which makes it metallic or noisy.
Raising the modulation-index, shifts the energy into the side-bands. The side-bands distance is: Distance in Hz = (carrierFreq)-(k*modFreq) | k = {1, 2, 3, 4 ..}
This calculation can result in negative frequencies. Those become reflected at zero, but with inverted phase! So negative frequencies can erase existing ones. Frequencies over Nyquist-frequency (half of samplingrate) "fold over" (aliasing).
Composer and researcher Jown Chowning worked on the first digital implementation of FM in the 1970's.
Using envelopes to control the modulation index and the overall amplitude gives you the possibility to create evolving sounds with enormous spectral variations. Chowning showed these possibilities in his pieces, where he let the sounds transform. In the piece Sabelithe a drum sound morphes over the time into a trumpet tone.
EXAMPLE 04D05_Trumpet_FM.csd
<CsoundSynthesizer> <CsOptions> -o dac </CsOptions> <CsInstruments> sr = 48000 ksmps = 32 nchnls = 2 0dbfs = 1 instr 1 ; simple way to generate a trumpet-like sound kCarFreq = 440 kModFreq = 440 kIndex = 5 kIndexM = 0 kMaxDev = kIndex*kModFreq kMinDev = kIndexM * kModFreq kVarDev = kMaxDev-kMinDev aEnv expseg .001, 0.2, 1, p3-0.3, 1, 0.2, 0.001 aModAmp = kMinDev+kVarDev*aEnv aModulator poscil aModAmp, kModFreq, 1 aCarrier poscil 0.3*aEnv, kCarFreq+aModulator, 1 outs aCarrier, aCarrier endin </CsInstruments> <CsScore> f 1 0 1024 10 1 ;Sine wave for table 1 i 1 0 2 </CsScore> </CsoundSynthesizer> ; written by Alex Hofmann (Mar. 2011)
The following example uses the same instrument, with different settings to generate a bell-like sound:
EXAMPLE 04D06_Bell_FM.csd
<CsoundSynthesizer> <CsOptions> -o dac </CsOptions> <CsInstruments> sr = 48000 ksmps = 32 nchnls = 2 0dbfs = 1 instr 1 ; bell-like sound kCarFreq = 200 ; 200/280 = 5:7 -> inharmonic spectrum kModFreq = 280 kIndex = 12 kIndexM = 0 kMaxDev = kIndex*kModFreq kMinDev = kIndexM * kModFreq kVarDev = kMaxDev-kMinDev aEnv expseg .001, 0.001, 1, 0.3, 0.5, 8.5, .001 aModAmp = kMinDev+kVarDev*aEnv aModulator poscil aModAmp, kModFreq, 1 aCarrier poscil 0.3*aEnv, kCarFreq+aModulator, 1 outs aCarrier, aCarrier endin </CsInstruments> <CsScore> f 1 0 1024 10 1 ;Sine wave for table 1 i 1 0 9 </CsScore> </CsoundSynthesizer> ; written by Alex Hofmann (Mar. 2011)
Combining more than two oscillators (operators) is called complex FM synthesis. Operators can be connected in different combinations often 4-6 operators are used. The carrier is always the last operator in the row. Changing it's pitch, shifts the whole sound. All other operators are modulators, changing their pitch alters the sound-spectrum.
The principle here is, that (M1:C) and (M2:C) will be separate modulations and later added together.
EXAMPLE 04D07_Added_FM.csd
<CsoundSynthesizer> <CsOptions> -o dac </CsOptions> <CsInstruments> sr = 48000 ksmps = 32 nchnls = 2 0dbfs = 1 instr 1 aMod1 poscil 200, 700, 1 aMod2 poscil 1800, 290, 1 aSig poscil 0.3, 440+aMod1+aMod2, 1 outs aSig, aSig endin </CsInstruments> <CsScore> f 1 0 1024 10 1 ;Sine wave for table 1 i 1 0 3 </CsScore> </CsoundSynthesizer> ; written by Alex Hofmann (Mar. 2011)
This is much more complicated to calculate and sound-timbre becomes harder to predict, because M1:M2 produces a complex spectrum (W), which then modulates the carrier (W:C).
EXAMPLE 04D08_Serial_FM.csd
<CsoundSynthesizer> <CsOptions> -o dac </CsOptions> <CsInstruments> sr = 48000 ksmps = 32 nchnls = 2 0dbfs = 1 instr 1 aMod1 poscil 200, 700, 1 aMod2 poscil 1800, 290+aMod1, 1 aSig poscil 0.3, 440+aMod2, 1 outs aSig, aSig endin </CsInstruments> <CsScore> f 1 0 1024 10 1 ;Sine wave for table 1 i 1 0 3 </CsScore> </CsoundSynthesizer> ; written by Alex Hofmann (Mar. 2011)
There is a strong relation between frequency modulation and phase modulation, as both techniques influence the oscillator's pitch, and the resulting timbre modifications are the same.
If you'd like to build a feedbacking FM system, it will happen that the self-modulation comes to a zero point, which stops the oscillator forever. To avoid this, it is more practical to modulate the carriers table-lookup phase, instead of its pitch.
Even the most famous FM-synthesizer Yamaha DX7 is based on the phase-modulation (PM) technique, because this allows feedback. The DX7 provides 7 operators, and offers 32 routing combinations of these. (http://yala.freeservers.com/t2synths.htm#DX7)
To build a PM-synth in Csound tablei opcode needs to be used as oscillator. In order to step through the f-table, a phasor will output the necessary steps.
EXAMPLE 04D09_PhaseMod.csd
<CsoundSynthesizer> <CsOptions> -o dac </CsOptions> <CsInstruments> sr = 48000 ksmps = 32 nchnls = 2 0dbfs = 1 instr 1 ; simple PM-Synth kCarFreq = 200 kModFreq = 280 kModFactor = kCarFreq/kModFreq kIndex = 12/6.28 ; 12/2pi to convert from radians to norm. table index aEnv expseg .001, 0.001, 1, 0.3, 0.5, 8.5, .001 aModulator poscil kIndex*aEnv, kModFreq, 1 aPhase phasor kCarFreq aCarrier tablei aPhase+aModulator, 1, 1, 0, 1 outs (aCarrier*aEnv), (aCarrier*aEnv) endin </CsInstruments> <CsScore> f 1 0 1024 10 1 ;Sine wave for table 1 i 1 0 9 </CsScore> </CsoundSynthesizer> ; written by Alex Hofmann (Mar. 2011)
Let's use the possibilities of self-modulation (feedback-modulation) of the oscillator. So in the following example, the oscillator is both modulator and carrier. To control the amount of modulation, an envelope scales the feedback.
EXAMPLE 04D10_Feedback_modulation.csd
<CsoundSynthesizer> <CsOptions> -o dac </CsOptions> <CsInstruments> sr = 48000 ksmps = 32 nchnls = 2 0dbfs = 1 instr 1 ; feedback PM kCarFreq = 200 kFeedbackAmountEnv linseg 0, 2, 0.2, 0.1, 0.3, 0.8, 0.2, 1.5, 0 aAmpEnv expseg .001, 0.001, 1, 0.3, 0.5, 8.5, .001 aPhase phasor kCarFreq aCarrier init 0 ; init for feedback aCarrier tablei aPhase+(aCarrier*kFeedbackAmountEnv), 1, 1, 0, 1 outs aCarrier*aAmpEnv, aCarrier*aAmpEnv endin </CsInstruments> <CsScore> f 1 0 1024 10 1 ;Sine wave for table 1 i 1 0 9 </CsScore> </CsoundSynthesizer> ; written by Alex Hofmann (Mar. 2011)
There has been error in communication with Booktype server. Not sure right now where is the problem.
You should refresh this page.