c2r
Prev | Orchestra Opcodes and Operators | Next

## c2r

c2r — Real to complex format conversion.

## Description

Converts a complex-valued input array into a real-valued array, by removing its imaginary part. The output array will be halt the size of the input. This is a utility operation to facilitate complex-valued operations where the result is purely real.

## Syntax

    kout[] c2r kin[]

## Performance

kout[] -- output array containing the real-valued output. It will be created if it does not exist.

kin[] -- input array containing the complex-valued real-imaginary input.

## Examples

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

Example 115. Example of the c2r opcode.

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

    <CsoundSynthesizer>
    <CsOptions>
    -d -o dac
    </CsOptions>
    <CsInstruments>
    ksmps = 64

    instr 1
    ifftsize = 1024
    kcnt init 0
    kIn[] init  ifftsize
    kOut[] init ifftsize

    a1 oscili 0dbfs/2, 440

    if kcnt >= ifftsize then
     kCmplx[] r2c kIn
     kSpec[] fft kCmplx
     kCmplx fftinv kSpec
     kOut c2r kCmplx
     kcnt = 0
    endif

    kIn[] shiftin a1
    a2 shiftout kOut
    kcnt += ksmps
       out a2
    endin
    </CsInstruments>
    <CsScore>
    i1 0 10
    </CsScore>
    </CsoundSynthesizer>

## See Also

Vectorial opcodes, array opcodes

## Credits

Author: Victor Lazzarini
NUI Maynooth
2014

New in version 6.04

Prev | Up | Next
buzz | Home | cabasa