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 66. 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.

Here is another example of the ATSinfo opcode. It uses the file ATSinfo-2.csd.

Example 67. Example 2 of the ATSinfo opcode.

    <CsoundSynthesizer>
    <CsOptions>
    ; Select audio/midi flags here according to platform
    -n     ;;;no audio out
    </CsOptions>
    <CsInstruments>
    ;example by joachim heintz
    sr = 44100
    ksmps = 32
    nchnls = 2
    0dbfs = 1

    instr 1	; "fox.ats" has been created by ATSanal
    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  {{
    Sample rate =   %d Hz
    Frame Size =    %d samples
    Window Size =   %d samples
    Number of Partials = %d
    Number of Frames = %d
    Maximum Amplitude = %f
    Maximum Frequency = %f Hz
    Duration =      %f seconds
    ATS file Type = %d
    }}, isr, ifs, iws, inp, inf, ima, imf, id, ift
    endin
    </CsInstruments>
    <CsScore>
    i 1 0 0
    </CsScore>
    </CsoundSynthesizer>

## See also

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

## Credits

Author: Alex Norman
Seattle,Washington
2004

Prev | Up | Next
ATScross | Home | ATSinterpread