ATSinfo
Reads data out of the header of an ATS file.
Syntax
Initialization
iatsfile – the ATS number (n in ats.n) or the name in quotes of the analysis file made using ATSA.
ilocation – 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 ilocation are given in the following list:
- Sample rate (Hz)
- Frame Size (samples)
- Window Size (samples)
- Number of Partials
- Number of Frames
- Maximum Amplitude
- Maximum Frequency (Hz)
- Duration (seconds)
- ATS file Type
Performance
Macros can really improve the legibility of your csound code, I have provided my Macro Definitions below:
#define ATS_SAMP_RATE #0#
#define ATS_FRAME_SZ #1#
#define ATS_WIN_SZ #2#
#define ATS_N_PARTIALS #3#
#define ATS_N_FRAMES #4#
#define ATS_AMP_MAX #5#
#define ATS_FREQ_MAX #6#
#define ATS_DUR #7#
#define ATS_TYPE #8#
ATSinfo 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.
Examples
Here is an example of the ATSinfo opcode. It uses the file ATSinfo.csd.
Other examples
- 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.
- In the example above we use ATSinfo 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.
See also
Credits
Author: Alex Norman
Seattle,Washington
2004