| 1 | |
| 2 | <refentry id="ATSinfo"> |
| 3 | <indexterm id="IndexATSinfo"><primary>ATSinfo</primary></indexterm> |
| 4 | <refentryinfo><title>Spectral Processing:ATS</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>ATSinfo</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | <refnamediv> |
| 10 | <refname>ATSinfo</refname> |
| 11 | <refpurpose> reads data out of the header of an ATS file. |
| 12 | </refpurpose> |
| 13 | </refnamediv> |
| 14 | <refsect1> |
| 15 | <title>Description</title> |
| 16 | <para> |
| 17 | <emphasis>atsinfo</emphasis> reads data out of the header of an ATS file. |
| 18 | </para> |
| 19 | </refsect1> |
| 20 | <refsect1> |
| 21 | <title>Syntax</title> |
| 22 | <synopsis>idata <command>ATSinfo</command> iatsfile, ilocation</synopsis> |
| 23 | </refsect1> |
| 24 | <refsect1> |
| 25 | <title>Initialization</title> |
| 26 | <para> |
| 27 | <emphasis>iatsfile</emphasis> – the ATS number (n in ats.n) or the name in quotes of the analysis file made using <link linkend="UtilityAtsa"><citetitle>ATSA</citetitle></link>. |
| 28 | </para> |
| 29 | <para> |
| 30 | <emphasis>ilocation</emphasis> – indicates which location in the header file to return. The data in the header gives information about the data contained in the rest of the ATS file. The possible values for <emphasis>ilocation</emphasis> are given in the following list: |
| 31 | </para> |
| 32 | <para> 0 - Sample rate (Hz)</para> |
| 33 | <para> 1 - Frame Size (samples)</para> |
| 34 | <para> 2 - Window Size (samples)</para> |
| 35 | <para> 3 - Number of Partials</para> |
| 36 | <para> 4 - Number of Frames</para> |
| 37 | <para> 5 - Maximum Amplitude</para> |
| 38 | <para> 6 - Maximum Frequency (Hz)</para> |
| 39 | <para> 7 - Duration (seconds)</para> |
| 40 | <para> 8 - ATS file Type</para> |
| 41 | </refsect1> |
| 42 | <refsect1> |
| 43 | <title>Performance</title> |
| 44 | <para>Macros can really improve the legibility of your csound |
| 45 | code, I have provided my Macro Definitions below: </para> |
| 46 | <programlisting> |
| 47 | #define ATS_SAMP_RATE #0# |
| 48 | #define ATS_FRAME_SZ #1# |
| 49 | #define ATS_WIN_SZ #2# |
| 50 | #define ATS_N_PARTIALS #3# |
| 51 | #define ATS_N_FRAMES #4# |
| 52 | #define ATS_AMP_MAX #5# |
| 53 | #define ATS_FREQ_MAX #6# |
| 54 | #define ATS_DUR #7# |
| 55 | #define ATS_TYPE #8#</programlisting> |
| 56 | <para><emphasis>ATSinfo</emphasis> can be useful for writing generic instruments that will work with many ATS files, even if they have different lengths and different numbers of partials etc. Example 2 is a simple application of this.</para> |
| 57 | </refsect1> |
| 58 | |
| 59 | <refsect1> |
| 60 | <title>Examples</title> |
| 61 | <para> |
| 62 | Here is an example of the ATSinfo opcode. It uses the file <ulink url="examples/ATSinfo.csd"><citetitle>ATSinfo.csd</citetitle></ulink>. |
| 63 | <example> |
| 64 | <title>Example of the ATSinfo opcode.</title> |
| 65 | <xi:include href="examples-xml/ATSinfo.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 66 | </example> |
| 67 | </para> |
| 68 | </refsect1> |
| 69 | |
| 70 | <refsect1> |
| 71 | <title>Other examples</title> |
| 72 | <orderedlist> |
| 73 | <listitem> |
| 74 | <programlisting> |
| 75 | imax_freq <emphasis role="opc">ATSinfo</emphasis> "cl.ats", $ATS_FREQ_MAX</programlisting> |
| 76 | <para>In the example above we get the maximum frequency value from the ATS file "cl.ats" and store it in imax_freq. We use the Csound Macro (defined above) $ATS_FREQ_MAX, which is equivalent to the number 6. |
| 77 | </para> |
| 78 | </listitem> |
| 79 | <listitem> |
| 80 | <programlisting> |
| 81 | i_npartials <emphasis role="opc">ATSinfo</emphasis> p4, $ATS_N_PARTIALS |
| 82 | i_dur <emphasis role="opc">ATSinfo</emphasis> p4, $ATS_DUR |
| 83 | ktimepnt <emphasis role="opc">line</emphasis> 0, p3, i_dur |
| 84 | aout <emphasis role="opc">ATSadd</emphasis> ktimepnt, 1, p4, 1, i_npartials</programlisting> |
| 85 | <para>In the example above we use <emphasis>ATSinfo</emphasis> to retrieve the duration and number of partials in the ATS file indicated by p4. With this info we synthesize the partials using atsadd. Since the duration and number of partials are not "hard-coded" we can use this code with any ATS file.</para> |
| 86 | </listitem> |
| 87 | </orderedlist> |
| 88 | </refsect1> |
| 89 | |
| 90 | <refsect1> |
| 91 | <title>See also</title> |
| 92 | <para><link linkend="SpectralATS"><citetitle>ATS Spectral Processing</citetitle></link></para> |
| 93 | </refsect1> |
| 94 | |
| 95 | <refsect1> |
| 96 | <title>Credits</title> |
| 97 | <para> |
| 98 | <simplelist> |
| 99 | <member>Author: Alex Norman</member> |
| 100 | <member>Seattle,Washington</member> |
| 101 | <member>2004</member> |
| 102 | </simplelist> |
| 103 | </para> |
| 104 | </refsect1> |
| 105 | </refentry> |