loopsegp

loopsegp — Control signals based on linear segments.

Description

Generate control signal consisiting of linear segments delimited by two or more specified points. The entire envelope can be looped at time-variant rate. Each segment coordinate can also be varied at k-rate.

Syntax

ksig loopsegp  kphase, kvalue0, kdur0, kvalue1 \
      [, kdur1, ... , kdurN-1, kvalueN]

Performance

ksig - output signal

kphase - point of the sequence read, expressed as a fraction of a cycle (0 to 1)

kvalue0 ...kvalueN - values of points

kdur0 ...kdurN-1 - duration of points expessed in fraction of a cycle

loopsegp opcode is similar to loopseg; the only difference is that, instead of frequency, a time-variant phase is required. If you use phasor to get the phase value, you will have a behaviour identical to loopseg, but interesting results can be achieved when using phases having non-linear motions, making loopsegp more powerful and general than loopseg.

Examples

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

Example 438. Example of the loopsegp opcode.

<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 loopsegp.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

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

instr 1
ktrig metro 22/8 ; triggers used to generate new direction values
kdir  trandom ktrig,-2.99,2.99
kdir  =       0.5*int(kdir) ; kdir will either -1, -0.5, 0, 0.5 or 1
; kphase - looping pointer
kphase phasor kdir
; a loop sequence of midi note numbers and durations
knote loopsegp  kphase, 40,1,40,0, 43,1,43,0, 49,2,48,0, \
 47,1,47,0, 46,1,46,0, 46,1,47,0, 49,1,49,0, 43,1,43,0, 46,1,46,0, 40,1,39,0    
kmul  rspline 0.1,0.8,0.5,5                         ; modulation of buzz tone
asig  gbuzz   0.2, cpsmidinn(knote), 30, 3, kmul, 1 ; buzz tone
      outs    asig, asig
      
      schedkwhen ktrig,0,0,2,0,0.1 ; play metronome
endin

instr 2 ; metronome
acps  expon   180+rnd(40),p3,50
aamp  expon   0.05+rnd(0.05),p3,0.001
asig  poscil  aamp-0.001,acps,2
      outs    asig,asig
endin

</CsInstruments>
<CsScore>
; cosine wave.
f 1 0 16384 11 1
; sine wave.
f 2 0 16384 10 1

i 1 0 360 0.25

e
</CsScore>
</CsoundSynthesizer>


Credits

Written by Gabriel Maldonado.

New in Csound 5. (Previously available only on CsoundAV)