Prev | Orchestra Opcodes and Operators | Next

## ||

|| — Logical OR operator.

## Description

Arithmetic operators perform operations of change-sign (negate), don't-change-sign, logical AND logical OR, add, subtract, multiply and divide. Note that a value or an expression may fall between two of these operators, either of which could take it as its left or right argument, as in

a + b * c.

In such cases three rules apply:

1. * and / bind to their neighbors more strongly than + and −. Thus the above expression is taken as

a + (b * c)

with * taking b and c and then + taking a and b * c.

2. + and − bind more strongly than &&, which in turn is stronger than ||:

a && b - c || d

is taken as

(a && (b - c)) || d

3. When both operators bind equally strongly, the operations are done left to right:

a - b - c

is taken as

(a - b) - c

Parentheses may be used as above to force particular groupings.

## Syntax

    a || b  (logical OR; not audio-rate)

where the arguments a and b may be further expressions.

## Examples

Here is an example of the | operator. It uses the file logicOR.csd.

Example 31. 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 -+rtmidi=virtual -M0   ;;;realtime audio out and virtual midi keyboard
    ;-iadc    ;;;uncomment -iadc if realtime audio input is needed too
    </CsOptions>
    <CsInstruments>
    ;after a UDO from Rory Walsh
    sr = 44100
    ksmps = 32
    nchnls = 2

    instr 1	;displays notes, midi channel and control number information

    kstatus, kchan, kdata1, kdata2 midiin
    k1 changed kstatus
    k2 changed kchan
    k3 changed kdata1
    k4 changed kdata2
    if((k1==1)||(k2==1)||(k3==1)||(k4==1)) then
    printks "Value:%d ChanNo:%d CtrlNo:%d\n" , 0, kdata2, kchan, kdata1
    endif

    endin
    </CsInstruments>
    <CsScore>

    i1  0  60	;print values for 60 seconds

    e
    </CsScore>
    </CsoundSynthesizer>

Its output should include a line like these:

    Value:127 ChanNo:11 CtrlNo:62
    Value:127 ChanNo:11 CtrlNo:60
    Value:127 ChanNo:11 CtrlNo:60
    Value:127 ChanNo:11 CtrlNo:60
    Value:127 ChanNo:11 CtrlNo:60
    ....
    Value:0 ChanNo:11 CtrlNo:62
    Value:0 ChanNo:11 CtrlNo:62
    Value:0 ChanNo:11 CtrlNo:62
    Value:0 ChanNo:11 CtrlNo:62
    ....
    Value:77 ChanNo:11 CtrlNo:23
    Value:77 ChanNo:11 CtrlNo:23
    Value:76 ChanNo:11 CtrlNo:23
    Value:76 ChanNo:11 CtrlNo:23
    ....

## See also

Arithmetic and Logic Operations

Prev | Up | Next
^ | Home | !