foscil

foscil — A basic frequency modulated oscillator.

Description

A basic frequency modulated oscillator.

Syntax

ares foscil xamp, kcps, xcar, xmod, kndx, ifn [, iphs]

Initialization

ifn -- function table number. Requires a wrap-around guard point.

iphs (optional, default=0) -- initial phase of waveform in table ifn, expressed as a fraction of a cycle (0 to 1). A negative value will cause phase initialization to be skipped. The default value is 0.

Performance

xamp -- the amplitude of the output signal.

kcps -- a common denominator, in cycles per second, for the carrier and modulating frequencies.

xcar -- a factor that, when multiplied by the kcps parameter, gives the carrier frequency.

xmod -- a factor that, when multiplied by the kcps parameter, gives the modulating frequency.

kndx -- the modulation index.

foscil is a composite unit that effectively banks two oscil opcodes in the familiar Chowning FM setup, wherein the audio-rate output of one generator is used to modulate the frequency input of another (the carrier). Effective carrier frequency = kcps * xcar, and modulating frequency = kcps * xmod. For integral values of xcar and xmod, the perceived fundamental will be the minimum positive value of kcps * (xcar - n * xmod), n = 0,1,2,... The input kndx is the index of modulation (usually time-varying and ranging 0 to 4 or so) which determines the spread of acoustic energy over the partial positions given by n = 0,1,2,.., etc. ifn should point to a stored sine wave. Previous to version 3.50, xcar and xmod could be k-rate only.

The actual formula used for this implementation of FM synthesis is xamp * cos(2π * t * kcps * xcar + kndx * sin(2π * t * kcps * xmod) - π), assuming that the table is a sine wave.

Examples

Here is an example of the foscil opcode. It uses the file foscil.csd.

Example 314. Example of the foscil opcode.

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
-odac      ;;;realtime audio out
;-iadc    ;;;uncomment -iadc if realtime audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o foscil.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 32
nchnls = 2
0dbfs  = 1

instr 1

kcps = 440
kcar = 1
kmod = p4
kndx line 0, p3, 20	;intensivy sidebands

asig foscil .5, kcps, kcar, kmod, kndx, 1
     outs asig, asig

endin
</CsInstruments>
<CsScore>
; sine
f 1 0 16384 10 1

i 1 0  9 .01	;vibrato
i 1 10 .  1
i 1 20 . 1.414	;gong-ish
i 1 30 5 2.05	;with "beat"
e
</CsScore>
</CsoundSynthesizer>


See Also

More information about frequency modulation on Wikipedia: http://en.wikipedia.org/wiki/Frequency_modulation_synthesis