sqrt
Prev | Orchestra Opcodes and Operators | Next

## sqrt

sqrt — Returns a square root value.

## Description

Returns the square root of x (x non-negative).

The argument value is restricted for log, log10, and sqrt.

## Syntax

    sqrt(x) (no rate restriction)

where the argument within the parentheses may be an expression. Value converters perform arithmetic translation from units of one kind to units of another. The result can then be a term in a further expression.

## Examples

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

Example 760. Example of the sqrt 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 sqrt.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

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

    instr 1

    asig   pluck 0.7, 55, 55, 0, 1
    kpan   line 0,p3,1
    kleft  = sqrt(1-kpan)
    kright = sqrt(kpan)
    printks "square root of left channel = %f\\n", 1, kleft	;show coarse of sqaure root values
           outs asig*kleft, asig*kright					;where 0.707126 is between 2 speakers

    endin
    </CsInstruments>
    <CsScore>

    i 1 0 10
    e
    </CsScore>
    </CsoundSynthesizer>

Its output should include lines like these:

    square root of left channel = 1.000000
    square root of left channel = 0.948688
    square root of left channel = 0.894437
    square root of left channel = 0.836676
    square root of left channel = 0.774620
    square root of left channel = 0.707139
    square root of left channel = 0.632499
    square root of left channel = 0.547781
    square root of left channel = 0.447295
    square root of left channel = 0.316242

## See Also

abs, exp, frac, int, log, log10, i

Prev | Up | Next
spsend | Home | sr