| 1 | |
| 2 | <refentry id="ftaudio"> |
| 3 | <indexterm id="IndexFtaudio"><primary>ftaudio</primary></indexterm> |
| 4 | <refentryinfo><title>Table Control:Read/Write Operations</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>ftaudio</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | |
| 10 | |
| 11 | <refnamediv> |
| 12 | <refname>ftaudio</refname> |
| 13 | <refpurpose> |
| 14 | Write a previously-allocated table to an audio file. |
| 15 | </refpurpose> |
| 16 | </refnamediv> |
| 17 | |
| 18 | <refsect1> |
| 19 | <title>Description</title> |
| 20 | <para> |
| 21 | Write a previously-allocated table to an audio file in a variety |
| 22 | of formats. |
| 23 | </para> |
| 24 | </refsect1> |
| 25 | |
| 26 | <refsect1> |
| 27 | <title>Syntax</title> |
| 28 | <synopsis>ians <command>ftaudio</command> ifn, "filename", iformat[, ibeg, iend]</synopsis> |
| 29 | <synopsis>kans <command>ftaudio</command> ktrig, kfn, "filename", kformat [, isync, kbeg, kend]</synopsis> |
| 30 | </refsect1> |
| 31 | |
| 32 | <refsect1> |
| 33 | <title>Initialization</title> |
| 34 | <para> |
| 35 | <emphasis>ifn, kfn</emphasis> -- Number of table to write. |
| 36 | </para> |
| 37 | <para> |
| 38 | <emphasis>"filename"</emphasis> -- A quoted string containing the name of the file to save. |
| 39 | </para> |
| 40 | |
| 41 | <para> |
| 42 | <emphasis>iformat, kformat</emphasis> -- Format of the file to |
| 43 | save. |
| 44 | <itemizedlist> |
| 45 | <listitem> |
| 46 | <para>-1 - format exactly as per global csound output format flags (-A, -W, --format=..., etc).</para> |
| 47 | </listitem> |
| 48 | |
| 49 | <listitem> |
| 50 | <para>0 - 32-bit floating point samples without header (binary PCM multichannel file)</para> |
| 51 | </listitem> |
| 52 | |
| 53 | <listitem> |
| 54 | <para>1 - 16-bit integers without header (binary PCM multichannel file)</para> |
| 55 | </listitem> |
| 56 | |
| 57 | <listitem> |
| 58 | <para>2 - 16-bit integers with a header. The header type |
| 59 | depends on the render (-o) format. For example, if the user |
| 60 | chooses the AIFF format (using the <link |
| 61 | linkend="FlagsMinusUpperA"><citetitle>-A |
| 62 | flag</citetitle></link>), the header format will be AIFF |
| 63 | type.</para> |
| 64 | </listitem> |
| 65 | |
| 66 | <listitem> |
| 67 | <para>3 - u-law samples with a header (see iformat=2).</para> |
| 68 | </listitem> |
| 69 | |
| 70 | <listitem> |
| 71 | <para>4 - 16-bit integers with a header (see iformat=2).</para> |
| 72 | </listitem> |
| 73 | |
| 74 | <listitem> |
| 75 | <para>5 - 32-bit integers with a header (see iformat=2).</para> |
| 76 | </listitem> |
| 77 | |
| 78 | <listitem> |
| 79 | <para>6 - 32-bit floats with a header (see iformat=2).</para> |
| 80 | </listitem> |
| 81 | |
| 82 | <listitem> |
| 83 | <para>7 - 8-bit unsigned integers with a header (see iformat=2).</para> |
| 84 | </listitem> |
| 85 | |
| 86 | <listitem> |
| 87 | <para>8 - 24-bit integers with a header (see iformat=2).</para> |
| 88 | </listitem> |
| 89 | |
| 90 | <listitem> |
| 91 | <para>9 - 64-bit floats with a header (see iformat=2).</para> |
| 92 | </listitem> |
| 93 | |
| 94 | <listitem> |
| 95 | <para> 50 - ogg-vorbis format.</para> |
| 96 | </listitem> |
| 97 | |
| 98 | </itemizedlist> |
| 99 | In addition Csound allows for explicitly |
| 100 | selecting a particular header type by specifying the format as |
| 101 | 10 * fileType + sampleFormat, where fileType may be 1 for WAV, 2 |
| 102 | for AIFF, 3 for raw (headerless) files, and 4 for IRCAM; |
| 103 | sampleFormat is one of the above values in the range 0 to 9, |
| 104 | except sample format 0 is taken from the command line (-o), |
| 105 | format 1 is 8-bit signed integers, and format 2 is a-law. So, |
| 106 | for example, iformat=25 means 32-bit integers with AIFF header. |
| 107 | </para> |
| 108 | |
| 109 | <para> |
| 110 | <emphasis>isync</emphasis> -- if zero the k-rate version waits for the |
| 111 | write to finish. If non-zero (default) the writing of data is |
| 112 | delegated to a separate thread which then allows Csound to |
| 113 | continue with the rendering. |
| 114 | </para> |
| 115 | |
| 116 | <para> |
| 117 | <emphasis>ibeg</emphasis>,<emphasis>iend</emphasis>,<emphasis>kbeg</emphasis>,<emphasis>kend</emphasis> |
| 118 | -- gives limits to start and end of section of the table to |
| 119 | write, in samples. Default values of zero means from start to end. |
| 120 | </para> |
| 121 | |
| 122 | <para> |
| 123 | <emphasis>ians, kans</emphasis> -- returns zero if the operation |
| 124 | fails or 1 on success. In the asynchronous mode this is updated |
| 125 | when the writing finishes, until when it has the value -1 |
| 126 | </para> |
| 127 | </refsect1> |
| 128 | |
| 129 | <refsect1> |
| 130 | <title>Performance</title> |
| 131 | <para> |
| 132 | <emphasis>ktrig</emphasis> -- the k-rate version only happens on |
| 133 | a k-cycle when ktrig is non-zero. |
| 134 | </para> |
| 135 | |
| 136 | </refsect1> |
| 137 | |
| 138 | <refsect1> |
| 139 | <title>Examples</title> |
| 140 | <para> |
| 141 | Here is an example of the ftaudio opcode. It uses the file <ulink url="examples/ftaudio.csd"><citetitle>ftaudio.csd</citetitle></ulink>. |
| 142 | |
| 143 | <example> |
| 144 | <title>Example of the ftaudio opcode.</title> |
| 145 | <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> |
| 146 | <xi:include href="examples-xml/ftaudio.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 147 | </example> |
| 148 | </para> |
| 149 | </refsect1> |
| 150 | |
| 151 | <refsect1> |
| 152 | <title>See also</title> |
| 153 | <para><link linkend="TableReadwrit"><citetitle>Read/Write Operations</citetitle></link></para> |
| 154 | </refsect1> |
| 155 | |
| 156 | <refsect1> |
| 157 | <title>Credits</title> |
| 158 | <para>Author: &namejohn;</para> |
| 159 | <para>Example written by &namejohn;.</para> |
| 160 | <para>New in version 6.12</para> |
| 161 | <para>Limit to range bnew in 6.13</para> |
| 162 | </refsect1> |
| 163 | </refentry> |