looptseg

looptseg — Generate control signal consisting of exponential or linear segments delimited by two or more specified points.

Description

Generate control signal consisting of controllable exponential segments or linear segments delimited by two or more specified points. The entire envelope is looped at kfreq rate. Each parameter can be varied at k-rate.

Syntax

ksig looptseg kfreq, ktrig, ktime0, kvalue0, ktype0, [, ktime1] [, kvalue1] [,ktype1] \
      [, ktime2] [, kvalue2] [,ktype2] [...][, ktimeN] [, kvalueN]

Performance

ksig -- Output signal.

kfreq -- Repeat rate in Hz or fraction of Hz.

ktrig -- If non-zero, retriggers the envelope from start (see trigger opcode), before the envelope cycle is completed.

ktime0...ktimeN -- Times of points; expressed in fraction of a cycle.

kvalue0...kvalueN -- Values of points

ktype0...ktypeN -- shape of the envelope. If the value is 0 then the shap eis linear; otherwise it is an concave exponential (positive type) or a convex exponential (negative type).

looptseg opcode is similar to transeg, but the entire envelope is looped at kfreq rate. Notice that times are not expressed in seconds but in fraction of a cycle. Actually each duration represent is proportional to the other, and the entire cycle duration is proportional to the sum of all duration values.

The sum of all duration is then rescaled according to kfreq argument. For example, considering an envelope made up of 3 segments, each segment having 100 as duration value, their sum will be 300. This value represents the total duration of the envelope, and is actually divided into 3 equal parts, a part for each segment.

Actually, the real envelope duration in seconds is determined by kfreq. Again, if the envelope is made up of 3 segments, but this time the first and last segments have a duration of 50, whereas the central segment has a duration of 100 again, their sum will be 200. This time 200 represent the total duration of the 3 segments, so the central segment will be twice as long as the other segments.

All parameters can be varied at k-rate. Negative frequency values are allowed, reading the envelope backward. ktime0 should always be set to 0, except if the user wants some special effect.

Examples

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

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

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

instr 1

kfreq linseg 10, p3*.5, 1, p3*.5, 5	; vary speed
ktyp linseg 100, p3*.5, -5, p3*.5, -20	; change form of segment
;klp looptseg kfreq,ktrig,ktime0,kvalue0,ktype0,ktime1,kvalue1,ktype1,ktime2,kvalue2,ktype2,ktime3,kvalue3
 klp looptseg kfreq,  0,    0,     0,     ktyp,   .6,     .9,     -10,    .8,     .4,    1,     .1,     0 

asig poscil3 klp, 440, 1
     outs asig, asig

endin
</CsInstruments>
<CsScore>
; sine wave.
f 1 0 16384 10 1

i 1 0 12

e
</CsScore>
</CsoundSynthesizer>


See Also

lpshold loopseg

Credits

Author: John ffitch

New in Version 5.12