doppler
Prev | Orchestra Opcodes and Operators | Next

## doppler

doppler — A fast and robust method for approximating sound propagation, achieving convincing Doppler shifts without having to solve equations.

## Description

Plugin opcode in doppler.

A fast and robust method for approximating sound propagation, achieving convincing Doppler shifts without having to solve equations. The method computes frequency shifts based on reading an input delay line at a delay time computed from the distance between source and mic and the speed of sound. One instance of the opcode is required for each dimension of space through which the sound source moves. If the source sound moves at a constant speed from in front of the microphone, through the microphone, to behind the microphone, then the output will be frequency shifted above the source frequency at a constant frequency while the source approaches, then discontinuously will be shifted below the source frequency at a constant frequency as the source recedes from the microphone. If the source sound moves at a constant speed through a point to one side of the microphone, then the rate of change of position will not be constant, and the familiar Doppler frequency shift typical of a siren or engine approaching and receding along a road beside a listener will be heard.

## Syntax

    ashifted doppler asource, ksourceposition, kmicposition [, isoundspeed, ifiltercutoff]

## Initialization

isoundspeed (optional, default=340.29) -- Speed of sound in meters/second.

ifiltercutoff (optional, default=6) -- Rate of updating the position smoothing filter, in cycles/second.

## Performance

asource -- Input signal at the sound source.

ksourceposition -- Position of the source sound in meters. The distance between source and mic should not be changed faster than about 3/4 the speed of sound.

kmicposition -- Position of the recording microphone in meters. The distance between source and mic should not be changed faster than about 3/4 the speed of sound.

## Examples

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

Example 244. Example of the doppler 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     ;;;RT audio out
    ;-iadc    ;;;uncomment -iadc if RT audio input is needed too
    ; For Non-realtime ouput leave only the line below:
    ; -o doppler.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

    sr = 48000
    ksmps = 128
    nchnls = 2
    0dbfs = 1

    instr 1

    iattack       init    0.05
    irelease      init    0.05
    isustain      init    p3
    p3            init    iattack + isustain + irelease
    kdamping      linseg  0.0, iattack, 1.0, isustain, 1.0, irelease, 0.0
    kmic          init    4
                  ; Position envelope, with a changing rate of change of position.
    ;             transeg a   dur   ty  b      dur    ty  c    dur    ty d
    kposition     transeg 4, p3*.4, 0, 120,   p3*.3, -3, 50,   p3*.3, 2, 4
    ismoothinghz  init    6
    ispeedofsound init    340.29
    asignal       vco2    0.5, 110
    aoutput       doppler asignal, kposition, kmic, ispeedofsound, ismoothinghz
                  outs    aoutput*kdamping, aoutput * kdamping
    endin

    </CsInstruments>
    <CsScore>

    i1	0.0	20
    e1
    </CsScore>
    </CsoundSynthesizer>

## Credits

Author of algorithm: Peter Brinkmann
Author of opcode: Michael Gogins
January 2010

New in Csound version 5.11

Prev | Up | Next
divz | Home | dot