Debian Codegraph @

opcodes/diskin2.xml

raw symbols SCIP
1
2 <refentry id="diskin2">
3 <indexterm id="IndexDiskin2"><primary>diskin2</primary></indexterm>
4 <refentryinfo><title>Signal I/O:Signal Input</title></refentryinfo>
5 <refmeta>
6 <refentrytitle>diskin2</refentrytitle>
7 </refmeta>
8
9 <refnamediv>
10 <refname>diskin2</refname>
11 <refpurpose>
12 Reads audio data from a file, and can alter its pitch using one of several
13 available interpolation types, as well as convert the sample rate to match
14 the orchestra sr setting.
15 </refpurpose>
16 </refnamediv>
17
18 <refsect1>
19 <title>Description</title>
20 <para>
21 Reads audio data from a file, and can alter its pitch using
22 one of several available interpolation types, as well as
23 convert the sample rate to match the orchestra sr
24 setting. <emphasis>diskin2</emphasis> can also read
25 multichannel files with any number of channels in the range 1
26 to 24 in versions before 5.14, and 40 after.
27
28 </para>
29
30
31 </refsect1>
32
33 <refsect1>
34 <title>Syntax</title>
35 <synopsis>a1[, a2[, ... aN]] <command>diskin2</command> ifilcod[, kpitch[, iskiptim \
36 [, iwrap[, iformat[, iwsize[, ibufsize[, iskipinit]]]]]]]</synopsis>
37
38 <synopsis>ar1[] <command>diskin2</command> ifilcod[, kpitch[, iskiptim \
39 [, iwrap[, iformat[, iwsize[, ibufsize[, iskipinit]]]]]]]</synopsis>
40
41 <para> (in the array output version, the number of output channels does not have an upper limit.)</para>
42
43 </refsect1>
44
45 <refsect1>
46 <title>Initialization</title>
47
48 <para>
49 <emphasis>ifilcod</emphasis>
50 -- integer or character-string denoting the source soundfile
51 name. An integer denotes the file soundin.ifilcod; a character-string
52 (in double quotes, spaces permitted) gives the filename itself,
53 optionally a full pathname. If not a full path, the named file is
54 sought first in the current directory, then in those given by the
55 environment variable <link linkend="CommandEnvironment"><citetitle>SSDIR</citetitle></link> (if defined) then by <link linkend="CommandEnvironment"><citetitle>SFDIR</citetitle></link>. See also
56 <link linkend="GEN01"><citetitle>GEN01</citetitle></link>.
57 Note: files longer than 2<superscript>31</superscript>-1 sample frames may not be played correctly
58 on 32-bit platforms; this means a maximum length about 3 hours with a
59 sample rate of 192000 Hz.
60 </para>
61
62 <para>
63 <emphasis>iskiptim</emphasis>
64 (optional, defaults to zero) -- time in seconds of input sound to
65 be skipped, assuming <emphasis>kpitch</emphasis>=1. Can be negative, to add
66 -<emphasis>iskiptim</emphasis>/<emphasis>kpitch</emphasis>
67 seconds of delay instead of skipping sound.
68 <note>
69 <title>Note</title>
70 <para>If <emphasis>iwrap</emphasis> is not 0 (locations are wrapped),
71 <emphasis>iskiptim</emphasis> will not delay the sound if a negative value is used.
72 Instead, the negative value will be "wrapped" from the end of the file.
73 </para>
74 </note>
75 </para>
76
77 <para>
78 <emphasis>iwrap</emphasis>
79 (optional, defaults to zero) -- if set to any non-zero value, read
80 locations that are negative or are beyond the end of the file are wrapped
81 to the duration of the sound file instead of assuming zero samples.
82 Useful for playing a file in a loop.
83
84 <note>
85 <title>Note</title>
86 <para>
87 If <emphasis>iwrap</emphasis> is enabled, the file length should not be shorter than
88 the interpolation window size (see below), otherwise there may be clicks
89 in the sound output.
90 </para>
91 </note>
92
93 </para>
94
95 <para>
96 <emphasis>iformat</emphasis>
97 (optional, defaults to zero) -- sets raw and sample format for raw (headerless)
98 files. This parameter must be zero if the file has a header.
99 Allowed values for raw files are are:
100
101 <itemizedlist>
102 <listitem>
103 <para>1: 16-bit short integers</para>
104 </listitem>
105
106 <listitem>
107 <para>2: 8-bit signed char (high-order 8 bits of a 16-bit integer)</para>
108 </listitem>
109
110 <listitem>
111 <para>3: 8-bit A-law bytes</para>
112 </listitem>
113
114 <listitem>
115 <para>4: 8-bit U-law bytes</para>
116 </listitem>
117
118 <listitem>
119 <para>5: 16-bit short integers</para>
120 </listitem>
121
122 <listitem>
123 <para>6: 32-bit long integers</para>
124 </listitem>
125
126 <listitem>
127 <para>7: 32-bit floats</para>
128 </listitem>
129
130 <listitem>
131 <para>8: 8-bit unsigned int</para>
132 </listitem>
133
134 <listitem>
135 <para>9: 24-bit int</para>
136 </listitem>
137
138 <listitem>
139 <para>10: 64-bit doubles</para>
140 </listitem>
141 </itemizedlist>
142
143 </para>
144 <note><para>This list is not the same as in <link linkend="GEN01"><citetitle>GEN01</citetitle></link></para></note>
145
146 <para>
147 <emphasis>iwsize</emphasis>
148 (optional, defaults to zero) -- interpolation window size, in samples.
149 Can be one of the following:
150
151 <itemizedlist>
152
153 <listitem>
154 <para>1: round to nearest sample (no interpolation, for <emphasis>kpitch</emphasis>=1)</para>
155 </listitem>
156
157 <listitem>
158 <para>2: linear interpolation</para>
159 </listitem>
160
161 <listitem>
162 <para>4: cubic interpolation</para>
163 </listitem>
164
165 <listitem>
166 <para>>= 8: <emphasis>iwsize</emphasis> point sinc interpolation with anti-aliasing (slow)</para>
167 </listitem>
168
169 </itemizedlist>
170
171 Zero or negative values select the default, which is cubic interpolation.
172
173 <note>
174 <title>Note</title>
175 <para>If interpolation is used, <emphasis>kpitch</emphasis> is automatically scaled by the
176 ratio of the sample rate of the sound file and the orchestra, so that
177 the file will always be played at the original pitch if <emphasis>kpitch</emphasis> is 1.
178 However, the sample rate conversion is disabled if <emphasis>iwsize</emphasis> is 1.
179 </para>
180 </note>
181
182 </para>
183
184 <para>
185 <emphasis>ibufsize</emphasis>
186 (optional, defaults to 0) -- buffer size in mono samples (not sample
187 frames). This is only the suggested value, the actual setting will be
188 rounded so that the number of sample frames is an integer power of two
189 and is in the range 128 (or <emphasis>iwsize</emphasis> if greater than 128) to 1048576.
190 The default, which is 4096, and is enabled by zero or negative values,
191 should be suitable for most uses, but for non-realtime mixing of many
192 large sound files, a high buffer setting is recommended to improve the
193 efficiency of disk reads. For real time audio output, reading the files
194 from a fast RAM file system (on platforms where this option is
195 available) with a small buffer size may be preferred.
196 </para>
197
198 <para>
199 <emphasis>iskipinit</emphasis>
200 (optional, defaults to 0) -- skip initialization if set to any
201 non-zero value.
202 </para>
203
204 </refsect1>
205
206 <refsect1>
207 <title>Performance</title>
208
209 <para>
210 <emphasis>a1 ... a24</emphasis>
211 -- output signals, in the range -0dbfs to 0dbfs. Any samples
212 before the beginning (i.e. negative location) and after the end of
213 the file are assumed to be zero, unless <emphasis>iwrap</emphasis> is non-zero.
214 The number of output arguments must be the same as the number of sound
215 file channels - which can be determined with the
216 <link linkend="filenchnls"><citetitle>filenchnls</citetitle></link> opcode,
217 otherwise an init error will occur.
218 </para>
219
220 <para>
221 <emphasis>ar1[]</emphasis>
222 --- output signals, in a-rate array of size N, where N is the number of
223 channels in the file. Arrays are automatically allocated to the correct
224 size.
225 </para>
226 <note>
227 <title>Note</title>
228 <para>It is more efficient to read a single file with many channels,
229 than many files with only a single channel, especially with high <emphasis>iwsize</emphasis>
230 settings.
231 </para>
232 </note>
233
234
235
236 <para>
237 <emphasis>kpitch</emphasis>
238 -- transpose the pitch of input sound by this factor (e.g. 0.5 means
239 one octave lower, 2 is one octave higher, and 1 is the original
240 pitch, which is the default value).
241 Fractional and negative values are allowed (the latter results in
242 playing the file backwards, however, in this case the skip time parameter
243 should be set to some positive value, e.g. the length of the file, or
244 <emphasis>iwrap</emphasis> should be non-zero, otherwise nothing would be played).
245 If interpolation is enabled, and the sample rate of the file differs
246 from the orchestra sample rate, the transpose ratio is automatically
247 adjusted to make sure that <emphasis>kpitch</emphasis>=1 plays at the original pitch.
248 Using a high <emphasis>iwsize</emphasis> setting (40 or more) can significantly improve
249 sound quality when transposing up, although at the expense of high
250 CPU usage.
251 </para>
252
253 </refsect1>
254
255
256 <refsect1>
257 <title>Examples</title>
258 <para>
259 Here is an example of the diskin2 opcode. It uses the file <ulink url="examples/diskin2.csd"><citetitle>diskin2.csd</citetitle></ulink>, <ulink url="examples/drumsMlp.wav"><citetitle>drumsMlp.wav</citetitle></ulink>.
260 <example>
261 <title>Example of the diskin2 opcode.</title>
262 <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>
263 <xi:include href="examples-xml/diskin2.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
264 </example>
265 </para>
266 </refsect1>
267
268 <refsect1>
269 <title>See also</title>
270 <para><link linkend="SigioInput"><citetitle>Signal Input</citetitle></link></para>
271 </refsect1>
272
273 <refsect1>
274 <title>Credits</title>
275 <para>
276 <simplelist>
277 <member>Author: Istvan Varga</member>
278 <member>2005</member>
279 </simplelist>
280 </para>
281 <para>New in version 5.00</para>
282 <para>kpitch optional in version 6.06</para>
283 </refsect1>
284 </refentry>