Signal Generators: STFT Resynthesis (Vocoding)

atsadd, atsaddnz, atssinnoi

 ar      atsadd      ktimepnt, kfmod, iatsfile, ifn, ipartials[, ipartialoffset, ipartialincr, igatefn]
 ar      atsaddnz    ktimepnt, iatsfile, ifn, ibands[, ibandoffset, ibandincr]
 ar      atssinnoi   ktimepnt, ksinlev, knzlev, kfmod, iatsfile, ipartials[, ipartialoffset, ipartialincr]


atsadd and atsaddnz are based on pvadd by Richard Karpen and use files created by Juan Pampin's ATS (Analysis - Transformation - Synthesis). atssinnoi is based on ATS's sinnoi synth. 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. atsaddnz also reads from an ATS file but it 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. atssinnoi reads data from an ATS data file and uses the information to synthesize sines and noise together. The noise energy for each band is distributed equally among each partial that falls in that band. Each partial is then synthesized, along with that partial's noise component. Each noise component is then modulated by the corresponding partial to be put in the correct place in the frequency spectrum. The level of the noise and the partials are individually controllable. See the ATS webpage for more info about the sinnoi synthesis. 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.


ktimepnt – a time pointer for reading through the ats file

kfmod – an input for performing pitch transposition or frequency modulation on all of the synthesized partials, if no fm or pitch change is desired then use a 1 for this value

iatsfile – integer or character-string denoting a control-file derived from ATS analysis of an audio signal. An integer denotes the suffix of a file ats.m; a character-string (in double quotes) gives a filename, optionally a full pathname. If not full-path, the file is sought first in the current directory, then in the one given by the environment variable SADIR (if defined).

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 / ibands – number of partials or noise bands that will be used in the resynthesis (the noise has a maximum of 25 bands)

ipartialoffset / ibandoffset (optional) – is the first partial or noise band used (defaults to 0).

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

ksinlev controls the level of the sines in the atssinnoi ugen. A value of 1 gives full volume sinewaves.

knzlev controls the level of the noise components in the atssinnoi ugen. A value of 1 gives full volume noise.

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 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. This will be made clearer in the examples below.


ktimpnt and kfmod are used in the same way as in pvoc.


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

  ktime line  0, p3, 2.5
  asig  atsaddnz ktime, "clarinet.ats", 2, 25

In the example above we're synthesizing all 25 noise bands from the data contained in the ATS analysis file called "clarinet.ats", we're using function table 2, which should be a cosine ie:

  f2 0 4096 9 1 1 90
  ktime line  0, p3, 2.5
  asig  atsadd ktime, 1.0125, "clarinet.ats", 1, 20, 0, 2

In the above example we synthesize 20 partials as in example 1 except this time we're using a ipartialoffset of 0 and ipartialincr of 2, which means that we'll start from the first partial and synthesize 20 partials total, skipping every other one (ie. partial 1, 3, 5,...). We've also increased the pitch of the result (kfmod is set to 1.0125).

  ktime line  2.5, p3, 0
  asig atsaddnz ktime, 1, "clarinet.ats", 2, 1, 24

Here we synthesize only the 25th noise band (ibandoffset of 24 and ibands of 1). Also our time pointer is going from 2.5 to 0 over the duration of the note so we're reading backwards from 2.5 seconds in the analysis file.

  ktime line  0, p3, 2.5
  asig atssinnoi ktime, 1, 1, 1, "clarinet.ats", 42

Here we synthesize both the noise and the sinewaves (all 42 partials) contained in "clarinet.ats" together. The relative volumes of the noise and the partials are unaltered (each set to 1).

  ktime line  0, p3, 2.5
  knzfade expon  0.001, p3, 2.5
  asig atssinnoi ktime, 1, knzfade, 1, "clarinet.ats", 42

This example here is like example 5 except that we use an envelope to control knzlev (the noise level). The result of this will be a clarinet sound that has its noise component fade in over the duration of the note.


Alex Norman (an edited version of Richard Karpen's pvadd documentation)
Seattle, Wash