| 1 | |
| 2 | <refentry id="loscilx"> |
| 3 | <indexterm id="Indexloscilx"><primary>loscilx</primary></indexterm> |
| 4 | <refentryinfo><title>Signal Generators:Sample Playback</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>loscilx</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | <refnamediv> |
| 10 | <refname>loscilx</refname> |
| 11 | <refpurpose> |
| 12 | Read multi-channel sampled sound from a table. |
| 13 | </refpurpose> |
| 14 | </refnamediv> |
| 15 | |
| 16 | <refsect1> |
| 17 | <title>Description</title> |
| 18 | <para> |
| 19 | Read sampled sound (up to 16 channels) from a table, with |
| 20 | optional sustain and release looping. |
| 21 | </para> |
| 22 | </refsect1> |
| 23 | <refsect1> |
| 24 | <title>Syntax</title> |
| 25 | <synopsis>ar1 [, ar2, ar3, ar4, ar5, ar6, ar7, ar8, ar9, ar10, ar11, ar12, ar13, ar14, \ |
| 26 | ar15, ar16] <command>loscilx</command> xamp, kcps, ifn \ |
| 27 | [, iwsize, ibas, istrt, imod, ibeg, iend]</synopsis> |
| 28 | <synopsis>ar[] <command>loscilx</command> xamp, kcps, ifn \ |
| 29 | [, iwsize, ibas, istrt, imod, ibeg, iend]</synopsis> |
| 30 | </refsect1> |
| 31 | |
| 32 | <refsect1> |
| 33 | <title>Initialization</title> |
| 34 | <para> |
| 35 | <emphasis>ifn</emphasis> -- function table number, typically |
| 36 | denoting an sampled sound segment with prescribed looping points |
| 37 | loaded using <link |
| 38 | linkend="GEN01"><citetitle>GEN01</citetitle></link>. The source |
| 39 | file may have up to 16 channels. |
| 40 | </para> |
| 41 | |
| 42 | <para> |
| 43 | <emphasis>iwsize</emphasis> (optional) -- window size used in interpolation. |
| 44 | iwsize (optional, defaults to zero) -- interpolation window size, in samples. Can be one of the following: |
| 45 | <itemizedlist> |
| 46 | |
| 47 | <listitem> |
| 48 | <para>1: round to nearest sample (no interpolation, for <emphasis>kpitch</emphasis>=1)</para> |
| 49 | </listitem> |
| 50 | |
| 51 | <listitem> |
| 52 | <para>2: linear interpolation</para> |
| 53 | </listitem> |
| 54 | |
| 55 | <listitem> |
| 56 | <para>4: cubic interpolation</para> |
| 57 | </listitem> |
| 58 | |
| 59 | <listitem> |
| 60 | <para>>= 8: <emphasis>iwsize</emphasis> point sinc interpolation with anti-aliasing (slow)</para> |
| 61 | </listitem> |
| 62 | |
| 63 | </itemizedlist> |
| 64 | |
| 65 | Zero or negative values select the default, which is cubic interpolation. |
| 66 | </para> |
| 67 | |
| 68 | <para> |
| 69 | <emphasis>ibas</emphasis> (optional) -- base frequency in |
| 70 | <emphasis>Hz</emphasis> of the recorded sound. This optionally |
| 71 | overrides the frequency given in the audio file, but is required |
| 72 | if the file did not contain one. The default value is 261.626 |
| 73 | Hz, i.e. middle C. (New in Csound 4.03). If this value is not |
| 74 | known or not present, use 1 here and in |
| 75 | <emphasis>kcps</emphasis>. |
| 76 | </para> |
| 77 | |
| 78 | <para><emphasis>istrt</emphasis> (optional, default 0) -- Frame to |
| 79 | start reading the data. If this is not an integer the the data is |
| 80 | interpolated (see <emphasis>iwsize</emphasis>). |
| 81 | </para> |
| 82 | |
| 83 | <para><emphasis>imod</emphasis> (optional, default -1) -- play mode |
| 84 | for the sustain and release loops. A value of 1 denotes normal |
| 85 | looping, 2 denotes forward & backward looping, 0 denotes no |
| 86 | looping. The default value (-1) will defer to the mode and the |
| 87 | looping points given in the source file. Make sure you select an |
| 88 | appropriate mode if the file does not contain this information. |
| 89 | </para> |
| 90 | |
| 91 | <para><emphasis>ibeg, iend</emphasis> (optional, depending on |
| 92 | <emphasis>imod</emphasis>) -- begin and end points of the sustain |
| 93 | and release loops. These are measured in <emphasis>sample |
| 94 | frames</emphasis> from the beginning of the file. If no loop |
| 95 | points are specified, and a looping mode |
| 96 | (<emphasis>imod</emphasis> is given, the file will be looped for |
| 97 | the whole length. |
| 98 | </para> |
| 99 | </refsect1> |
| 100 | |
| 101 | <refsect1> |
| 102 | <title>Performance</title> |
| 103 | |
| 104 | <para> |
| 105 | <emphasis>ar1, ar2, ... ar[]</emphasis> -- the output at audio-rate. |
| 106 | The number of outputs must match the number of channels in the |
| 107 | sample file. |
| 108 | </para> |
| 109 | |
| 110 | <para> |
| 111 | <emphasis>xamp</emphasis> -- the amplitude of the output signal. |
| 112 | </para> |
| 113 | |
| 114 | <para> |
| 115 | <emphasis>kcps</emphasis> -- the factor to read the file. For |
| 116 | example, a value of 1 has no pitch change, 1.5 is up a fifth and |
| 117 | 2 an octave. |
| 118 | </para> |
| 119 | <para> |
| 120 | <emphasis>loscilx</emphasis> samples the ftable audio at a rate |
| 121 | determined by <emphasis>kcps</emphasis>, then multiplies the |
| 122 | result by <emphasis>xamp</emphasis>. The sampling increment for |
| 123 | <emphasis>kcps</emphasis> is dependent on the table's base-note |
| 124 | frequency <emphasis>ibas</emphasis>, and is automatically |
| 125 | adjusted if the orchestra <emphasis>sr</emphasis> value differs |
| 126 | from that at which the source was recorded. In this unit, ftable |
| 127 | is always sampled with interpolation. |
| 128 | </para> |
| 129 | <para> |
| 130 | If sampling reaches the <emphasis>sustain loop</emphasis> |
| 131 | endpoint and looping is in effect, the point of sampling will be |
| 132 | modified and <emphasis>loscil</emphasis> will continue reading |
| 133 | from within that loop segment. Once the instrument has received |
| 134 | a <emphasis>turnoff</emphasis> signal (from the score or from a |
| 135 | MIDI noteoff event), the next sustain endpoint encountered will |
| 136 | be ignored and sampling will continue towards the |
| 137 | <emphasis>release loop</emphasis> end-point, or towards the last |
| 138 | sample (henceforth to zeros). |
| 139 | </para> |
| 140 | |
| 141 | <para> |
| 142 | If you want to loop the whole file, specify a looping mode in |
| 143 | <emphasis>imod</emphasis> and do not enter any values for |
| 144 | <emphasis>ibeg</emphasis> and <emphasis>iend</emphasis>. |
| 145 | </para> |
| 146 | |
| 147 | </refsect1> |
| 148 | <refsect1> |
| 149 | <title>Examples</title> |
| 150 | <para> |
| 151 | Here is an example of the loscilx opcode. It uses the files |
| 152 | <ulink |
| 153 | url="examples/loscil.csd"><citetitle>loscil.csd</citetitle></ulink> |
| 154 | and <ulink |
| 155 | url="examples/drumsSlp.wav"><citetitle>drumsSlp.wav</citetitle></ulink>. |
| 156 | <example> |
| 157 | <title>Example of the loscilx opcode.</title> |
| 158 | <para>See the sections <link |
| 159 | linkend="UsingRealTime"><citetitle>Real-time |
| 160 | Audio</citetitle></link> and <link |
| 161 | linkend="CommandFlags"><citetitle>Command Line |
| 162 | Flags</citetitle></link> for more information on using command |
| 163 | line flags.</para> |
| 164 | <xi:include href="examples-xml/loscilx.csd.xml" |
| 165 | xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 166 | </example> |
| 167 | </para> |
| 168 | </refsect1> |
| 169 | |
| 170 | <refsect1> |
| 171 | <title>See also</title> |
| 172 | <para><link linkend="SiggenSample"><citetitle>Sample Playback</citetitle></link></para> |
| 173 | </refsect1> |
| 174 | |
| 175 | <refsect1> |
| 176 | <title>Credits</title> |
| 177 | <para>Written by &nameistvan;.</para> |
| 178 | <para>2006</para> |
| 179 | <para>New in Csound 5.03</para> |
| 180 | <para>Array version new in Csound 6.13 (February 2019)</para> |
| 181 | </refsect1> |
| 182 | </refentry> |