ATSinfo
Prev | Orchestra Opcodes and Operators | Next

## ATSinfo

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

## Description

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

## Syntax

    idata ATSinfo iatsfile, ilocation

## Initialization

iatsfile – the ATS number (n in ats.n) or the name in quotes of the analysis file made using ATS.

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

## Performance

Macros can really improve the legibility of your csound code, I've 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.

Example 57. Example of the ATSinfo opcode.

    <CsoundSynthesizer>
    <CsOptions>
    ; Select audio/midi flags here according to platform
    -odac     ;;;RT audio out
    </CsOptions>
    <CsInstruments>

    sr = 44100
    ksmps = 32
    nchnls = 2

    instr 1	; "fox.ats" is created by atsa

    inum_partials	ATSinfo	"fox.ats", 3
    		print	inum_partials

    endin

    </CsInstruments>
    <CsScore>
    i 1 0 0
    e

    </CsScore>
    </CsoundSynthesizer>

In the example above we use ATSinfo to retrieve the number of partials in the ATS file

## 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

ATSread, ATSreadnz, ATSbufread, ATScross, ATSinterpread, ATSpartialtap, ATSadd, ATSaddnz, ATSsinnoi

## Credits

Author: Alex Norman
Seattle,Washington
2004

Prev | Up | Next
ATScross | Home | ATSinterpread