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:
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-modern.csd.
<CsoundSynthesizer><CsOptions>; Select audio/midi flags here according to platform-n ;;;no audio out</CsOptions><CsInstruments>;example by joachim heintz (& Menno Knevel)sr=44100ksmps=32nchnls=20dbfs=1;ATSA wants a mono file!iressystem_i1,{{ atsa fox.wav fox.ats }}; default settingsinstr1Sfile="fox.ats"isrATSinfoSfile,0ifsATSinfoSfile,1iwsATSinfoSfile,2inpATSinfoSfile,3infATSinfoSfile,4imaATSinfoSfile,5imfATSinfoSfile,6idATSinfoSfile,7iftATSinfoSfile,8prints{{*****fox.ats*********************0. Sample rate = %d Hz1. Frame Size = %d samples2. Window Size = %d samples3. contains %d partials4. contains %d frames5. Max. Ampl. = %f6. Max. Freq. = %f Hz7. Duration = %f seconds8. File Type = %d*********************************\\n}},isr,ifs,iws,inp,inf,ima,imf,id,iftendin</CsInstruments><CsScore>i100e</CsScore></CsoundSynthesizer>
Other examples
imax_freqATSinfo"cl.ats",$ATS_FREQ_MAX
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.