Debian Codegraph @

opcodes/pvadd.xml

raw symbols SCIP
1
2 <refentry id="pvadd">
3 <indexterm id="IndexPvadd"><primary>pvadd</primary></indexterm>
4 <refentryinfo><title>Spectral Processing:STFT</title></refentryinfo>
5 <refmeta>
6 <refentrytitle>pvadd</refentrytitle>
7 </refmeta>
8
9 <refnamediv>
10 <refname>pvadd</refname>
11 <refpurpose>
12 Reads from a <emphasis>pvoc</emphasis> file and uses the data to perform additive synthesis.
13 </refpurpose>
14 </refnamediv>
15
16 <refsect1>
17 <title>Description</title>
18 <para>
19 <emphasis>pvadd</emphasis> reads from a <link linkend="pvoc"><citetitle>pvoc</citetitle></link> file and uses the data to perform additive synthesis using an internal array of interpolating oscillators. The user supplies the wave table (usually one period of a sine wave), and can choose which analysis bins will be used in the re-synthesis.
20 </para>
21 </refsect1>
22
23 <refsect1>
24 <title>Syntax</title>
25 <synopsis>ares <command>pvadd</command> ktimpnt, kfmod, ifilcod, ifn, ibins [, ibinoffset] \
26 [, ibinincr] [, iextractmode] [, ifreqlim] [, igatefn]</synopsis>
27 </refsect1>
28
29 <refsect1>
30 <title>Initialization</title>
31 <para>
32 <emphasis>ifilcod</emphasis> -- integer or character-string denoting a control-file derived from <link linkend="pvanal"><citetitle>pvanal</citetitle></link> analysis of an audio signal. An integer denotes the suffix of a file <emphasis>pvoc.m</emphasis>; a character-string (in double quotes) gives a filename, optionally a full pathname. If not fullpath, the file is sought first in the current directory, then in the one given by the environment variable <link linkend="OrchDirFiles"><citetitle>SADIR</citetitle></link> (if defined). <emphasis>pvoc</emphasis> control files contain data organized for fft resynthesis. Memory usage depends on the size of the files involved, which are read and held entirely in memory during computation but are shared by multiple calls (see also <link linkend="lpread"><citetitle>lpread</citetitle></link>).
33 </para>
34
35 <para>
36 <emphasis>ifn</emphasis> -- table number of a stored function containing a sine wave.
37 </para>
38
39 <para>
40 <emphasis>ibins</emphasis> -- number of bins that will be used in the resynthesis (each bin counts as one oscillator in the re-synthesis)
41 </para>
42
43 <para>
44 <emphasis>ibinoffset</emphasis> (optional) -- is the first bin used (it is optional and defaults to 0).
45 </para>
46
47 <para>
48 <emphasis>ibinincr</emphasis> (optional) -- sets an increment by which <emphasis>pvadd</emphasis> counts up from <emphasis>ibinoffset</emphasis> for <emphasis>ibins</emphasis> components in the re-synthesis (see below for a further explanation).
49 </para>
50
51 <para>
52 <emphasis>iextractmode</emphasis> (optional) -- determines if spectral extraction will be carried out and if so whether components that have changes in frequency below <emphasis>ifreqlim</emphasis> or above <emphasis>ifreqlim</emphasis> will be discarded. A value for <emphasis>iextractmode</emphasis> of 1 will cause <emphasis>pvadd</emphasis> to synthesize only those components where the frequency difference between analysis frames is greater than <emphasis>ifreqlim</emphasis>. A value of 2 for <emphasis>iextractmode</emphasis> will cause <emphasis>pvadd</emphasis> to synthesize only those components where the frequency difference between frames is less than <emphasis>ifreqlim</emphasis>. The default values for <emphasis>iextractmode</emphasis> and <emphasis>ifreqlim</emphasis> are 0, in which case a simple resynthesis will be done. See examples below.
53 </para>
54
55 <para>
56 <emphasis>igatefn</emphasis> (optional) -- is the number of a stored function which will be applied to the amplitudes of the analysis bins before resynthesis takes place. If <emphasis>igatefn</emphasis> is greater than 0 the amplitudes of each bin will be scaled by <emphasis>igatefn</emphasis> through a simple mapping process. First, the amplitudes of all of the bins in all of the frames in the entire analysis file are compared to determine the maximum amplitude value. This value is then used create normalized amplitudes as indeces into the stored function <emphasis>igatefn</emphasis>. The maximum amplitude will map to the last point in the function. An amplitude of 0 will map to the first point in the function. Values between 0 and 1 will map accordingly to points along the function table.This will be made clearer in the examples below.
57 </para>
58 </refsect1>
59
60 <refsect1>
61 <title>Performance</title>
62 <para>
63 <emphasis>ktimpnt</emphasis> and <emphasis>kfmod</emphasis> are used in the same way as in <link linkend="pvoc"><citetitle>pvoc</citetitle></link>.
64 </para>
65 </refsect1>
66
67 <refsect1>
68 <title>Examples</title>
69 <para>
70 <informalexample>
71 <programlisting>
72 ktime <emphasis role="opc">line</emphasis> 0, p3, p3
73 asig <emphasis role="opc">pvadd</emphasis> ktime, 1, <quote>oboe.pvoc</quote>, 1, 100, 2</programlisting>
74 </informalexample>
75 </para>
76
77 <para>
78 In the above, <emphasis>ibins</emphasis> is 100 and <emphasis>ibinoffset</emphasis> is 2. Using these settings the resynthesis will contain 100 components beginning with bin #2 (bins are counted starting with 0). That is, resynthesis will be done using bins 2-101 inclusive. It is usually a good idea to begin with bin 1 or 2 since the 0th and often 1st bin have data that is neither necessary nor even helpful for creating good clean resynthesis.
79 </para>
80
81 <para>
82 <informalexample>
83 <programlisting>
84 ktime <emphasis role="opc">line</emphasis> 0, p3, p3
85 asig <emphasis role="opc">pvadd</emphasis> ktime, 1, <quote>oboe.pvoc</quote>, 1, 100, 2, 2</programlisting>
86 </informalexample>
87 </para>
88
89 <para>
90 The above is the same as the previous example with the addition of the value 2 used for the optional <emphasis>ibinincr</emphasis> argument. This result will still result in 100 components in the resynthesis, but <emphasis>pvadd</emphasis> will count through the bins by 2 instead of by 1. It will use bins 2, 4, 6, 8, 10, and so on. For <emphasis>ibins</emphasis>=10, <emphasis>ibinoffset</emphasis>=10, and <emphasis>ibinincr</emphasis>=10, <emphasis>pvadd</emphasis> would use bins 10, 20, 30, 40, up to and including 100.
91 </para>
92
93 <para>
94 Below is an example using spectral extraction. In this example <emphasis>iextractmode</emphasis> is 1 and <emphasis>ifreqlim</emphasis> is 9. This will cause pvadd to synthesize only those bins where the frequency deviation, averaged over 6 frames, is greater than 9.
95 </para>
96
97 <para>
98 <informalexample>
99 <programlisting>
100 ktime <emphasis role="opc">line</emphasis> 0, p3, p3
101 asig <emphasis role="opc">pvadd</emphasis> ktime, 1, <quote>oboe.pvoc</quote>, 1, 100, 2, 2, 1, 9</programlisting>
102 </informalexample>
103 </para>
104
105 <para>
106 If <emphasis>iextractmode</emphasis> were 2 in the above, then only those bins with an average frequency deviation of less than 9 would be synthesized. If tuned correctly, this technique can be used to separate the pitched parts of the spectrum from the noisy parts. In practice this depends greatly on the type of sound, the quality of the recording and digitization, and also on the analysis window size and frame increment.
107 </para>
108
109 <para>
110 Next is an example using amplitude gating. The last 2 in the argument list stands for f2 in the score.
111 </para>
112
113 <para>
114 <informalexample>
115 <programlisting>
116 asig <emphasis role="opc">pvadd</emphasis> ktime, 1, <quote>oboe.pvoc</quote>, 1, 100, 2, 2, 0, 0, 2</programlisting>
117 </informalexample>
118 </para>
119
120 <para>
121 Suppose the score for the above were to contain:
122 </para>
123
124 <para>
125 <informalexample>
126 <programlisting>
127 <emphasis role="stamnt">f</emphasis>2 0 512 7 0 256 1 256 1</programlisting>
128 </informalexample>
129 </para>
130
131 <para>
132 Then those bins with amplitudes of 50% of the maximum or greater would be left unchanged, while those with amplitudes less than 50% of the maximum would be scaled down. In this case the lower the amplitude the more severe the scaling down would be. But suppose the score contains:
133 </para>
134
135 <para>
136 <informalexample>
137 <programlisting>
138 <emphasis role="stamnt">f</emphasis>2 0 512 5 1 512 .001</programlisting>
139 </informalexample>
140 </para>
141
142 <para>
143 In this case lower amplitudes will be left unchanged and greater ones will be scaled down, turning the sound <quote>upside-down</quote> in terms of the amplitude spectrum! Functions can be arbitrarily complex. Just remember that the normalized amplitude values of the analysis are themselves the indeces into the function.
144 </para>
145
146 <para>
147 Finally, both spectral extraction and amplitude gating can be used together. The example below will synthesize only those components that with a frequency deviation of less than 5Hz per frame and it will scale the amplitudes according to f2.
148 </para>
149
150 <para>
151 <informalexample>
152 <programlisting>
153 asig <emphasis role="opc">pvadd</emphasis> ktime, 1, <quote>oboe.pvoc</quote>, 1, 100, 1, 1, 2, 5, 2</programlisting>
154 </informalexample>
155 </para>
156
157 <note>
158 <title>USEFUL HINTS</title>
159 <para>
160 By using several <emphasis>pvadd</emphasis> units together, one can gradually fade in different parts of the resynthesis, creating various <quote>filtering</quote> effects. The author uses <emphasis>pvadd</emphasis> to synthesis one bin at a time to have control over each separate component of the re-synthesis.
161 </para>
162
163 <para>
164 If any combination of <emphasis>ibins</emphasis>, <emphasis>ibinoffset</emphasis>, and <emphasis>ibinincr</emphasis>, creates a situation where <emphasis>pvadd</emphasis> is asked to used a bin number greater than the number of bins in the analysis, it will just use all of the available bins, and give no complaint. So to use every bin just make <emphasis>ibins</emphasis> a big number (ie. 2000).
165 </para>
166
167 <para>
168 Expect to have to scale up the amplitudes by factors of 10-100, by the way.
169 </para>
170 </note>
171 <para>
172 Here is a complete example of the pvadd opcode. It uses the file <ulink url="examples/pvadd.csd"><citetitle>pvadd.csd</citetitle></ulink>
173 <example>
174 <title>Example of the pvadd opcode.</title>
175 <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>
176 <xi:include href="examples-xml/pvadd.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
177 </example>
178 </para>
179 </refsect1>
180
181 <refsect1>
182 <title>See Also</title>
183 <para>
184 <link linkend="SiggenStft"><citetitle>Short-time Fourier Transform (STFT) Resynthesis</citetitle></link>
185 </para>
186 </refsect1>
187
188 <refsect1>
189 <title>Credits</title>
190 <para>
191 <simplelist>
192 <member>Author: Richard Karpen</member>
193 <member>Seattle, WA USA</member>
194 <member>1998</member>
195 </simplelist>
196 </para>
197
198 <para>New in Csound version 3.48, additional arguments version 3.56</para>
199 </refsect1>
200 </refentry>