summaryrefslogtreecommitdiff
path: root/opcodes/syncgrain.xml
blob: a4591dc6127a2841924015cc56c5a05faaa294a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<refentry id="syncgrain">
<indexterm id="IndexSyncgrain"><primary>syncgrain</primary></indexterm>
  <refentryinfo><title>Signal Generators:Granular Synthesis</title></refentryinfo>
  <refmeta>
    <refentrytitle>syncgrain</refentrytitle>
  </refmeta>



  <refnamediv>
    <refname>syncgrain</refname>
    <refpurpose>
Synchronous granular synthesis.
          </refpurpose>
  </refnamediv>
  
  <refsect1>
    <title>Description</title>
    <para>
<emphasis>syncgrain</emphasis> implements synchronous granular synthesis. The source sound for the
grains is obtained by reading a function table containing the samples of the source waveform. 
For sampled-sound sources, <link linkend="GEN01"><citetitle>GEN01</citetitle></link> is used.
<emphasis>syncgrain</emphasis> will accept deferred allocation tables.
  </para>
  <para>
The grain generator has full control of frequency (grains/sec), overall amplitude, 
grain pitch (a sampling increment) and grain size (in secs), 
both as fixed or time-varying (signal) parameters. 
An extra parameter is the grain pointer speed (or rate), 
which controls which position the generator will start reading samples 
in the table for each successive grain. It is measured in fractions of grain size, 
so a value of 1 (the default) will make each successive grain read from where the 
previous grain should finish. A value of 0.5 will make the next grain start at the midway position 
from the previous grain start and finish, etc.. A value of 0 will make the generator read 
always from a fixed position of the table (wherever the pointer was last at).
A negative value will decrement pointer positions. This control gives extra flexibility for creating 
timescale modifications in the resynthesis.
  </para>
  <para>
<emphasis>syncgrain</emphasis> will generate any number of parallel grain streams (which will depend
on grain density/frequency), up to the <emphasis>iolaps</emphasis> value (default 100). The number
of streams (overlapped grains) is determined by grainsize*grain_freq. More grain overlaps will
demand more calculations and the synthesis might not run in realtime (depending on processor power).
  </para>
  <para>
<emphasis>syncgrain</emphasis> can simulate FOF-like formant synthesis, provided that a suitable shape is used 
as grain envelope and a sinewave as the grain wave. For this use, grain sizes of around 
0.04 secs can be used. The formant centre frequency is determined by the grain pitch. 
Since this is a sampling increment, in order to use a frequency in Hz, that value has to be 
scaled by tablesize/sr. Grain frequency will determine the fundamental.
  </para>
  <para>
<emphasis>syncgrain</emphasis> uses floating-point indexing, so its precision is not affected by
large-size tables. This opcode is based on the SndObj library SyncGrain class.
    </para>
  </refsect1>

  <refsect1>
    <title>Syntax</title>
    <synopsis>asig <command>syncgrain</command> kamp, kfreq, kpitch, kgrsize, kprate, ifun1, \
      ifun2, iolaps</synopsis>
  </refsect1>

  <refsect1>
    <title>Initialization</title>
      <para>
      <emphasis>ifun1</emphasis> -- source signal function table. Deferred-allocation tables (see
      <link linkend="GEN01"><citetitle>GEN01</citetitle></link>) are accepted, but the opcode
      expects a mono source.
    </para>
	      <para>
      <emphasis>ifun2</emphasis> -- grain envelope function table.
    </para>
		      <para>
      <emphasis>iolaps</emphasis> -- maximum number of overlaps,
      max(<emphasis>kfreq</emphasis>)*max(<emphasis>kgrsize</emphasis>). Estimating a large value
      should not affect performance, but exceeding this value will probably have disastrous
      consequences.
    </para>
	
  </refsect1>
  
  <refsect1>
    <title>Performance</title>
    <para>
      <emphasis>kamp</emphasis> -- amplitude scaling
    </para>
    <para>
      <emphasis>kfreq</emphasis> -- frequency of grain generation, or density, in grains/sec.
    </para>

    <para>
      <emphasis>kpitch</emphasis> -- grain pitch scaling (1=normal pitch, &lt; 1 lower, > 1 higher; negative, backwards)
    </para>

    <para>
      <emphasis>kgrsize</emphasis> -- grain size in secs.
    </para>
    <para>
      <emphasis>kprate</emphasis> -- readout pointer rate, in grains. The value of 1 will advance 
the reading pointer 1 grain ahead in the source table. Larger values 
will time-compress and smaller values will time-expand the source signal. 
Negative values will cause the pointer to run backwards and zero will 
freeze it.
    </para>

  </refsect1>
  <refsect1>
    <title>Examples</title>
    <para>
      <example>
        <title>Example</title>
        <programlisting>
		
iolaps  <emphasis role="op">=</emphasis> 2
igrsize <emphasis role="op">=</emphasis> 0.04
ifreq   <emphasis role="op">=</emphasis> iolaps<emphasis role="op">/</emphasis>igrsize
ips     <emphasis role="op">=</emphasis> 1<emphasis role="op">/</emphasis>iolaps

istr    <emphasis role="op">=</emphasis> .5  <emphasis role="comment">/* timescale  */</emphasis>
ipitch  <emphasis role="op">=</emphasis> 1   <emphasis role="comment">/* pitchscale */</emphasis>

a1 <emphasis role="opc">syncgrain</emphasis> 16000, ifreq, ipitch, igrsize, ips*istr, 1, 2, iolaps
   <emphasis role="opc">out</emphasis>       a1</programlisting>
      </example>

    </para>
    

  </refsect1>



  <refsect1>
    <title>Credits</title>
    <para>
      <simplelist>
        <member>Author: Victor Lazzarini;</member>
        <member>January 2005</member>
      </simplelist>
    </para>

    <para>New plugin in version 5</para>
    <para>January 2005.</para>
  </refsect1>
</refentry>