Skip to content

seqtime2

Generates a trigger signal according to the values stored in a table.

Syntax

ktrig_out seqtime2 ktrig_in, ktime_unit, kstart, kloop, kinitndx, kfn_times

Performance

ktrig_out -- output trigger signal

ktime_unit -- unit of measure of time, related to seconds.

ktrig_in -- input trigger signal.

kstart -- start index of looped section

kloop -- end index of looped section

kinitndx -- initial index

📝 Note

Although kinitndx is listed as k-rate, it is in fact accessed only at init-time. So if you are using a k-rate argument, it must be assigned with init.

kfn_times -- number of table containing a sequence of times

This opcode handles timed-sequences of groups of values stored into a table.

seqtime2 generates a trigger signal (a sequence of impulses, see also trigger opcode), according to the values stored in the kfn_times table. This table should contain a series of delta-times (i.e. times beetween to adjacent events). The time units stored into table are expressed in seconds, but can be rescaled by means of ktime_unit argument. The table can be filled with GEN02 or by means of an external text-file containing numbers, with GEN23.

It is possible to start the sequence from a value different than the first, by assigning to initndx an index different than zero (which corresponds to the first value of the table). Normally the sequence is looped, and the start and end of loop can be adjusted by modifying kstart and kloop arguments. User must be sure that values of these arguments (as well as initndx) correspond to valid table numbers, otherwise Csound will crash (because no range-checking is implementeted).

It is possible to disable loop (one-shot mode) by assigning the same value both to kstart and kloop arguments. In this case, the last read element will be the one corresponding to the value of such arguments. Table can be read backward by assigning a negative kloop value. It is possible to trigger two events almost at the same time (actually separated by a k-cycle) by giving a zero value to the corresponding delta-time. First element contained in the table should be zero, if the user intends to send a trigger impulse, it should come immediately after the orchestra instrument containing seqtime2 opcode.

seqtime2 is similar to seqtime, the difference is that when ktrig_in contains a non-zero value, current index is reset to kinitndx value. kinitndx can be varied at performance time.

Examples

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

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

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

gitabMap2 ftgen 57,0,512,-2, 1,1/4,1/4,1/8,1/8,1/8,1/8,1/4,1/4,.5,1/4,1/4,1/16,1/16,1/16,1/16,1/16,1/16,1/16,1/16
gisine    ftgen 1,0,512,10, 1

instr 1

ktrigin metro   .333333333333
ktrig2  metro   1
        schedkwhen ktrig2, 0,0, 2, 0, .1                        ; just to set the metronome!
kspeed  init    1
;                ktime_unit, kstart, kloop, initndx, kfn_times 
ktrig   seqtime2 ktrigin, kspeed, 0, 20, 2, gitabMap2
;ktrig  seqtime  kspeed, 0, 20, 0, gitabMap2                    ; try with seqtime too...               
        schedkwhen ktrig, 0, 0, 3, 0, ktrig                     ; the duration is got from seqtime2 output!
endin

instr 2

a1      line    1,p3,0
aout    oscili  0.7*a1,500,gisine
        outs1   aout
endin   


instr 3

a1      line    1,p3,0
aout    oscili  0.7*a1,1000,gisine
        outs2   aout
endin   

</CsInstruments>
<CsScore>
i1 0 20

;f0 3600
</CsScore>
</CsoundSynthesizer>

See also

Sensing and Control: Tempo and Sequencing

Credits

Author: Gabriel Maldonado