<=
Prev | Orchestra Opcodes and Operators | Next

## <=

<= — Determines if one value is less than or equal to another.

## Description

Determines if one value is less than or equal to another.

## Syntax

    (a <= b ? v1 : v2)

where a, b, v1 and v2 may be expressions, but a, b not audio-rate.

## Performance

In the above conditional, a and b are first compared. If the indicated relation is true (a less than or equal to b), then the conditional expression has the value of v1; if the relation is false, the expression has the value of v2.

NB.: If v1 or v2 are expressions, these will be evaluated before the conditional is determined.

In terms of binding strength, all conditional operators (i.e. the relational operators (<, etc.), and ?, and : ) are weaker than the arithmetic and logical operators (+, -, *, /, && and ||).

These are operators not opcodes. Therefore, they can be used within orchestra statements, but do not form complete statements themselves.

## Examples

Here is an example of the <= operator. It uses the file lessequal.csd.

Example 25. Example of the <= operator.

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 <=.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

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

    instr 1

    kval    randomh 0, 1.2, 20		;choose between 0 and 1.2

    if kval >0 && kval<=.5 then		;3 possible outcomes
    	kvl = 1
    elseif kval >.5 && kval<=1 then
    	kvl =2
    elseif kval >1 then
    	kvl =3
    endif

    printks "random number = %f, result = %f\n", .1, kval, kvl
    asig    poscil .7, 440*kvl, 1
            outs asig, asig

    endin
    </CsInstruments>
    <CsScore>
    f1 0 16384 10 1

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

Its output should include lines like this:

    random number = 1.035781, result = 3.000000
    random number = 0.134037, result = 1.000000
    random number = 0.130742, result = 1.000000
    random number = 1.002550, result = 3.000000
    random number = 0.370565, result = 1.000000
    random number = 0.655759, result = 2.000000
    random number = 0.676154, result = 2.000000
    ......

## See Also

==, >=, >, <, !=

Prev | Up | Next
< | Home | *