trigseq
Prev | Orchestra Opcodes and Operators | Next

## trigseq

trigseq — Accepts a trigger signal as input and outputs a group of values.

## Description

Accepts a trigger signal as input and outputs a group of values.

## Syntax

    trigseq ktrig_in, kstart, kloop, kinitndx, kfn_values, kout1 [, kout2] [...]

## Performance

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_values -- number of a table containing a sequence of groups of values

kout1 -- output values

kout2, ... (optional) -- more output values

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

trigseq accepts a trigger signal (ktrig_in) as input and outputs group of values (contained in the kfn_values table) each time ktrig_in assumes a non-zero value. Each time a group of values is triggered, table pointer is advanced of a number of positions corresponding to the number of group-elements, in order to point to the next group of values. The number of elements of groups is determined by the number of koutX arguments.

It is possible to start the sequence from a value different than the first, by assigning to kinitndx 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 kinitndx) correspond to valid table numbers, otherwise Csound will crash because no range-checking is implemented.

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.

trigseq is designed to be used together with seqtime or trigger opcodes.

## Examples

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

Example 1122. Example of the trigseq 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 RT audio input is needed too
    ; For Non-realtime ouput leave only the line below:
    ; -o trigseq.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

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

    giTimes	ftgen	91, 0, 128, -2,     1, 1/2, 1/2, 1/8, 1/8, 1/2,1/2, 1/16, 1/16, 1/16, 1/16, 1/16, 1/16, 1/16, 1/16; times
    giSeq	ftgen 	90, 0, 128, -2,     1, 2,     .5, 3,    .25, 4,      .10, 5,       .05, 6 ;** sequence amplitude and freq-ratio bins

    instr	1

    icps	init	p4
    iamp	init	.3

    kloop	init	p5
    initndx	init	p6
    kloop2	init	p7
    initndx2 init	p8
    kdur	init	p9
    iminTime init	p10
    imaxTime init	p11
    kampratio init  1
    kfreqratio init 1

    ktime_unit expseg iminTime,p3/8,iminTime,p3* 3/4,imaxTime,p3/8,imaxTime

    ;**ktrig	seqtime	ktime_unit, kstart, kloop, initndx, kfn_times
    ;ktrig	seqtime	1/ktime_unit, 0,      15, 0,      giTimes

    ktrig	metro	ktime_unit

    ;****	trigseq	ktrig_in,  kstart,  kloop, initndx,  kfn_values, kout1 [, kout2, kout3, ....,  koutN]
    	trigseq	ktrig, 	0, 	kloop2,initndx2,   giSeq,      kampratio, kfreqratio

    ;atrig	= ktrig*10000
    	schedkwhen ktrig, -1, -1, 3, 0, kdur, kampratio*iamp, kfreqratio*icps
    ;	schedkwhen ktrig, -1, -1, 2, 0, ktrig, kampratio*iamp, kfreqratio*icps
    	endin

    instr	2

    icps	init	p4
    iamp	init .2

    kloop	init	p5
    initndx	init	p6
    kloop2	init	p7
    initndx2 init	p8
    kdur	init	p9
    iminTime init	p10
    imaxTime init	p11
    kampratio init  1
    kfreqratio init 1

    ktime_unit expseg iminTime,p3/8,iminTime,p3* 3/4,imaxTime,p3/8,imaxTime

    ;**ktrig	seqtime	ktime_unit, kstart, kloop, initndx, kfn_times
    ktrig	seqtime	1/ktime_unit, 0,      15, 0,      giTimes

    ;ktrig	metro	ktime_unit

    ;****	trigseq	ktrig_in,  kstart,  kloop, initndx,  kfn_values, kout1 [, kout2, kout3, ....,  koutN]
    	trigseq	ktrig,      0, 	   kloop2, initndx2,   giSeq,    kampratio, kfreqratio
    printk2 ktrig
    ;atrig	= ktrig*10000
    ;	schedkwhen ktrig, -1, -1, 2, 0, kdur, kampratio*iamp, kfreqratio*icps
    	schedkwhen ktrig, -1, -1, 3, 0, ktrig, kampratio*iamp, kfreqratio*icps
    endin

    instr	3

    print p3
    kenv	expseg	 1.04, p3,.04
    a1	foscili	p4*a(kenv-0.04), p5,1,1,kenv*5, 2
    	outs	a1, a1
    endin

    </CsInstruments>
    <CsScore>
    f2 0 8192 10 1

    ;	icps	unused	unused	kloop2	initndx2 kdur iminTime	imaxTime

    s

    i1 0  6	100	0	0	5	0	.2	3	15
    i1 8  6	150	0	0	4	1	.1	4	30
    i1 16 6	200	0	0	5	3	.25	8	50
    i1 24 6	300	0	0	3	0	.1	1	30

    i2 32 6	100	0	0	5	0	.2	1	1
    i2 40 6 150	0	0	4	1	.1	.5	.5
    i2 48 6	200	0	0	5	3	.25	3	.5
    i2 56 6	300	0	0	5	0	.1	1	8

    e
    </CsScore>
    </CsoundSynthesizer>

## See Also

seqtime, trigger

## Credits

Author: Gabriel Maldonado

November 2002. Added a note about the kinitndx parameter, thanks to Rasmus Ekman.

January 2003. Thanks to a note from Øyvind Brandtsegg, I corrected the credits.

New in version 4.06

Prev | Up | Next
triglinseg | Home | trim