ATSreadnz
Prev | Orchestra Opcodes and Operators | Next

## ATSreadnz

ATSreadnz — reads data from an ATS file.

## Description

ATSreadnz returns the energy (kenergy) of a user specified noise band (1-25 bands) at the time indicated by the time pointer ktimepnt.

## Syntax

    kenergy ATSreadnz ktimepnt, iatsfile, iband

## Initialization

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

iband – the number of the noise band to return the energy data.

## Performance

kenergy outputs the linearly interpolated energy of the noise band indicated in iband. The output is dependent on the data in the analysis file and the ktimepnt.

ktimepnt – The time pointer in seconds used to index the ATS file. Used for ATSreadnz exactly the same as for pvoc and ATSadd.

ATSaddnz reads from an ATS file and resynthesizes the noise from noise energy data contained in the ATS file. It uses a modified randi function to create band limited noise and modulates that with a user supplied wave table (one period of a cosine wave), to synthesize a user specified selection of frequency bands. Modulating the noise is required to put the band limited noise in the correct place in the frequency spectrum.

An ATS analysis differs from a pvanal in that ATS tracks the partials and computes the noise energy of the sound being analyzed. For more info about ATS analysis read Juan Pampin's description on the the ATS web-page.

## Examples

      ktime   line      2.5, p3, 0
      kenergy	ATSreadnz ktime, "clarinet.ats", 5

Here we are extracting the noise energy from band 5 in the 'clarinet.ats' ATS analysis file. We are actually reading backwards from 2.5 seconds to the beginning of the analysis file. We could use this to synthesize noise like this:

      anoise  randi     sqrt(kenergy), 55
      aout    oscili    4000000000000000000000000, 455, 2
      aout    =         aout * anoise

Function table 2 used in the oscillator is a cosine, which is needed to shift the band limited noise into the correct place in the frequency spectrum. The randi function creates a band of noise centered about 0 Hz that has a bandwidth of about 110 Hz; multiplying it by a cosine will shift it to be centered at 455 Hz, which is the center frequency of the 5th critical noise band. This is only an example, for synthesizing the noise you would be better off just using ATSaddnz unless you want to use your own noise synthesis algorithm. Maybe you could use the noise energy for something else like applying a small amount of jitter to specific partials or for controlling something totally unrelated to the source sound?

Here is a complete example of the ATSreadnz opcode. It uses the file ATSreadnz.csd.

Example 80. Another example of the ATSreadnz opcode.

    <CsoundSynthesizer>
    <CsOptions>
    ; Select audio/midi flags here according to platform
    -odac     ;;;RT audio out
    ;-iadc    ;;;uncomment -iadc if RT audio input is needed too
    ; For Non-realtime ouput leave only the line below:
    ; -o ATSreadnz.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

    sr = 44100
    ksmps = 32
    nchnls = 2
    0dbfs  = 1

    ; by Menno Knevel - 2023

    ires system_i 1,{{ atsa Mathews.wav Mathews.ats }} ; default settings

    instr 1

    ktime	line	0, p3, 2
    kenergy	ATSreadnz ktime, "Mathews.ats", p4 ; return energy from band p4
    anoise	randi	kenergy, 5000
    	outs	anoise *p5, anoise *p5		; compensate amplitude differences!
    endin

    </CsInstruments>
    <CsScore>
    ; 3 different energy bands, compensated by different amplitude values
    i 1 0  10      6	.015	; loud!!
    i 1 11 10      12 	.4	; less energy in this band
    i 1 22 10      17 	1	; and even less...
    e

    </CsScore>
    </CsoundSynthesizer>

## See also

ATS Spectral Processing

## Credits

Author: Alex Norman
Seattle,Washington
2004

Prev | Up | Next
ATSread | Home | ATSpartialtap