<

< — Determines if one value is less than another.

Description

Determines if one value is less than 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 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 lessthan.csd.

Example 24. 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

ipch = p4
ipitch	= (ipch < 15 ? cpspch(ipch) : ipch)	;if p4 is lower then 15, it assumes p4 to be pitch-class
print ipitch					;and not meant to be a frequency in Hertz
asig  poscil .5,  ipitch , 1
      outs asig, asig
  
endin
</CsInstruments>
<CsScore>
f1 0 8192 10 1	;sine wave

i1 0  3 8.00	;pitch class
i1 4  3 800	;frequency

e
</CsScore>
</CsoundSynthesizer>


Its output should include lines like this:

ipitch = 261.626
ipitch = 800.00

See Also

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