Uses a collection of arrays to generate a sequence of events with variable tempo that can be played in forward, reverse, back and forth, and random directions. The max length of the arrays is 128, and it can be scaled dynamically. Permutational playback modes feature randomisation, probability and other algorithms.
irhythm - array of durations in beats. The actual duration is determined by these values divided by the current BPM.
iinstr - array of instrument numbers scheduled per step. An instrument number zero does nothing. It skips the note associated with the step and produces a silence for that note's duration.
idata - Either a vector of p4 values to the associated iinstr step or a two dimensional array of p4, p5, p6...values. Typically, one would specify pitch information in cps, or MIDI note number; but the arbitrary list of p4 data values could have other uses in the called iinstr.
iverbose enables messages about internal state changes when nonzero. It is an initialization argument and defaults to 0.
iid is an optional sequence ID from 0 to 9, defaulting to 0. Give each active sequence its own ID when reading its counter and ordering with sequstate.
Performance
kbpm - speed of looping in beats per minute.
klen - length of the active part of the sequence (starting from step 0).
kmode - control the sequencer playback. A value of 0 (default) loops forward through the sequence, calling the associated instrument on each step. Other modes are supported. (See below).
Current playback options for kmode are:
0 - forward loop
n>0 - forward loop with a mutation every n events
-1 - backward loop
-2 - back and forth
-3 - random events
-4 - play the entire sequence forward one time and stop
-5 - play the entire sequence backward one time and stop
-6 - shuffle the events
-7 - reset to the initial state
kstep - if non zero replace the irhythm array with k-rate triggers. These could be from a MIDI keyboard or any other krate controller. An event is scheduled if this argument is positive, and just waits if it is negative. Default is zero.
kreset - if non zero resets the sequencer (like mode -7). Default is zero.
kres - gives the index of the event created for the current k-cycle, or -1 if no event happened.
Note
While the irhythm, iinstr, and idata, arrays are i-time, the values of the entries are read at k-rate when used. This means that by using global i-rate vectors, it is possible (with care) to change the specific values and other details at performance time.
Examples
Here is an example of the sequ opcode. It uses the file sequ1.csd
<CsoundSynthesizer><CsOptions> -odac
</CsOptions><CsInstruments>ksmps=320dbfs=1.0nchnls=2instr1;; rhythm array - these steps values multiplied by tempo (ticks) in BPMirhythm[]fillarray1,1.5,0.5,0.5,0.5,0.5,1.5,1;; instrument array - instrument number to render for each stepinst0[]fillarray11,12,13,14,15,16,17,18inst1[]fillarray19,20,21,22,23,24,25,26;; note array - here in cpsmidinn - esentially the 'p4' output from opcode;; can be any sequence of valuesinotes[]fillarray60,61,62,63,64,65,66,67;; variable tempokspeedline60,p3,180;; rhythm, inst, notes, bpm, length, mode, verbosekSeq0sequirhythm,inst0,inotes,kspeed,8kSeq1sequirhythm,inst1,inotes,kspeed*1.2,8endininstr11,12,13,14,15,16,17,18kllinseg0,p3*0.01,1,p3*.99,0a1oscil0.9,cpsmidinn(p4)outs1a1*klendininstr19,20,21,22,23,24,25,26kllinseg0,p3*0.01,1,p3*.99,0a1oscil0.9,cpsmidinn(p4)outs2a1*klendin</CsInstruments><CsScore>i1060e</CsScore></CsoundSynthesizer>
Here is another example of the sequ opcode showing the various modes. It uses the file sequ2.csd
<CsoundSynthesizer><CsOptions> -odac
</CsOptions><CsInstruments>ksmps=320dbfs=1.0nchnls=2instr1;; rhythm array - these values are multiplied by tempo (ticks) in BPMirhythm0[]fillarray1,1.5,0.5,0.5,0.5,0.5,1.5,1;; instrument array - instrument number to render for each stepiinsts0[]fillarray11,12,13,14,15,16,17,18;; note array - here cpsmidinn(p4), amps(p5), mod ratios(p6), mod indices(p7);; - esentially the 'p4', 'p5', 'p6' and 'p7' are output from sequinotes[][]init4,8;initialize 4 rows with 8 columns - p4=pitch, p5=amp, p6=modratio, p7=modindexinotesfillarray60,61,62,63,64,65,66,67,\
0.8,0.3,0.6,0.2,0.7,0.4,0.5,0.6,\
1,2,3,4,5,6,7,8,\
1,11,2,12,3,21,4,22;; NOTE: this can be any sequence of values;; variable tempokspeedlinseg85,p3*.7,85,p3*.3,240;; rhythms, insts, notes, bpm, length, mode, step, reset, verbosekSeqsequirhythm0,iinsts0,inotes,kspeed,8,p4endininstr11,12,13,14,15,16,17,18kenvlinseg0,p3*0.01,1,p3*.99,0asigfoscilp5,cpsmidinn(p4),1,p6,p7outallasig*kenvendin</CsInstruments><CsScore>i10150;; forward modesf01si1015-1;; backward modesf01si1015-2;; forward and backward modesf01si1015-3;; randomsf01si106-4;; play forward once and stopsf01si106-5;; play backward once and stopsf01si1015-6;; shuffle modesf01si10301;; mutate after each stepsf01si10302;; mutate each second stepsf01si10304;; mutate every four stepse</CsScore></CsoundSynthesizer>