crossfm
Prev | Orchestra Opcodes and Operators | Next

## crossfm

crossfm — Two mutually frequency and/or phase modulated oscillators.

## Description

Two oscillators, mutually frequency and/or phase modulated by each other.

## Syntax

    a1, a2 crossfm xfrq1, xfrq2, xndx1, xndx2, kcps, ifn1, ifn2 [, iphs1] [, iphs2]

    a1, a2 crossfmi xfrq1, xfrq2, xndx1, xndx2, kcps, ifn1, ifn2 [, iphs1] [, iphs2]

    a1, a2 crosspm xfrq1, xfrq2, xndx1, xndx2, kcps, ifn1, ifn2 [, iphs1] [, iphs2]

    a1, a2 crosspmi xfrq1, xfrq2, xndx1, xndx2, kcps, ifn1, ifn2 [, iphs1] [, iphs2]

    a1, a2 crossfmpm xfrq1, xfrq2, xndx1, xndx2, kcps, ifn1, ifn2 [, iphs1] [, iphs2]

    a1, a2 crossfmpmi xfrq1, xfrq2, xndx1, xndx2, kcps, ifn1, ifn2 [, iphs1] [, iphs2]

## Initialization

ifn1 -- function table number for oscillator #1. Requires a wrap-around guard point.

ifn2 -- function table number for oscillator #2. Requires a wrap-around guard point.

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

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

## Performance

xfrq1 -- a factor that, when multipled by the kcps parameter, gives the frequency of oscillator #1.

xfrq2 -- a factor that, when multipled by the kcps parameter, gives the frequency of oscillator #2.

xndx1 -- the index of the modulation of oscillator #2 by oscillator #1.

xndx2 -- the index of the modulation of oscillator #1 by oscillator #2.

kcps -- a common denominator, in cycles per second, for both oscillators frequencies.

crossfm implements a crossed frequency modulation algorithm. The audio-rate output of oscillator #1 is used to modulate the frequency input of oscillator #2 while the audio-rate output of oscillator #2 is used to modulate the frequency input of oscillator #1. This double feedback structure produces a rich set of sounds with some chaotic behaviour. crossfmi behaves like crossfm except that linear interpolation is used for table lookup.

crosspm and crosspmi implement cross phase modulation between two oscillators.

crossfmpm and crossfmpmi implement cross frequency/phase modulation between two oscillators. Oscillator #1 is frequency-modulated by oscillator #2 while oscillator #2 is phase-modulated by oscillator #1.

| Warning
Those opcodes may produce very rich spectra, especially with high modulation indexes, and in some cases foldover aliases may occur if the sampling rate is not high enough. Moreover the audio output may vary in function of the sampling rate, due to the non-linearity of the algorithm. In Csound, two other opcodes have this characteristic: planet and chuap.

## Examples

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

Example 187. Example of the crossfm opcode.

    <CsoundSynthesizer>

    <CsOptions>
      -d -o dac
    </CsOptions>

    <CsInstruments>
    sr     = 48000
    ksmps  = 10
    nchnls = 2
    0dbfs  = 1

              instr 1
    idur       =          p3
    iamp       =          p4
    ifrq1      =          p5
    ifrq2      =          p6
    indx1      =          p7
    indx2      =          p8
    kenv       linen      iamp, 0.05, idur, 0.2
    a1, a2     crossfm    ifrq1, ifrq2, indx1, indx2, 1, 1, 1
               outs       a1*kenv, a2*kenv
              endin

              instr 2
    kx         init       0.0
    kdx        init       0.1
    kdur       init       p4
    kamp       init       p5
    kndx       init       0
    kmax       init       p6
    kfq1       init       440.0
    kfq2       init       557.0
    knx1       init       3.5
    knx2       init       4.8
               event      "i", 1, kx, kdur, kamp, kfq1, kfq2, knx1, knx2
    kx         =          kx + kdx
    knx1       =          knx1 - 0.025
    knx2       =          knx2 - 0.075
    kndx       =          kndx + 1
    if (kndx <= kmax) kgoto nextone
               turnoff
    nextone:
              endin
    </CsInstruments>

    <CsScore>
    f 1 0 16384 10 1 0

    i 2 0 2 0.67 0.16 150
    i 1 15.1 1.5 0.1 440 557 -0.25 -6.45 0.05 1.2
    e
    </CsScore>
    </CsoundSynthesizer>

## See Also

More information on these opcodes: http://www.csoundjournal.com/issue12/crossfm.html.

## Credits

Author: François Pinot
2005-2009

New in version 5.12

Prev | Up | Next
cross2 | Home | crunch