wrap

wrap — Wraps-around the signal that exceeds the low and high thresholds.

Description

Wraps-around the signal that exceeds the low and high thresholds.

Syntax

ares wrap asig, klow, khigh
ires wrap isig, ilow, ihigh
kres wrap ksig, klow, khigh

Initialization

isig -- input signal

ilow -- low threshold

ihigh -- high threshold

Performance

xsig -- input signal

klow -- low threshold

khigh -- high threshold

wrap wraps-around the signal that exceeds the low and high thresholds.

This opcode is useful in several situations, such as table indexing or for clipping and modeling a-rate, i-rate or k-rate signals. wrap is also useful for wrap-around of table data when the maximum index is not a power of two (see table and tablei). Another use of wrap is in cyclical event repeating, with arbitrary cycle length.

Examples

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

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

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

instr    1 ; Limit / Mirror / Wrap

igain    = p4				;gain
ilevl1   = p5				; + level
ilevl2   = p6				; - level
imode    = p7				;1 = limit, 2 = mirror, 3 = wrap

ain   soundin  "fox.wav"
ain   = ain*igain

if    imode = 1 goto limit
if    imode = 2 goto mirror

asig  wrap  ain, ilevl2, ilevl1
goto  outsignal

limit:
asig  limit  ain, ilevl2, ilevl1
goto  outsignal

mirror:
asig  mirror  ain, ilevl2, ilevl1
outsignal:

outs  asig*.5, asig*.5			;mind your speakers
  
endin

</CsInstruments>
<CsScore>

;           Gain  +Levl -Levl Mode
i1  0  3    4.00  .25  -1.00   1	;limit
i1  4  3    4.00  .25  -1.00   2	;mirror
i1  8  3    4.00  .25  -1.00   3	;wrap
e
</CsScore>
</CsoundSynthesizer>


See Also

limit, mirror

Credits

Author: Gabriel Maldonado
Italy

New in Csound version 3.49