lpshold — Generate control signal consisting of held segments.
Generate control signal consisting of held segments delimited by two or more specified points. The entire envelope is looped at kfreq rate. Each parameter can be varied at k-rate.
ksig lpshold kfreq, ktrig, iphase, ktime0, kvalue0 [, kvalue1] [, ktime1] [, kvalue2] [, ktime2] [...]
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.
iphase -- A vaue between 0 and 1 to say where to start the loop. Zero, the commonest value, indicates the beginning.
kvalue0...kvalueN -- Values of points
ktime0...ktimeN -- Times between points; expressed in fractions of a cycle (see below). The final time designates a ramp between the final value and the first value.
lpshold is similar to loopseg, but can generate only horizontal segments, i.e. holds values for each time interval placed between ktimeN and ktimeN+1. It can be useful, among other things, for melodic control, like old analog sequencers.
Here is an example of the lpshold opcode. It uses the file lpshold.csd.
Example 462. Example of the lpshold 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 lpshold.wav -W ;;; for file output any platform </CsOptions> <CsInstruments> sr = 44100 ksmps = 32 nchnls = 2 0dbfs = 1 instr 1 kfrq init p4 ; frequency of the loop ifrac = p5 ; fraction of frequency at which to force retrigger ipan = p6 ; pan position ktrig metro kfrq * ifrac ; trigger to force restart the loop iphs = 0 ; initial phase of the loop ; a loop of midi note numbers: note duration etc... knote lpshold kfrq, ktrig, iphs, 61, 0.0625, 60, 0.9375, 61, 1, 58, 1, \ 63, 2, 65, 3 aenv linseg 0,0.01,1,p3-0.11,1,0.1,0 ; amplitude envelope krnd rspline -0.05,0.05,0.5,1 ; random detune asig gbuzz 0.2*aenv, cpsmidinn(knote+krnd), 30, 1, 0.5, 1 outs asig*ipan, asig*(1-ipan) endin </CsInstruments> <CsScore> ; cosine wave. f 1 0 16384 11 1 ; 3 layers of the loop are played, each at a different speed, ; - with different retriggering rate, and pan location. i 1 0 60 0.5 [8/10] 0.5 i 1 0 60 0.375 [8/11] 0.1 i 1 0 60 0.25 [8/13] 0.9 e </CsScore> </CsoundSynthesizer>