| 1 | |
| 2 | <refentry id="grain"> |
| 3 | <indexterm id="IndexGrain"><primary>grain</primary></indexterm> |
| 4 | <refentryinfo><title>Signal Generators:Granular Synthesis</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>grain</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | |
| 10 | |
| 11 | <refnamediv> |
| 12 | <refname>grain</refname> |
| 13 | <refpurpose> |
| 14 | Generates granular synthesis textures. |
| 15 | </refpurpose> |
| 16 | </refnamediv> |
| 17 | |
| 18 | <refsect1> |
| 19 | <title>Description</title> |
| 20 | <para> |
| 21 | Generates granular synthesis textures. |
| 22 | </para> |
| 23 | </refsect1> |
| 24 | |
| 25 | <refsect1> |
| 26 | <title>Syntax</title> |
| 27 | <synopsis>ares <command>grain</command> xamp, xpitch, xdens, kampoff, kpitchoff, kgdur, igfn, \ |
| 28 | iwfn, imgdur [, igrnd]</synopsis> |
| 29 | </refsect1> |
| 30 | |
| 31 | <refsect1> |
| 32 | <title>Initialization</title> |
| 33 | <para> |
| 34 | <emphasis>igfn</emphasis> -- The ftable number of the grain waveform. This can be just a sine wave or a sampled sound. |
| 35 | </para> |
| 36 | |
| 37 | <para> |
| 38 | <emphasis>iwfn</emphasis> -- Ftable number of the amplitude envelope used for the grains (see also <link linkend="GEN20"><citetitle>GEN20</citetitle></link>). |
| 39 | </para> |
| 40 | |
| 41 | <para> |
| 42 | <emphasis>imgdur</emphasis> -- Maximum grain duration in seconds. This is the biggest value to be assigned to <emphasis>kgdur</emphasis>. |
| 43 | </para> |
| 44 | |
| 45 | <para> |
| 46 | <emphasis>igrnd</emphasis> (optional) -- if non-zero, turns off grain offset randomness. This means that all grains will begin reading from the beginning of the <emphasis>igfn</emphasis> table. If zero (the default), grains will start reading from random <emphasis>igfn</emphasis> table positions. |
| 47 | </para> |
| 48 | </refsect1> |
| 49 | |
| 50 | <refsect1> |
| 51 | <title>Performance</title> |
| 52 | <para> |
| 53 | <emphasis>xamp</emphasis> -- Amplitude of each grain. |
| 54 | </para> |
| 55 | |
| 56 | <para> |
| 57 | <emphasis>xpitch</emphasis> -- Grain pitch. To use the original frequency of the input sound, use the formula: |
| 58 | <literallayout> sndsr / ftlen(<emphasis>igfn</emphasis>)</literallayout> |
| 59 | </para> |
| 60 | |
| 61 | <para> |
| 62 | where sndsr is the original sample rate of the <emphasis>igfn</emphasis> sound. |
| 63 | </para> |
| 64 | |
| 65 | <para> |
| 66 | <emphasis>xdens</emphasis> -- Density of grains measured in grains per second. If this is constant then the output is synchronous granular synthesis, very similar to <link linkend="fof"><citetitle>fof</citetitle></link>. If <emphasis>xdens</emphasis> has a random element (like added noise), then the result is more like asynchronous granular synthesis. |
| 67 | </para> |
| 68 | |
| 69 | <para> |
| 70 | <emphasis>kampoff</emphasis> -- Maximum amplitude deviation from <emphasis>xamp</emphasis>. This means that the maximum amplitude a grain can have is <emphasis>xamp</emphasis> + <emphasis>kampoff</emphasis> and the minimum is <emphasis>xamp</emphasis>. If <emphasis>kampoff</emphasis> is set to zero then there is no random amplitude for each grain. |
| 71 | </para> |
| 72 | |
| 73 | <para> |
| 74 | <emphasis>kpitchoff</emphasis> -- Maximum pitch deviation from <emphasis>xpitch</emphasis> in Hz. Similar to <emphasis>kampoff</emphasis>. |
| 75 | </para> |
| 76 | |
| 77 | <para> |
| 78 | <emphasis>kgdur</emphasis> -- Grain duration in seconds. The maximum value for this should be declared in <emphasis>imgdur</emphasis>. If <emphasis>kgdur</emphasis> at any point becomes greater than <emphasis>imgdur</emphasis>, it will be truncated to <emphasis>imgdur</emphasis>. |
| 79 | </para> |
| 80 | |
| 81 | <para> |
| 82 | The grain generator is based primarily on work and writings of Barry Truax and Curtis Roads. |
| 83 | </para> |
| 84 | </refsect1> |
| 85 | |
| 86 | <refsect1> |
| 87 | <title>Examples</title> |
| 88 | <para> |
| 89 | This example generates a texture with gradually shorter grains and wider amp and pitch spread. It uses the file <ulink url="examples/grain.csd"><citetitle>grain.csd</citetitle></ulink>, and <ulink url="examples/drumsMlp.wav"><citetitle>drumsMlp.wav</citetitle></ulink>. |
| 90 | |
| 91 | <example> |
| 92 | <title>Example of the grain opcode.</title> |
| 93 | |
| 94 | |
| 95 | |
| 96 | <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> |
| 97 | <xi:include href="examples-xml/grain.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 98 | </example> |
| 99 | </para> |
| 100 | </refsect1> |
| 101 | |
| 102 | <refsect1> |
| 103 | <title>See Also</title> |
| 104 | <para> |
| 105 | <link linkend="SiggenGranular"><citetitle>Granular Synthesis</citetitle></link> |
| 106 | </para> |
| 107 | </refsect1> |
| 108 | |
| 109 | <refsect1> |
| 110 | <title>Credits</title> |
| 111 | <para> |
| 112 | <simplelist> |
| 113 | <member>Author: &nameparis;</member> |
| 114 | <member>MIT</member> |
| 115 | <member>May 1997</member> |
| 116 | </simplelist> |
| 117 | </para> |
| 118 | </refsect1> |
| 119 | </refentry> |