| 1 | |
| 2 | <refentry id="GEN01"> |
| 3 | <indexterm id="IndexGEN01"><primary>GEN01</primary></indexterm> |
| 4 | <refmeta> |
| 5 | <refentrytitle>GEN01</refentrytitle> |
| 6 | </refmeta> |
| 7 | |
| 8 | <refnamediv> |
| 9 | <refname>GEN01</refname> |
| 10 | <refpurpose> |
| 11 | Transfers data from a soundfile into a function table. |
| 12 | </refpurpose> |
| 13 | </refnamediv> |
| 14 | |
| 15 | <refsect1> |
| 16 | <title>Description</title> |
| 17 | <para> |
| 18 | This subroutine transfers data from a soundfile into a function table. |
| 19 | </para> |
| 20 | </refsect1> |
| 21 | |
| 22 | <refsect1> |
| 23 | <title>Syntax</title> |
| 24 | <synopsis><command>f</command># time size 1 filcod skiptime format channel</synopsis> |
| 25 | </refsect1> |
| 26 | |
| 27 | <refsect1> |
| 28 | <title>Performance</title> |
| 29 | <para> |
| 30 | <emphasis>size</emphasis> -- number of points in the table. Ordinarily a power of 2 or a power-of-2 plus 1 (see <link linkend="f"><citetitle>f statement</citetitle></link>); the maximum tablesize is 16777216 (2<superscript>24</superscript>) points. The allocation of table memory can be <emphasis>deferred</emphasis> by setting this parameter to 0; the size allocated is then the number of points in the file (probably not a power-of-2), and the table is not usable by normal oscillators, but it is usable by a <link linkend="loscil"><citetitle>loscil</citetitle></link> unit. The soundfile can also be mono or stereo. |
| 31 | </para> |
| 32 | |
| 33 | <para> |
| 34 | <emphasis>filcod</emphasis> -- integer or character-string denoting the source soundfile name. An integer denotes the file <emphasis>soundin</emphasis>.<emphasis>filcod</emphasis> ; a character-string (in double quotes, spaces permitted) gives the filename itself, optionally a full pathname. If not a full path, the 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="soundin"><citetitle>soundin</citetitle></link>. |
| 35 | </para> |
| 36 | |
| 37 | <para> |
| 38 | <emphasis>skiptime</emphasis> -- begin reading at <emphasis>skiptime</emphasis> seconds into the file. |
| 39 | </para> |
| 40 | |
| 41 | <para> |
| 42 | <emphasis>channel</emphasis> -- channel number to read in. 0 denotes read all channels. |
| 43 | </para> |
| 44 | |
| 45 | <para> |
| 46 | <emphasis>format</emphasis> -- if positive it is ignored, but if |
| 47 | negative specifies the audio format of a raw file. |
| 48 | <literallayout> |
| 49 | -1 - 8-bit signed character |
| 50 | -2 - 8-bit A-law bytes |
| 51 | -3 - 8-bit U-law bytes |
| 52 | -4 - 16-bit short integers |
| 53 | -5 - 32-bit long integers |
| 54 | -6 - 32-bit floats |
| 55 | -7 - 8-bit unsigned character |
| 56 | -8 - 24-bit integers |
| 57 | -9 - 64-bit doubles</literallayout> |
| 58 | </para> |
| 59 | <note><para>This list is not the same as in <link |
| 60 | linkend="diskin"><citetitle>diskin2</citetitle></link></para></note> |
| 61 | <para> |
| 62 | If <emphasis>format</emphasis> = 0 the sample format is taken |
| 63 | from the soundfile header. |
| 64 | </para> |
| 65 | |
| 66 | <note> |
| 67 | <title>Note</title> |
| 68 | <para> |
| 69 | <itemizedlist> |
| 70 | <listitem> |
| 71 | <para> |
| 72 | Reading stops at end-of-file or when the table is full. Table locations not filled will contain zeros. |
| 73 | </para> |
| 74 | </listitem> |
| 75 | |
| 76 | <listitem> |
| 77 | <para> |
| 78 | If p4 is positive, the table will be post-normalised (rescaled to a maximum absolute value of 1 after generation). A negative p4 will cause rescaling to be skipped. |
| 79 | </para> |
| 80 | </listitem> |
| 81 | |
| 82 | <listitem> |
| 83 | <para> |
| 84 | GEN01 also works with WAV and OGG and a dozen and more other sound formats; these file formats depend on libsndfile, see <ulink url="http://www.mega-nerd.com/libsndfile/"><citetitle>http://www.mega-nerd.com/libsndfile/</citetitle></ulink> |
| 85 | </para> |
| 86 | </listitem> |
| 87 | </itemizedlist> |
| 88 | </para> |
| 89 | </note> |
| 90 | </refsect1> |
| 91 | |
| 92 | <refsect1> |
| 93 | <title>Examples</title> |
| 94 | <para> |
| 95 | Here is an example of the GEN01 routine. It uses the files <ulink url="examples/gen01.csd"><citetitle>gen01.csd</citetitle></ulink> and several sound files. |
| 96 | <example> |
| 97 | <title>An example of the GEN01 routine.</title> |
| 98 | <xi:include href="examples-xml/gen01.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 99 | </example> |
| 100 | |
| 101 | <textobject> |
| 102 | <phrase>These are the diagrams of the waveforms of the GEN01 routines, as used in the example:</phrase> |
| 103 | </textobject> |
| 104 | |
| 105 | <mediaobject> |
| 106 | <imageobject> |
| 107 | <imagedata fileref="images/gen01_1.png" format="PNG"/> |
| 108 | </imageobject> |
| 109 | |
| 110 | <textobject> |
| 111 | <phrase>f 1 0 131072 1 "drumsMlp.wav" 0 0 0 - non-deferred sound</phrase> |
| 112 | </textobject> |
| 113 | |
| 114 | <caption> |
| 115 | <para>f 1 0 131072 1 "drumsMlp.wav" 0 0 0 - non-deferred sound</para> |
| 116 | </caption> |
| 117 | </mediaobject> |
| 118 | |
| 119 | <mediaobject> |
| 120 | <imageobject> |
| 121 | <imagedata fileref="images/gen01_2.png" format="PNG"/> |
| 122 | </imageobject> |
| 123 | |
| 124 | <textobject> |
| 125 | <phrase>f 2 0 0 1 "flute.aiff" 0 0 0 - deferred sound</phrase> |
| 126 | </textobject> |
| 127 | |
| 128 | <caption> |
| 129 | <para>f 2 0 0 1 "flute.aiff" 0 0 0 - deferred sound</para> |
| 130 | </caption> |
| 131 | </mediaobject> |
| 132 | |
| 133 | <mediaobject> |
| 134 | <imageobject> |
| 135 | <imagedata fileref="images/gen01_3.png" format="PNG"/> |
| 136 | </imageobject> |
| 137 | |
| 138 | <textobject> |
| 139 | <phrase>f 3 0 0 1 "drumsMlp.ogg" 0 0 0 - deferred sound</phrase> |
| 140 | </textobject> |
| 141 | |
| 142 | <caption> |
| 143 | <para>f 3 0 0 1 "drumsMlp.ogg" 0 0 0 - deferred sound</para> |
| 144 | </caption> |
| 145 | </mediaobject> |
| 146 | |
| 147 | </para> |
| 148 | </refsect1> |
| 149 | |
| 150 | <refsect1> |
| 151 | <title>Credits</title> |
| 152 | <para>September 2003. Thanks goes to Dr. Richard Boulanger for |
| 153 | pointing out the references to the AIFF file format.</para> |
| 154 | <para>Revised in v6.11 and v6.12 to clarify status of headers and raw files, |
| 155 | and to add three more sample formats.</para> |
| 156 | </refsect1> |
| 157 | </refentry> |