| 1 | |
| 2 | <refentry id="diskin"> |
| 3 | <indexterm id="IndexDiskin"><primary>diskin</primary></indexterm> |
| 4 | <refentryinfo><title>Signal I/O:Signal Input</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>diskin</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | <refnamediv> |
| 10 | <refname>diskin</refname> |
| 11 | <refpurpose> |
| 12 | Reads audio data from an external device or stream and can alter its pitch. |
| 13 | </refpurpose> |
| 14 | </refnamediv> |
| 15 | |
| 16 | <refsect1> |
| 17 | <title>Description</title> |
| 18 | <para> |
| 19 | Reads audio data from an external device or stream and can alter its pitch. |
| 20 | </para> |
| 21 | </refsect1> |
| 22 | |
| 23 | <refsect1> |
| 24 | <title>Syntax</title> |
| 25 | <synopsis>ar1 [, ar2 [, ar3 [, ... arN]]] <command>diskin</command> ifilcod[, kpitch[, iskiptim \ |
| 26 | [, iwraparound[, iformat[, iskipinit]]]]]</synopsis> |
| 27 | <para> Note the N was 24 in versions before 5.14, and 40 after.</para> |
| 28 | |
| 29 | <synopsis>ar1[] <command>diskin</command> ifilcod[, kpitch[, iskiptim \ |
| 30 | [, iwraparound[, iformat[, iskipinit]]]]]</synopsis> |
| 31 | <para> (in this version, the number of output channels is not limited.)</para> |
| 32 | </refsect1> |
| 33 | |
| 34 | <refsect1> |
| 35 | <title>Initialization</title> |
| 36 | <para> |
| 37 | <emphasis>ifilcod</emphasis> -- integer or character-string denoting the source soundfile name. An integer denotes the file soundin.filcod ; a character-string (in double quotes, spaces permitted) gives the filename itself, optionally a full pathname. If not a full path, the named file is sought first in the current directory, then in that given by the environment variable <link linkend="CommandEnvironment"><citetitle>SSDIR</citetitle></link> (if defined) then by <link linkend="CommandEnvironment"><citetitle>SFDIR</citetitle></link>. See also <link linkend="GEN01"><citetitle>GEN01</citetitle></link>. |
| 38 | </para> |
| 39 | |
| 40 | <para> |
| 41 | <emphasis>iskptim</emphasis> (optional) -- time in seconds of input sound to be skipped. The default value is 0. |
| 42 | </para> |
| 43 | |
| 44 | <para> |
| 45 | <emphasis>iformat</emphasis> (optional) -- ignored if positive |
| 46 | but if negative specifies the audio data file format of a raw file: |
| 47 | <itemizedlist> |
| 48 | <listitem> |
| 49 | <para>-1 = 8-bit signed char (high-order 8 bits of a 16-bit integer)</para> |
| 50 | </listitem> |
| 51 | |
| 52 | <listitem> |
| 53 | <para>-2 = 8-bit A-law bytes</para> |
| 54 | </listitem> |
| 55 | |
| 56 | <listitem> |
| 57 | <para>-3 = 8-bit U-law bytes</para> |
| 58 | </listitem> |
| 59 | |
| 60 | <listitem> |
| 61 | <para>-4 = 16-bit short integers</para> |
| 62 | </listitem> |
| 63 | |
| 64 | <listitem> |
| 65 | <para>-5 = 32-bit long integers</para> |
| 66 | </listitem> |
| 67 | |
| 68 | <listitem> |
| 69 | <para>-6 = 32-bit floats</para> |
| 70 | </listitem> |
| 71 | |
| 72 | <listitem> |
| 73 | <para>-7 = 8-bit unsigned int (not available in Csound versions older than 5.00)</para> |
| 74 | </listitem> |
| 75 | |
| 76 | <listitem> |
| 77 | <para>-8 = 24-bit int (not available in Csound versions older than 5.00)</para> |
| 78 | </listitem> |
| 79 | |
| 80 | <listitem> |
| 81 | <para>-9 = 64-bit doubles (not available in Csound versions older than 5.00)</para> |
| 82 | </listitem> |
| 83 | </itemizedlist> |
| 84 | </para> |
| 85 | |
| 86 | <para> |
| 87 | <emphasis>iwraparound</emphasis> -- 1 = on, 0 = off (wraps |
| 88 | around to end of file either direction, enabling looping) |
| 89 | </para> |
| 90 | |
| 91 | <para> |
| 92 | <emphasis>iskipinit</emphasis> switches off all initialisation if |
| 93 | non zero (default =0). This was introduced in 4_23f13 and |
| 94 | csound5. |
| 95 | </para> |
| 96 | |
| 97 | <para> |
| 98 | If <emphasis>iformat</emphasis> = 0 it is taken from the soundfile header, and if no header from the Csound <link linkend="FlagsMinusLowerO"><citetitle>-o</citetitle></link> command-line flag. The default value is 0. |
| 99 | </para> |
| 100 | |
| 101 | </refsect1> |
| 102 | |
| 103 | <refsect1> |
| 104 | <title>Performance</title> |
| 105 | <para> |
| 106 | <emphasis>a1 ... a24</emphasis> |
| 107 | -- output signals, in the range -0dbfs to 0dbfs. Any samples |
| 108 | before the beginning (i.e. negative location) and after the end of |
| 109 | the file are assumed to be zero, unless <emphasis>iwrap</emphasis> is non-zero. |
| 110 | The number of output arguments must be the same as the number of sound |
| 111 | file channels - which can be determined with the |
| 112 | <link linkend="filenchnls"><citetitle>filenchnls</citetitle></link> opcode, |
| 113 | otherwise an init error will occur. |
| 114 | </para> |
| 115 | |
| 116 | <para> |
| 117 | <emphasis>ar1[]</emphasis> |
| 118 | --- output signals, in a-rate array of size N, where N is the number of |
| 119 | channels in the file. Arrays are automatically allocated to the correct |
| 120 | size. |
| 121 | </para> |
| 122 | <para> |
| 123 | <emphasis>kpitch</emphasis> -- can be any real number. A negative number signifies backwards playback. The given number is a pitch ratio, where: |
| 124 | <itemizedlist> |
| 125 | <listitem><para><emphasis>1</emphasis> = normal pitch (default)</para></listitem> |
| 126 | <listitem><para><emphasis>2</emphasis> = 1 octave higher</para></listitem> |
| 127 | <listitem><para><emphasis>3</emphasis> = 12th higher, etc.</para></listitem> |
| 128 | <listitem><para><emphasis>.5</emphasis> = 1 octave lower</para></listitem> |
| 129 | <listitem><para><emphasis>.25</emphasis> = 2 octaves lower, etc.</para></listitem> |
| 130 | <listitem><para><emphasis>-1</emphasis> = normal pitch backwards</para></listitem> |
| 131 | <listitem><para><emphasis>-2</emphasis> = 1 octave higher backwards, etc.</para></listitem> |
| 132 | </itemizedlist> |
| 133 | </para> |
| 134 | |
| 135 | |
| 136 | <caution> |
| 137 | <title>Note to Windows users</title> |
| 138 | <para> |
| 139 | Windows users typically use back-slashes, <quote>\</quote>, when specifying the paths of their files. As an example, a Windows user might use the path <quote>c:\music\samples\loop001.wav</quote>. This is problematic because back-slashes are normally used to specify special characters. |
| 140 | </para> |
| 141 | |
| 142 | <para> |
| 143 | To correctly specify this path in Csound, one may alternately: |
| 144 | <itemizedlist> |
| 145 | <listitem><para><emphasis>Use forward slashes</emphasis>: c:/music/samples/loop001.wav</para></listitem> |
| 146 | <listitem><para><emphasis>Use back-slash special characters, <quote>\\</quote></emphasis>: c:\\music\\samples\\loop001.wav</para></listitem> |
| 147 | |
| 148 | </itemizedlist> |
| 149 | </para> |
| 150 | </caution> |
| 151 | </refsect1> |
| 152 | |
| 153 | <refsect1> |
| 154 | <title>Examples</title> |
| 155 | <para> |
| 156 | Here is an example of the diskin opcode. It uses the file <ulink url="examples/diskin.csd"><citetitle>diskin.csd</citetitle></ulink>, <ulink url="examples/drumsMlp.wav"><citetitle>drumsMlp.wav</citetitle></ulink>. |
| 157 | <example> |
| 158 | <title>Example of the diskin opcode.</title> |
| 159 | <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> |
| 160 | <xi:include href="examples-xml/diskin.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 161 | </example> |
| 162 | </para> |
| 163 | </refsect1> |
| 164 | |
| 165 | <refsect1> |
| 166 | <title>See also</title> |
| 167 | <para><link linkend="SigioInput"><citetitle>Signal Input</citetitle></link></para> |
| 168 | </refsect1> |
| 169 | |
| 170 | <refsect1> |
| 171 | <title>Credits</title> |
| 172 | <para> |
| 173 | <simplelist> |
| 174 | <member>Authors: &namebarry;, &namematt;/&namemike;</member> |
| 175 | <member>MIT, Mills College</member> |
| 176 | <member>1993-1997</member> |
| 177 | </simplelist> |
| 178 | </para> |
| 179 | <para>New in version 3.46</para> |
| 180 | <para>kpitch optional in version 6.06</para> |
| 181 | <para>Warning to Windows users added by &namekevin;, April 2002</para> |
| 182 | </refsect1> |
| 183 | </refentry> |