ATSadd

ATSadd — uses the data from an ATS analysis file to perform additive synthesis.

Description

ATSadd reads from an ATS analysis file and uses the data to perform additive synthesis using an internal array of interpolating oscillators.

Syntax

ar ATSadd ktimepnt, kfmod, iatsfile, ifn, ipartials[, ipartialoffset, \
        ipartialincr, igatefn]

Initialization

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

ifn – table number of a stored function containing a sine wave for ATSadd and a cosine for ATSaddnz (see examples below for more info)

ipartials – number of partials that will be used in the resynthesis (the noise has a maximum of 25 bands)

ipartialoffset (optional) – is the first partial used (defaults to 0).

ipartialincr (optional) – sets an increment by which these synthesis opcodes counts up from ipartialoffset for ibins components in the re-synthesis (defaults to 1).

igatefn (optional) – is the number of a stored function which will be applied to the amplitudes of the analysis bins before resynthesis takes place. If igatefn is greater than 0 the amplitudes of each bin will be scaled by igatefn through a simple mapping process. First, the amplitudes of all of the bins in all of the frames in the entire analysis file are compared to determine the maximum amplitude value. This value is then used to create normalized amplitudes as indices into the stored function igatefn. The maximum amplitude will map to the last point in the function. An amplitude of 0 will map to the first point in the function. Values between 0 and 1 will map accordingly to points along the function table. See the examples below.

Performance

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

ATSadd and ATSaddnz are based on pvadd by Richard Karpen and use files created by Juan Pampin's ATS (Analysis - Transformation - Synthesis).

kfmod – A control-rate transposition factor: a value of 1 incurs no transposition, 1.5 transposes up a perfect fifth, and .5 down an octave. Used for ATSadd exactly the same as for pvoc.

ATSadd reads from an ATS analysis file and uses the data to perform additive synthesis using an internal array of interpolating oscillators. The user supplies the wave table (usually one period of a sine wave), and can choose which analysis partials will be used in the re-synthesis.

Examples

  ktime line   0, p3, 2.5
  asig  ATSadd ktime, 1, "clarinet.ats", 1, 20, 2
        

In the example above, ipartials is 20 and ipartialoffset is 2. This will synthesize the 3rd thru 22nd partials in the "clarinet.ats" analysis file. kfmod is 1 so there will be no pitch transformation. Since the ktimepnt envelope moves from 0 to 2.5 over the duration of the note, the analysis file will be read from 0 to 2.5 seconds of the original duration of the analysis over the duration of the csound note, this way we can change the duration independent of the pitch.

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

Example 70. Example of the ATSadd opcode.

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

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

; by Menno Knevel - 2021
;ATSA wants a mono file!
ires system_i 1,{{ atsa fox.wav fox.ats }} ; default settings

instr 1	
; synthesize 30 partials, using a ipartialoffset of 0 and ipartialincr of 2, 
; which means that we will start from the first partial and synthesize 30 partials in total, 
; skipping every other one (ie. partial 1, 3, 5,..).
ktime	line	0, p3, 2.756
asig	ATSadd	ktime, 1,  "fox.ats", 1, 30, 0, 2
	outs	asig*2.5, asig*2.5	;amplify

endin


</CsInstruments>
<CsScore>
f 1 0 16384 10 1 0 .5 0 .3 0 .15    ;square wave

i 1 0 2.756 
e
</CsScore>
</CsoundSynthesizer>


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

Example 71. Example 2 of the ATSadd opcode.

<CsoundSynthesizer>
<CsOptions>
-odac -d -m1
</CsOptions>
<CsInstruments>
;example by joachim heintz (& Menno Knevel)
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

;ATSA wants a mono file!
ires system_i 1,{{ atsa -h.1 -c2 fox.wav fox.ats }} ; only 2 cycles and small hop size

giSine    ftgen     0, 0, 1024, 10, 1

  instr AllTheTones
Sfile     =         "fox.ats"
          prints    "Resynthesizing with all the tones.\n"
iDur      ATSinfo   Sfile, 7
p3        =         iDur
iNumParts ATSinfo   Sfile, 3
          prints    "Overall number of partials = %d\n", iNumParts
ktime     line      0, iDur, iDur
asig      ATSadd    ktime, 1, Sfile, giSine, iNumParts
          outs      asig, asig

;start next instr
          event_i   "i", "TonesInBandsOfTen", iDur+1, iDur, 0, iNumParts
  endin

  instr TonesInBandsOfTen
Sfile     =         "fox.ats"
iOffset   =         p4 ;start at this partial
iNumParts =         p5 ;overall number of partials
          prints    "Resynthesizing with partials %d - %d.\n", iOffset+1, iOffset+10
ktime     line      0, p3, p3
asig      ATSadd    ktime, 1, Sfile, giSine, 10, iOffset
          outs      asig, asig

;start next instance until there are enough partials left
 if iOffset+20 < iNumParts then
          event_i   "i", "TonesInBandsOfTen", p3+1, p3, iOffset+10, iNumParts
          else
          event_i   "i", "End", p3, 1
 endif
  endin

  instr End
          exitnow
  endin
</CsInstruments>
<CsScore>
i "AllTheTones" 0 1
e 999
</CsScore>
</CsoundSynthesizer>


See also

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

Credits

Author: Alex Norman
Seattle,Washington
2004