| 1 | <refentry id="sequ"> |
| 2 | <indexterm id="IndexSequ"><primary>sequ</primary></indexterm> |
| 3 | <refentryinfo><title>Instrument Control:Sensing and Control</title></refentryinfo> |
| 4 | <refmeta> |
| 5 | <refentrytitle>sequ</refentrytitle> |
| 6 | </refmeta> |
| 7 | |
| 8 | <refnamediv> |
| 9 | <refname>sequ</refname> |
| 10 | <refpurpose> |
| 11 | Emulate a hardware sequencer |
| 12 | </refpurpose> |
| 13 | </refnamediv> |
| 14 | |
| 15 | <refsect1> |
| 16 | <title>Description</title> |
| 17 | <para> |
| 18 | Uses a collection of arrays to generate a sequence of events |
| 19 | with variable tempo that can be played in forward, reverse, back |
| 20 | and forth, and random directions. The max length of the arrays |
| 21 | is 128, and it can be scaled dynamically. Permutational playback |
| 22 | modes feature randomisation, probability and other algorithms. |
| 23 | </para> |
| 24 | </refsect1> |
| 25 | <refsect1> |
| 26 | <title>Syntax</title> |
| 27 | <synopsis>kres <command>sequ</command> irhythm[], iinstr[], idata[], kbpm, klen [, kmode] [, kstep] [, kreset] [, kverbose] |
| 28 | </synopsis> |
| 29 | <synopsis>kres <command>sequ</command> irhythm[], iinstr[], |
| 30 | idata[][], kbpm, klen [, kmode] [, kstep] [, kreset] [, kverbose] |
| 31 | </synopsis> |
| 32 | </refsect1> |
| 33 | |
| 34 | <refsect1> |
| 35 | <title>Initialization</title> |
| 36 | <para> |
| 37 | <emphasis>irhythm</emphasis> - array of durations in |
| 38 | beats. The actual duration is determined by these values divided |
| 39 | by the current BPM. |
| 40 | </para> |
| 41 | <para> |
| 42 | <emphasis>iinstr</emphasis> - array of instrument numbers scheduled |
| 43 | per step. An instrument number zero does nothing. It skips the note |
| 44 | associated with the step and produces a silence for that note's duration. |
| 45 | </para> |
| 46 | <para> |
| 47 | <emphasis>idata</emphasis> - Either a vector of p4 values to the |
| 48 | associated iinstr step or a two dimensional array of p4, p5, |
| 49 | p6...values. Typically, one would specify pitch |
| 50 | information in cps, or MIDI note number; but the arbitrary list |
| 51 | of p4 data values could have other uses in the called iinstr. |
| 52 | </para> |
| 53 | </refsect1> |
| 54 | |
| 55 | <refsect1> |
| 56 | <title>Performance</title> |
| 57 | <para> |
| 58 | <emphasis>kbpm</emphasis> - speed of looping in beats per minute. |
| 59 | </para> |
| 60 | <para> |
| 61 | <emphasis>klen</emphasis> - length of the active part of the |
| 62 | sequence (starting from step 0). |
| 63 | </para> |
| 64 | <para> |
| 65 | <emphasis>kmode</emphasis> - control the sequencer playback. A value |
| 66 | of 0 (default) loops forward through the sequence, calling the |
| 67 | associated instrument on each step. Other modes are |
| 68 | supported. (See below). |
| 69 | </para> |
| 70 | <para> |
| 71 | Current playback options for <emphasis>kmode</emphasis> are: |
| 72 | |
| 73 | <itemizedlist> |
| 74 | <listitem><para>0 - forward loop</para></listitem> |
| 75 | <listitem><para>n>0 - forward loop with a mutation every n |
| 76 | events</para></listitem> |
| 77 | <listitem><para>-1 - backward loop</para></listitem> |
| 78 | <listitem><para>-2 - back and forth</para></listitem> |
| 79 | <listitem><para>-3 - random events</para></listitem> |
| 80 | <listitem><para>-4 - play the entire sequence forward one time |
| 81 | and stop</para></listitem> |
| 82 | <listitem><para>-5 - play the entire sequence backward one time |
| 83 | and stop</para></listitem> |
| 84 | <listitem><para>-6 - shuffle the events</para></listitem> |
| 85 | <listitem><para>-7 - reset to the initial state</para></listitem> |
| 86 | </itemizedlist> |
| 87 | </para> |
| 88 | <para> |
| 89 | <emphasis>kstep</emphasis> - if non zero replace the irhythm |
| 90 | array with k-rate triggers. These could be from a MIDI keyboard |
| 91 | or any other krate controller. An event is scheduled if this |
| 92 | argument is positive, and just waits if it is negative. Default |
| 93 | is zero. |
| 94 | </para> |
| 95 | <para> |
| 96 | <emphasis>kreset</emphasis> - if non zero resets the sequencer (like |
| 97 | mode -7). Default is zero. |
| 98 | </para> |
| 99 | <para> |
| 100 | <emphasis>kverbose</emphasis> - if non zero prints messages |
| 101 | about the internal state changes. Default is zero. |
| 102 | </para> |
| 103 | <para> |
| 104 | <emphasis>kres</emphasis> - gives the index of the event created |
| 105 | for the current k-cycle, or -1 if no event happened. |
| 106 | </para> |
| 107 | |
| 108 | <note> |
| 109 | <para> |
| 110 | While the irhythm, iinstr, and idata, arrays are i-time, the |
| 111 | values of the entries are read at k-rate when used. This |
| 112 | means that by using global i-rate vectors, it is possible |
| 113 | (with care) to change the specific values and other details at |
| 114 | performance time. |
| 115 | </para> |
| 116 | </note> |
| 117 | </refsect1> |
| 118 | |
| 119 | <refsect1> |
| 120 | <title>Examples</title> |
| 121 | <para> |
| 122 | Here is an example of the sequ opcode. It uses the file <ulink url="examples/sequ1.csd"><citetitle>sequ1.csd</citetitle></ulink> |
| 123 | <example> |
| 124 | <title>Example of the sequ opcode.</title> |
| 125 | <xi:include href="examples-xml/sequ1.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 126 | </example> |
| 127 | Here is another example of the sequ opcode showing the various |
| 128 | modes. It uses the file <ulink |
| 129 | url="examples/sequ2.csd"><citetitle>sequ2.csd</citetitle></ulink> |
| 130 | <example> |
| 131 | <title>Example of the sequ opcode.</title> |
| 132 | <xi:include href="examples-xml/sequ2.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 133 | </example> |
| 134 | </para> |
| 135 | </refsect1> |
| 136 | |
| 137 | <refsect1> |
| 138 | <title>See also</title> |
| 139 | <para><link linkend="ControlSensing"><citetitle>Sensing and Control: Tempo and Sequencing</citetitle></link></para> |
| 140 | </refsect1> |
| 141 | |
| 142 | <refsect1> |
| 143 | <title>Credits</title> |
| 144 | <para>Written by &namejohn;</para> |
| 145 | <para>New in Csound 6.17</para> |
| 146 | </refsect1> |
| 147 | </refentry> |