Debian Codegraph @

opcodes/grain3.xml

raw symbols SCIP
1
2 <refentry id="grain3">
3 <indexterm id="IndexGrain3"><primary>grain3</primary></indexterm>
4 <refentryinfo><title>Signal Generators:Granular Synthesis</title></refentryinfo>
5 <refmeta>
6 <refentrytitle>grain3</refentrytitle>
7 </refmeta>
8
9
10
11 <refnamediv>
12 <refname>grain3</refname>
13 <refpurpose>
14 Generate granular synthesis textures with more user control.
15 </refpurpose>
16 </refnamediv>
17
18 <refsect1>
19 <title>Description</title>
20 <para>
21 Generate granular synthesis textures. <link linkend="grain2"><citetitle>grain2</citetitle></link> is simpler to use but <emphasis>grain3</emphasis> offers more control.
22 </para>
23 </refsect1>
24
25 <refsect1>
26 <title>Syntax</title>
27 <synopsis>ares <command>grain3</command> kcps, kphs, kfmd, kpmd, kgdur, kdens, imaxovr, kfn, iwfn, \
28 kfrpow, kprpow [, iseed] [, imode]</synopsis>
29 </refsect1>
30
31 <refsect1>
32 <title>Initialization</title>
33 <para>
34 <emphasis>imaxovr</emphasis> -- maximum number of overlapping grains. The number of overlaps can be calculated by (<emphasis>kdens</emphasis> * <emphasis>kgdur</emphasis>); however, it can be overestimated at no cost in rendering time, and a single overlap uses (depending on system) 16 to 32 bytes of memory.
35 </para>
36
37 <para>
38 <emphasis>iwfn</emphasis> -- function table containing window waveform (Use <link linkend="GEN20">GEN20</link> to calculate <emphasis>iwfn</emphasis>).
39 </para>
40
41
42 <para>
43 <emphasis>iseed</emphasis> (optional, default=0) -- seed value for random number generator (positive integer in the range 1 to 2147483646 (2<superscript>31</superscript> - 2)). Zero or negative value seeds from current time (this is also the default).
44 </para>
45
46 <para>
47 <emphasis>imode</emphasis> (optional, default=0) -- sum of the following values:
48 <itemizedlist>
49 <listitem><para><emphasis>64:</emphasis> synchronize start phase of grains to <emphasis>kcps</emphasis>.</para></listitem>
50 <listitem><para><emphasis>32:</emphasis> start all grains at integer sample location. This may be faster in some cases, however it also makes the timing of grain envelopes less accurate.</para></listitem>
51 <listitem><para><emphasis>16:</emphasis> do not render grains with start time less than zero. (see the image below; this option turns off grains marked with red on the image).</para></listitem>
52 <listitem><para><emphasis>8:</emphasis> interpolate window waveform (slower).</para></listitem>
53 <listitem><para><emphasis>4:</emphasis> do not interpolate grain waveform (fast, but lower quality).</para></listitem>
54 <listitem><para><emphasis>2:</emphasis> grain frequency is continuously modified by <emphasis>kcps</emphasis> and <emphasis>kfmd</emphasis> (by default, each grain keeps the frequency it was launched with). This may be slower at high control rates. It also controls phase modulation (<emphasis>kphs</emphasis>).</para></listitem>
55 <listitem><para><emphasis>1:</emphasis> skip initialization.</para></listitem>
56 </itemizedlist>
57 </para>
58
59 <para>
60 <mediaobject>
61 <imageobject>
62 <imagedata fileref="images/grain3_2.png" format="PNG"/>
63 </imageobject>
64
65 <textobject>
66 <phrase>[A diagram showing grains with a start time less than zero in red.]</phrase>
67 </textobject>
68
69 <caption>
70 <para>A diagram showing grains with a start time less than zero in red.</para>
71 </caption>
72 </mediaobject>
73 </para>
74 </refsect1>
75
76 <refsect1>
77 <title>Performance</title>
78 <para>
79 <emphasis>ares</emphasis> -- output signal.
80 </para>
81
82 <para>
83 <emphasis>kcps</emphasis> -- grain frequency in Hz.
84 </para>
85
86 <para>
87 <emphasis>kphs</emphasis> -- grain phase. This is the location in the grain waveform table, expressed
88 as a fraction (between 0 to 1) of the table length.
89 </para>
90
91 <para>
92 <emphasis>kfmd</emphasis> -- random variation (bipolar) in grain frequency in Hz.
93 </para>
94
95 <para>
96 <emphasis>kpmd</emphasis> -- random variation (bipolar) in start phase.
97 </para>
98
99 <para>
100 <emphasis>kgdur</emphasis> -- grain duration in seconds. <emphasis>kgdur</emphasis> also controls the duration of already active grains (actually the speed at which the window function is read). This behavior does not depend on the <emphasis>imode</emphasis> flags.
101 </para>
102
103 <para>
104 <emphasis>kdens</emphasis> -- number of grains per second.
105 </para>
106
107 <para>
108 <emphasis>kfrpow</emphasis> -- this value controls the distribution of grain frequency variation. If <emphasis>kfrpow</emphasis> is positive, the random distribution (x is in the range -1 to 1) is <literallayout>abs(x) &circ; ((1 / kfrpow) - 1)</literallayout>; for negative <emphasis>kfrpow</emphasis> values, it is <literallayout>(1 - abs(x)) &circ; ((-1 / kfrpow) - 1)</literallayout>Setting <emphasis>kfrpow</emphasis> to -1, 0, or 1 will result in uniform distribution (this is also faster to calculate). The image below shows some examples for <emphasis>kfrpow</emphasis>. The default value of <emphasis>kfrpow</emphasis> is 0.
109 </para>
110 <para>
111 <mediaobject>
112 <imageobject>
113 <imagedata fileref="images/grain2_rand-448x289.png" format="PNG"/>
114 </imageobject>
115 <textobject>
116 <phrase>[A graph of distributions for different values of <emphasis>kfrpow</emphasis>.]</phrase>
117 </textobject>
118 <caption>
119 <para>A graph of distributions for different values of <emphasis>kfrpow</emphasis>.</para>
120 </caption>
121 </mediaobject>
122 </para>
123 <para>
124 <emphasis>kprpow</emphasis> -- distribution of random phase variation (see <emphasis>kfrpow</emphasis>). Setting <emphasis>kphs</emphasis> and <emphasis>kpmd</emphasis> to 0.5, and <emphasis>kprpow</emphasis> to 0 will emulate <emphasis>grain2</emphasis>.
125 </para>
126
127 <para>
128 <emphasis>kfn</emphasis> -- function table containing grain waveform. Table number can be changed at k-rate (this is useful to select from a set of band-limited tables generated by <link linkend="GEN30">GEN30</link>, to avoid aliasing).
129 </para>
130
131 <note>
132 <title>Note</title>
133 <para>
134 <emphasis>grain3</emphasis> internally uses the same random number generator as <emphasis>rnd31</emphasis>. So reading <link linkend="rnd31"><citetitle>its documentation</citetitle></link> is also recommended.
135 </para>
136 </note>
137 </refsect1>
138
139 <refsect1>
140 <title>Examples</title>
141 <para>
142 Here is an example of the grain3 opcode. It uses the file <ulink url="examples/grain3.csd"><citetitle>grain3.csd</citetitle></ulink>.
143
144 <example>
145 <title>Example of the grain3 opcode.</title>
146
147
148
149 <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>
150 <xi:include href="examples-xml/grain3.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
151 </example>
152 </para>
153 </refsect1>
154
155 <refsect1>
156 <title>See Also</title>
157 <para>
158 <link linkend="SiggenGranular"><citetitle>Granular Synthesis</citetitle></link>
159 </para>
160 </refsect1>
161
162 <refsect1>
163 <title>Credits</title>
164 <para>
165 <simplelist>
166 <member>Author: &nameistvan;</member>
167 </simplelist>
168 </para>
169
170 <para>New in version 4.15</para>
171 <para>Updated April 2002 by &nameistvan;</para>
172 </refsect1>
173 </refentry>