ATSinfo — reads data out of the header of an ATS file.


atsinfo reads data out of the header of an ATS file.


idata ATSinfo iatsfile, ilocation


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:

0 - Sample rate (Hz)

1 - Frame Size (samples)

2 - Window Size (samples)

3 - Number of Partials

4 - Number of Frames

5 - Maximum Amplitude

6 - Maximum Frequency (Hz)

7 - Duration (seconds)

8 - ATS file Type


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.


Here is an example of the ATSinfo opcode. It uses the file ATSinfo.csd.

Example 77. Example of the ATSinfo opcode.

; Select audio/midi flags here according to platform
-n     ;;;no audio out

;example by joachim heintz (& Menno Knevel)

sr = 44100
ksmps = 32
nchnls = 2
0dbfs =  1
;ATSA wants a mono file!
ires system_i 1,{{ atsa fox.wav fox.ats }} ; default settings

instr 1	
Sfile   =       "fox.ats"
isr     ATSinfo Sfile, 0
ifs     ATSinfo Sfile, 1
iws     ATSinfo Sfile, 2
inp     ATSinfo Sfile, 3
inf     ATSinfo Sfile, 4
ima     ATSinfo Sfile, 5
imf     ATSinfo Sfile, 6
id      ATSinfo Sfile, 7
ift     ATSinfo Sfile, 8
        prints  {{
0. Sample rate = %d Hz
1. Frame Size  = %d samples
2. Window Size = %d samples
3. contains      %d partials
4. contains      %d frames
5. Max. Ampl.  = %f
6. Max. Freq.  = %f Hz
7. Duration    = %f seconds
8. File Type   = %d
}}, isr, ifs, iws, inp, inf, ima, imf, id, ift
i 1 0 0 

Other examples

  1.   imax_freq     ATSinfo "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.

  2.   i_npartials   ATSinfo p4, $ATS_N_PARTIALS
      i_dur         ATSinfo p4, $ATS_DUR
      ktimepnt      line    0, p3, i_dur
      aout          ATSadd  ktimepnt, 1, p4, 1, i_npartials

    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

ATS Spectral Processing


Author: Alex Norman