Signal Generators: STFT Resynthesis (Vocoding)

atsbufread, atscross, atsinterpread, atspartialtap

            atsbufread    ktimepnt, kfmod, iatsfile, ipartials[, ipartialoffset, ipartialincr]
 ar         atscross      ktimepnt, kfmod, iatsfile, ifn, kmylev, kbuflev, ipartials[, ipartialoffset, ipartialincr]
 kamp       atsinterpread kfreq
 kfrq, kamp atspartialtap ipartialnum


atsbufread is based on pvbufread by Richard Karpen. atscross, atsinterpread and atspartialtap are all dependent on atsbufread just as pvcross and pvinterp are on pvbufread. atsbufread reads data from and ATS data file and stores it in an internal data table of frequency, amplitude pairs. The data stored by an atsbufread can only be accessed by other unit generators, and therefore, due to the architecture of Csound, an atsbufread must come before (but not necessarily directly) any dependent unit generator. Besides the fact that atsbufread doesn't output any data directly, it works almost exactly as atsadd. The ugen uses a time pointer (ktimepnt) to index the data in time, ipartials, ipartialoffset and ipartialincr to select which partials to store in the table and kfmod to scale partials in frequency.

atscross uses data from an ATS analysis file (indicated by iatsfile) and data from an atsbufread to perform cross synthesis. atscross uses ktimepnt, kfmod, ipartials, ipartialoffset and ipartialincr just like atsadd . atscross synthesizes a sine-wave for each partial selected by the user and uses the frequency of that partial (after scaling in frequency by kfmod) to index the table created by atsbufread. Interpolation is used to get in-between values. atscross uses the sum of the amplitude data from its ATS file (scaled by kmylev) and the amplitude data gained from an atsbufread (scaled by kbuflev) to scale the amplitude of each partial it synthesizes. Setting kmylev to one and kbuflev to zero will make atscross act exactly like atsadd. Setting kmylev to zero and kbuflev to one will produce a sound that has all the partials selected by the atscross ugen, but with amplitudes taken from an atsbufread. The time pointers of the atsbufread and atscross do not need to be the same.

atsinterpread takes a frequency value (kfreq in Hz). This frequency is used to index the data of an atsbufread. The return value is an amplitude gained from the atsbufread after interpolation. atsinterpread allows a user to determine the frequency envelope of any atsbufread. This data could be useful for an number of reasons, one might be performing cross synthesis of data from an ATS file and non ATS data.

atspartialtap takes a partial number and returns a frequency, amplitude pair. The frequency and amplitude data comes from an atsbufread opcode. This is more restricted version of atsread, since each atsread opcode has its own independent time pointer, and atspartialtap is restricted to the data given by an atsbufread. Its simplicity is its attractive feature.


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 re-synthesis (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).

kmylev scales the atscross component of the frequency spectrum applied to the partials from the ATS file indicated by the atscross opcode. The frequency spectrum information comes from the atscross ATS file. A value of 1 (and 0 for kbuflev) gives the same results as atsadd.

kbuflev scales the atsbufread component of the frequency spectrum applied to the partials from the ATS file indicated by the atscross opcode. The frequency spectrum information comes from the atsbufread ATS file. A value of 1 (and 0 for kmylev) results in partials that have frequency information from the ATS file given by the atscross, but amplitudes imposed by data from the ATS file given by atsbufread

kfreq is a frequency value (given in Hertz) used by atsinterpread as in index into the table produced by an atsbufread

ipartialnum indicates the partial that the atspartialtap opcode should read from an atsbufread.


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


  ktime line 0, p3, 2.4
  ktime2 line 0, p3, .5
  kline expseg 0.001, .9, 1, p3-.9, 1
  kline2 expseg .001, p3, 1
  atsbufread  ktime2, 1, "crt.ats", 20
  aout atscross ktime, 1, "cl.ats", 1, kline, .001* (1 - kline2), 42

This example performs cross synthesis using two ATS files, crt.ats and cl.ats. The result of this will be a sound that starts out with the shape (in frequency) of crt.ats, and ends with the shape of cl.ats. All the sine-wave frequencies come from cl.ats. The kbuflev value is scaled because the energy produced by applying crt.ats's frequency spectrum to cl.ats's partials is very large. Notice also that the time pointers of the atsbufread (crt.ats) and atscross (cl.ats) need not have the same value, this way you can read through the two ATS files at different rates.

  ktime  line  0, p3, 2.4
  atsbufread  ktime, 1, "cl.ats", 42
  kamp  atsinterpread p4
  aosc  oscili  kamp, p4, 1

This example shows how to use atsinterpread. Here a frequency is given by the score (p4) and this frequency is given to an atsinterpread (with a corresponding atsbufread). The atsinterpread uses this frequency to output a corresponding amplitude value, based on the atsfile given by the atsbufread (cl.ats in this case). We then use that amplitude to scale a sine-wave that is synthesized with the same frequency (p4). You could extend this to include multiple sine-waves. This way you could synthesize any reasonable frequency (within the low and high frequencies of the indicated ATS file), and maintain the shape (in frequency) of the indicated atsfile (given by the atsbufread).

  ktime line 0, p3, 2.4
  atsbufread  ktime, 1, "crt.ats", 20
  kfreq1, kamp1 atspartialtap 1
  kfreq2, kamp2 atspartialtap 10
  kfreq3, kamp3 atspartialtap 20

This example here uses an atspartialtap, and an atsbufread to read partials 1, 10 and 20 from crt.ats. These amplitudes and frequencies could be used to re-synthesize those partials, or something all together different.


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