| 1 | |
| 2 | <refentry id="partikkel"> |
| 3 | <indexterm id="IndexPartikkel"><primary>partikkel</primary></indexterm> |
| 4 | <refentryinfo><title>Signal Generators:Granular Synthesis</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>partikkel</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | <refnamediv> |
| 10 | <refname>partikkel</refname> |
| 11 | <refpurpose> |
| 12 | Granular synthesizer with "per grain" control |
| 13 | over many of its parameters. Has a sync input to |
| 14 | sychronize its internal grain scheduler clock to an external |
| 15 | clock source. |
| 16 | </refpurpose> |
| 17 | </refnamediv> |
| 18 | |
| 19 | <refsect1> |
| 20 | <title>Description</title> |
| 21 | <para> |
| 22 | <emphasis>partikkel</emphasis> was conceived after reading Curtis Roads' book |
| 23 | "Microsound", and the goal was to create an opcode that was |
| 24 | capable of all time-domain varieties of granular synthesis |
| 25 | described in this book. The idea being that most of the |
| 26 | techniques only differ in parameter values, and by having a |
| 27 | single opcode that can do all varieties of granular synthesis |
| 28 | makes it possible to interpolate between techniques. Granular synthesis is sometimes dubbed particle |
| 29 | synthesis, and it was thought apt to name the opcode <emphasis>partikkel</emphasis> |
| 30 | to distinguish it from other granular opcodes. |
| 31 | </para> |
| 32 | <para> |
| 33 | Some of the input parameters to <emphasis>partikkel</emphasis> is table numbers, |
| 34 | pointing to tables where values for the "per grain" parameter |
| 35 | changes are stored. <emphasis>partikkel</emphasis> can use single-cycle or complex |
| 36 | (e.g. sampled sound) waveforms as source waveforms for |
| 37 | grains. Each grain consists of a mix of 4 source |
| 38 | waveforms. Individual tuning of the base frequency can be done |
| 39 | for each of the 4 source waveforms. Frequency modulation inside |
| 40 | each grain is enabled via an auxillary audio input |
| 41 | (<emphasis>awavfm</emphasis>). Trainlet synthesis is available, and trainlets can be |
| 42 | mixed with wavetable based grains. Up to 8 separate audio |
| 43 | outputs can be used. Fractional output values will distribute a grain between two outputs |
| 44 | and a "panning law" table can be devised to control the amplitude scaling between output pairs. |
| 45 | </para> |
| 46 | </refsect1> |
| 47 | |
| 48 | <refsect1> |
| 49 | <title>Syntax</title> |
| 50 | <synopsis>a1 [, a2, a3, a4, a5, a6, a7, a8] <command>partikkel</command> agrainfreq, \ |
| 51 | kdistribution, idisttab, async, kenv2amt, ienv2tab, ienv_attack, \ |
| 52 | ienv_decay, ksustain_amount, ka_d_ratio, kduration, kamp, igainmasks, \ |
| 53 | kwavfreq, ksweepshape, iwavfreqstarttab, iwavfreqendtab, awavfm, \ |
| 54 | ifmamptab, kfmenv, icosine, ktraincps, knumpartials, kchroma, \ |
| 55 | ichannelmasks, krandommask, kwaveform1, kwaveform2, kwaveform3, \ |
| 56 | kwaveform4, iwaveamptab, asamplepos1, asamplepos2, asamplepos3, \ |
| 57 | asamplepos4, kwavekey1, kwavekey2, kwavekey3, kwavekey4, imax_grains \ |
| 58 | [, iopcode_id, ipanlaws]</synopsis> |
| 59 | </refsect1> |
| 60 | |
| 61 | <refsect1> |
| 62 | <title>Initialization</title> |
| 63 | <para> |
| 64 | <emphasis>idisttab</emphasis> -- function table number, |
| 65 | distribution for random grain displacements over time. The table |
| 66 | values are interpreted as "displacement amount" scaled by |
| 67 | 1/grainrate. This means that a value of 0.5 in the table will |
| 68 | displace a grain by half the grainrate period. The table values |
| 69 | are read randomly, and scaled by <emphasis>kdistribution</emphasis>. For realistic |
| 70 | stochastic results, it is advisable not to use a too small table |
| 71 | size, as this limits the amount of possible displacement |
| 72 | values. This can also be utilized for other purposes, e.g. using |
| 73 | quantized displacement values to work with controlled time |
| 74 | displacement from the periodic grain rate. If <emphasis>kdistribution</emphasis> is |
| 75 | negative, the table values will be read sequentially. A default |
| 76 | table might be selected by using -1 as the ftable number, for |
| 77 | <emphasis>idisttab</emphasis> the default uses a zero distribution (no |
| 78 | displacement). |
| 79 | </para> |
| 80 | <para> |
| 81 | <emphasis>ienv_attack</emphasis> -- function table number, |
| 82 | attack shape of grain. Needs extended guard point. A default |
| 83 | table might be selected by using -1 as the ftable number, for |
| 84 | <emphasis>ienv_attack</emphasis> the default uses a square window (no enveloping). |
| 85 | </para> |
| 86 | <para> |
| 87 | <emphasis>ienv_decay</emphasis> -- function table number, decay |
| 88 | shape of grain. Needs extended guard point. A default table |
| 89 | might be selected by using -1 as the ftable number, for |
| 90 | <emphasis>ienv_decay</emphasis> the default uses a square window (no enveloping). |
| 91 | </para> |
| 92 | <para> |
| 93 | <emphasis>ienv2tab</emphasis> -- function table number, |
| 94 | additional envelope applied to grain, done after attack and |
| 95 | decay envelopes. Can be used e.g. for fof formant |
| 96 | synthesis. Needs extended guard point. A default table might be |
| 97 | selected by using -1 as the ftable number, for <emphasis>ienv2tab</emphasis> the |
| 98 | default uses a square window (no enveloping). |
| 99 | </para> |
| 100 | <para> |
| 101 | <emphasis>icosine</emphasis> -- function table number, must |
| 102 | contain a cosine, used for trainlets. Table size should be at least 2048 for good quality trainlets. |
| 103 | </para> |
| 104 | <para> |
| 105 | <emphasis>igainmasks</emphasis> -- function table number, gain per |
| 106 | grain. The sequence of values in the table is as follows: index |
| 107 | 0 is used as a loop start point in reading the values, index 1 |
| 108 | is used as a loop end point. Remaining indices contain gain |
| 109 | values (normally in range 0 - 1, but other values are |
| 110 | allowed, negative values will invert phase of waveform inside |
| 111 | grain) for a sequence of grains, these are read at grain rate |
| 112 | enabling exact patterns of "gain per grain". The loop start and |
| 113 | end points are zero based with an origin at index 2, e.g. a loop |
| 114 | start value of 0 and loop end value of 3 will read indices |
| 115 | 2,3,4,5 in a loop at grain rate. A default table might be |
| 116 | selected by using -1 as the ftable number, for <emphasis>igainmasks</emphasis> the |
| 117 | default disables gain masking (all grains are given a gain |
| 118 | masking value of 1). |
| 119 | </para> |
| 120 | <para> |
| 121 | <emphasis>ichannelmasks</emphasis> -- function table number, see <emphasis>igainmasks</emphasis> |
| 122 | for a description of how the values in the table are read. Range |
| 123 | is 0 to N, where N is the number of output channels. A |
| 124 | value of zero will send the grain to audio output 1 from the |
| 125 | opcode. Fractional values are allowed, e.g. a value of 3.5 will |
| 126 | mix the grain equally to outputs 4 and 5. The channelmask value wraps |
| 127 | around from the last to the first output, so that a vaalue of N-0.5 will |
| 128 | mix the grain equally between the last and the first output. If another panning law |
| 129 | between outputs is desired, this can be described in the <emphasis>ipanlaws</emphasis> |
| 130 | table. The user is responsible for keeping the values in range, |
| 131 | the opcode will crash with out of range values. A |
| 132 | default table might be selected by using -1 as the ftable |
| 133 | number, for <emphasis>ichannelmasks</emphasis> the default disables channel masking |
| 134 | (all grains are given a channel masking value of 0 and are sent |
| 135 | to <emphasis>partikkel</emphasis> audio out 1). |
| 136 | </para> |
| 137 | <para> |
| 138 | <emphasis>iwavfreqstarttab</emphasis> -- function table number, |
| 139 | see <emphasis>igainmasks</emphasis> for a description of how the values in the table |
| 140 | are read. Start frequency multiplicator for each grain. Pitch |
| 141 | will glide from start frequency to end frequency following a |
| 142 | line or curve as set by <emphasis>ksweepshape</emphasis>. A default table might be |
| 143 | selected by using -1 as the ftable number, for <emphasis>iwavfreqstarttab</emphasis> |
| 144 | the default uses a multiplicator of 1, disabling any start |
| 145 | frequency modification. |
| 146 | </para> |
| 147 | <para> |
| 148 | <emphasis>iwavfreqendtab</emphasis> -- function table number, |
| 149 | see <emphasis>iwavfreqstarttab</emphasis>. End frequency multiplicator for each |
| 150 | grain. A default table might be selected by using -1 as the |
| 151 | ftable number, for <emphasis>iwavfreqendtab</emphasis> the default uses a |
| 152 | multiplicator of 1, disabling any end frequency modification. |
| 153 | </para> |
| 154 | <para> |
| 155 | <emphasis>ifmamptab</emphasis> -- function table number, |
| 156 | see <emphasis>igainmasks</emphasis> for a description of how |
| 157 | the values in the table are read. Frequency modulation index per |
| 158 | grain. The signal <emphasis>awavfm</emphasis> will be multiplied by values read from |
| 159 | this table. A default table might be selected by using -1 as the |
| 160 | ftable number, for <emphasis>ifmamptab</emphasis> the default uses 1 as the index |
| 161 | multiplicator, enabling fm for all grains. |
| 162 | </para> |
| 163 | <para> |
| 164 | <emphasis>iwaveamptab</emphasis> -- function table number, the |
| 165 | indices are read in a similar way to what is used for |
| 166 | <emphasis>igainmasks</emphasis>. Index 0 is used as a loop start point, and index 1 |
| 167 | is used as a loop end point. The rest of the indices are read in |
| 168 | groups of 5, where each value represent a gain value for each of |
| 169 | the 4 source waveforms, and the 5th value represent trainlet |
| 170 | amplitude. A default table might be selected by |
| 171 | using -1 as the ftable number, for <emphasis>iwaveamptab</emphasis> the default uses |
| 172 | an equal mix of all 4 source waveforms (each with an amplitude of 0.5) and setting trainlet amp |
| 173 | to zero. |
| 174 | </para> |
| 175 | <para> |
| 176 | Computation of trainlets can be CPU intensive, and setting |
| 177 | <emphasis>ktrainamp</emphasis> to zero will skip most of the trainlet |
| 178 | computations. Trainlets will be normalized to peak (<emphasis>ktrainamp</emphasis>), |
| 179 | compensating for amplitude variations caused by variations in |
| 180 | <emphasis>kpartials</emphasis> and <emphasis>kchroma</emphasis>. |
| 181 | </para> |
| 182 | <para> |
| 183 | <emphasis>imax_grains</emphasis> -- maximum number of grains per k-period. Estimating a large value should not affect performance, exceeding this value will lead to "oldest grains" being deleted. |
| 184 | </para> |
| 185 | <para> |
| 186 | <emphasis>iopcode_id</emphasis> -- the opcode id, linking an |
| 187 | instance of <emphasis>partikkel</emphasis> to an instance of <link linkend="partikkelsync"><citetitle>partikkelsync</citetitle></link>, the linked <emphasis>partikkelsync</emphasis> will output trigger pulses synchronized to <emphasis>partikkel</emphasis>'s grain maker scheduler. |
| 188 | The default value is zero, which means no connection to any <emphasis>partikkelsync</emphasis> instances. |
| 189 | </para> |
| 190 | <para> |
| 191 | <emphasis>ipanlaws</emphasis> -- function table number. The table describes the panning curve used for fractional channelmask values. |
| 192 | Fractional channelmask values will mix a grain to two neighbouring outputs, with the relative gain set by the fractional value. |
| 193 | By default (if no <emphasis>ipanlaws</emphasis> table is described, a linear gain relationship is used, so that a channelmask value of e.g. 1.5 distributes |
| 194 | the grain with 0.5 gain to output 2 and 0.5 gain to output 3. The <emphasis>ipanlaws</emphasis> table can be used to describe other gain control curves (panning laws). |
| 195 | The table should contain 8 such gain control curves, each governing the panning between two neighbouring outputs. |
| 196 | The curves should appear one after another in the table, in a concatenated fashion. GEN 18 can be used to create this table from separate panning curve tables (see example below). |
| 197 | The first curve describes the panning law between output 1 and output 2, the next is for panning between outputs 2 and 3, and so on. |
| 198 | The last curve describes the panning law between the last and the first output. The table is indexed by the channelmask value such that one output |
| 199 | (of an output pair goverened by the panning law) uses the index (tablesize/8*channelmask) while the other of the two outputs reads the value at index |
| 200 | (tablesize/8*(int(channelmask+1)-frac(channelmask))). This means that if the panning law value halfway between these two channel masks is e.g. 0.7 |
| 201 | (which would give approximately equal power panning), then each of those two outputs will use 0.7 as the gain value. |
| 202 | </para> |
| 203 | </refsect1> |
| 204 | |
| 205 | <refsect1> |
| 206 | <title>Performance</title> |
| 207 | <para> |
| 208 | <emphasis>xgrainfreq</emphasis> -- number of grains per |
| 209 | second. A value of zero is allowed, and this will defer all |
| 210 | grain scheduling to the sync input. |
| 211 | </para> |
| 212 | <para> |
| 213 | <emphasis>async</emphasis> -- sync input. Input values are added to the |
| 214 | phase value of the internal grain maker clock, enabling tempo synchronization |
| 215 | with an external clock source. As this is an a-rate signal, inputs are usually pulses |
| 216 | of length 1/<emphasis>sr</emphasis>. Using such pulses, the internal phase value can be "nudged" up or down, |
| 217 | enabling soft or hard synchronization. Negative input values decrements the internal phase, |
| 218 | while positive values in the range 0 to 1 increments the internal phase. An input value of 1 |
| 219 | will always make <emphasis>partikkel</emphasis> generate a grain. |
| 220 | If the value remains at 1, the internal grain scheduler clock will pause but any currently |
| 221 | playing grains will still play to end. |
| 222 | </para> |
| 223 | <para> |
| 224 | <emphasis>kdistribution</emphasis> -- periodic or stochastic |
| 225 | distribution of grains, 0 = periodic. Stochastic grain displacement is in the range of <emphasis>kdistribution/grainrate</emphasis> seconds. |
| 226 | The stochastic distribution profile (random distribution) can be set in the <emphasis>idisttab</emphasis> table. |
| 227 | If <emphasis>kdistribution</emphasis> is negative, the result is deterministic time displacement as described by <emphasis>idisttab</emphasis> (sequential read of displacement values). |
| 228 | Maximum grain displacement in all cases is limited to 10 seconds, |
| 229 | and a grain will keep the values (duration, pitch etc) it was given when it was first generated (before time displacement). |
| 230 | Since grain displacement is relative to the grain rate, displacement amount is undefined at 0Hz grain rate and kdistribution is completely disabled in this case. |
| 231 | </para> |
| 232 | <para> |
| 233 | <emphasis>kenv2amt</emphasis> -- amount of enveloping for the |
| 234 | secondary envelope for each grain. Range 0 to 1, where 0 is no |
| 235 | secondary enveloping (square window), a value of 0.5 will use an |
| 236 | interpolation between a square window and the shape set by |
| 237 | <emphasis>ienv2tab</emphasis>. |
| 238 | </para> |
| 239 | <para> |
| 240 | <emphasis>ksustain_amount</emphasis> -- sustain time as fraction |
| 241 | of grain duration. I.e. balance between enveloped |
| 242 | time(attack+decay) and sustain level time. The sustain level is |
| 243 | taken from the last value of the <emphasis>ienv_attack</emphasis> ftable. |
| 244 | </para> |
| 245 | <para> |
| 246 | <emphasis>ka_d_ratio</emphasis> -- balance between attack time |
| 247 | and decay time. For example, with <emphasis>ksustain_amount</emphasis> set to 0.5 and |
| 248 | <emphasis>ka_d_ratio</emphasis> set to 0.5, the attack envelope of each grain will take 25% of |
| 249 | the grain duration, full amplitude (sustain) will be held for |
| 250 | 50% of the grain duration, and the decay envelope will take the |
| 251 | remaining 25% of the grain duration. |
| 252 | </para> |
| 253 | <para> |
| 254 | <emphasis>kduration</emphasis> -- grain duration in milliseconds. |
| 255 | </para> |
| 256 | <para> |
| 257 | <emphasis>kamp</emphasis> -- amplitude scaling of the opcode's |
| 258 | output. Multiplied by per grain amplitude read from <emphasis>igainmasks</emphasis>. |
| 259 | Source waveform playback inside grains can consume a significant amount of CPU cycles, |
| 260 | especially if grain duration is long so that we have a lot of overlapping grains. |
| 261 | Setting kamp to zero will skip waveform playback inside grains (and not generate any sound, obviously). |
| 262 | This can be used as a "soft" bypass method if we want to keep the opcode active but silent for some periods of time. |
| 263 | </para> |
| 264 | <para> |
| 265 | <emphasis>kwavfreq</emphasis> -- transposition |
| 266 | scaling. Multiplied with start and end transposition values read |
| 267 | from <emphasis>iwavfreqstarttab</emphasis> and <emphasis>iwavfreqendtab</emphasis>. |
| 268 | </para> |
| 269 | <para> |
| 270 | <emphasis>ksweepshape</emphasis> -- transposition sweep shape, |
| 271 | controls the curvature of the transposition sweep. Range 0 |
| 272 | to 1. Low values will hold the transposition at the start value |
| 273 | longer and then drop to the end value quickly, high values will |
| 274 | drop to the end value quickly. A value of 0.5 will give a |
| 275 | linear sweep. A value of exactly 0 will bypass sweep and only |
| 276 | use the start frequency, while a value of exactly 1 will bypass sweep |
| 277 | and only use the end frequency. The sweep generator might be slightly |
| 278 | inaccurate in hitting the end frequency when using a steep curve and very long grains. |
| 279 | </para> |
| 280 | <para> |
| 281 | <emphasis>awavfm</emphasis> -- audio input for frequency |
| 282 | modulation inside grain. |
| 283 | </para> |
| 284 | <para> |
| 285 | <emphasis>kfmenv</emphasis> -- function table number, envelope |
| 286 | for FM modulator signal enabling the modulation index to change |
| 287 | over the duration of a grain. |
| 288 | </para> |
| 289 | <para> |
| 290 | <emphasis>ktraincps</emphasis> -- trainlet fundamental frequency. |
| 291 | </para> |
| 292 | <para> |
| 293 | <emphasis>knumpartials</emphasis> -- number of partials in trainlets. |
| 294 | </para> |
| 295 | <para> |
| 296 | <emphasis>kchroma</emphasis> -- chroma of trainlets. A value of |
| 297 | 1 give equal amplitude to each partial, higher values will |
| 298 | reduce the amplitude of lower partials while strengthening the |
| 299 | amplitude of the higher partials. |
| 300 | </para> |
| 301 | <para> |
| 302 | <emphasis>krandommask</emphasis> -- random masking (muting) of |
| 303 | individual grains. Range 0 to 1, where a value of 0 will give no |
| 304 | masking (all grains are played), and a value of 1 will mute all |
| 305 | grains. |
| 306 | </para> |
| 307 | <para> |
| 308 | <emphasis>kwaveform1</emphasis> -- table number for source waveform 1. |
| 309 | </para> |
| 310 | <para> |
| 311 | <emphasis>kwaveform2</emphasis> -- table number for source waveform 2. |
| 312 | </para> |
| 313 | <para> |
| 314 | <emphasis>kwaveform3</emphasis> -- table number for source waveform 3. |
| 315 | </para> |
| 316 | <para> |
| 317 | <emphasis>kwaveform4</emphasis> -- table number for source waveform 4. |
| 318 | </para> |
| 319 | <para> |
| 320 | <emphasis>asamplepos1</emphasis> -- start position for reading |
| 321 | source waveform 1 (in range 0..1). |
| 322 | </para> |
| 323 | <para> |
| 324 | <emphasis>asamplepos2</emphasis> -- start position for reading |
| 325 | source waveform 2. |
| 326 | </para> |
| 327 | <para> |
| 328 | <emphasis>asamplepos3</emphasis> -- start position for reading |
| 329 | source waveform 3. |
| 330 | </para> |
| 331 | <para> |
| 332 | <emphasis>asamplepos4</emphasis> -- start position for reading |
| 333 | source waveform 4. |
| 334 | </para> |
| 335 | <para> |
| 336 | <emphasis>kwavekey1</emphasis> -- original key of source |
| 337 | waveform 1. Can be used to transpose each source waveform |
| 338 | independently. |
| 339 | </para> |
| 340 | <para> |
| 341 | <emphasis>kwavekey2</emphasis> -- as <emphasis>kwavekey1</emphasis>, but for source |
| 342 | waveform 2. |
| 343 | </para> |
| 344 | <para> |
| 345 | <emphasis>kwavekey3</emphasis> -- as <emphasis>kwavekey1</emphasis>, but for source |
| 346 | waveform 3. |
| 347 | </para> |
| 348 | <para> |
| 349 | <emphasis>kwavekey4</emphasis> -- as <emphasis>kwavekey1</emphasis>, but for source waveform 4. |
| 350 | </para> |
| 351 | </refsect1> |
| 352 | |
| 353 | <refsect1> |
| 354 | <title>Examples</title> |
| 355 | |
| 356 | <para> |
| 357 | Here is an example of the partikkel opcode. It uses the file <ulink url="examples/partikkel.csd"><citetitle>partikkel.csd</citetitle></ulink>. |
| 358 | <example> |
| 359 | <title>Example of the partikkel opcode.</title> |
| 360 | <para>See the sections <link linkend="UsingRealTime"><citetitle>Real-time Audio</citetitle></link> and <link linkend="CommandFlags"><citetitle>Command Line Flags</citetitle></link> for more information on using command line flags.</para> |
| 361 | <xi:include href="examples-xml/partikkel.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 362 | </example> |
| 363 | </para> |
| 364 | <para> |
| 365 | Here is another example of the partikkel opcode. It uses the file <ulink url="examples/partikkel-2.csd"><citetitle>partikkel-2.csd</citetitle></ulink>. |
| 366 | <example> |
| 367 | <title>Example 2 of the partikkel opcode.</title> |
| 368 | <xi:include href="examples-xml/partikkel-2.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 369 | </example> |
| 370 | </para> |
| 371 | <para> |
| 372 | Here is an example of using panning laws with channelmasks in partikkel. It uses the file <ulink url="examples/partikkel-panlaws.csd"><citetitle>partikkel-panlaws.csd</citetitle></ulink>. |
| 373 | <example> |
| 374 | <title>Example with panning laws with channel masks.</title> |
| 375 | <xi:include href="examples-xml/partikkel-panlaws.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 376 | </example> |
| 377 | </para> |
| 378 | </refsect1> |
| 379 | |
| 380 | <refsect1> |
| 381 | <title>See Also</title> |
| 382 | <para> |
| 383 | <link linkend="SiggenGranular"><citetitle>Granular Synthesis</citetitle></link> |
| 384 | </para> |
| 385 | </refsect1> |
| 386 | |
| 387 | <refsect1> |
| 388 | <title>Credits</title> |
| 389 | <para> |
| 390 | <simplelist> |
| 391 | <member>Author: Thom Johansen</member> |
| 392 | <member>Author: Torgeir Strand Henriksen</member> |
| 393 | <member>Author: &nameoeyvind;</member> |
| 394 | <member>April 2007</member> |
| 395 | </simplelist> |
| 396 | <para>Examples written by Joachim Heintz and &nameoeyvind;.</para> |
| 397 | <para>New in version 5.06</para> |
| 398 | </para> |
| 399 | </refsect1> |
| 400 | </refentry> |
| 401 |