ntrpol

ntrpol — Calculates the weighted mean value of two input signals.

Description

Calculates the weighted mean value (i.e. linear interpolation) of two input signals

Syntax

ares ntrpol asig1, asig2, kpoint [, imin] [, imax]
ires ntrpol isig1, isig2, ipoint [, imin] [, imax]
kres ntrpol ksig1, ksig2, kpoint [, imin] [, imax]

Initialization

imin -- minimum xpoint value (optional, default 0)

imax -- maximum xpoint value (optional, default 1)

Performance

xsig1, xsig2 -- input signals

xpoint -- interpolation point between the two values

ntrpol opcode outputs the linear interpolation between two input values. xpoint is the distance of evaluation point from the first value. With the default values of imin and imax, (0 and 1) a zero value indicates no distance from the first value and the maximum distance from the second one. With a 0.5 value, ntrpol will output the mean value of the two inputs, indicating the exact half point between xsig1 and xsig2. A 1 value indicates the maximum distance from the first value and no distance from the second one. The range of xpoint can be also defined with imin and imax to make its management easier.

These opcodes are useful for crossfading two signals.

Examples

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

Example 533. Example of the ntrpol 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 real audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o ntrpol.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

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

giSin ftgen 1, 0, 1024, 10, 1

instr 1

avco vco2   .5, 110			;sawtootyh wave
asin poscil .5, 220, giSin		;sine wave but octave higher
kx   linseg 0, p3*.4, 1, p3*.6, 1	;crossfade between saw and sine
asig ntrpol avco, asin, kx
     outs   asig, asig

endin
</CsInstruments>
<CsScore>

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


Credits

Author: Gabriel Maldonado
Italy
October 1998

New in Csound version 3.49