Use Non-Frames Version Previous Page Next Page
Signal Generators: STFT Resynthesis (Vocoding)

pvread, pvbufread, pvinterp, pvcross, tableseg, tablexseg

  kfr,    pvread     ktimpnt, ifile, ibin
  kap
          pvbufread  ktimpnt, ifile
  ar      pvinterp   ktimpnt, kfmod, ifile, kfreqscale1, kfreqscale2, kampscale1, kampscale2, kfreqinterp, kampinterp
  ar      pvcross    ktimpnt, kfmod, ifile, kamp1, kamp2[, ispecwp]
          tableseg   ifn1, idur1, ifn2[, idur2, ifn3[...]]
          tablexseg  ifn1, idur1, ifn2[, idur2, ifn3[...]]

Description

pvread reads from a pvoc file and returns the frequency and amplitude from a single analysis channel or bin. The returned values can be used anywhere else in the Csound instrument. For example, one can use them as arguments to an oscillator to synthesize a single component from an analyzed signal or a bank of pvreads can be used to resynthesize the analyzed sound using additive synthesis by passing the frequency and magnitude values to a bank of oscillators.

pvbufread reads from a pvoc file and makes the retrieved data available to any following pvinterp and pvcross units that appear in an instrument before a subsequent pvbufread (just as lpread and lpreson work together). The data is passed internally and the unit has no output of its own. pvinterp and pvcross allow the interprocessing of two phase vocoder analysis files prior to the resynthesis which these units do also. Both of these units receive data from one of the files from a previously called pvbufread unit. The other file is read by the pvinterp and/or pvcross units. Since each of these units has its own time-pointer the analysis files can be read at different speeds and directions from one another. pvinterp does not allow for the use of the ispecwp process as with the pvoc and vpvoc units.

pvinterp interpolates between the amplitudes and frequencies, on a bin by bin basis, of two phase vocoder analysis files (one from a previously called pvbufread unit and the other from within its own argument list), allowing for user defined transitions between analyzed sounds. It also allows for general scaling of the amplitudes and frequencies of each file separately before the interpolated values are calculated and sent to the resynthesis routines. The kfmod argument in pvinterp performs its frequency scaling on the frequency values after their derivation from the separate scaling and subsequent interpolation is performed so that this acts as an overall scaling value of the new frequency components.

pvcross applies the amplitudes from one phase vocoder analysis file to the data from a second file and then performs the resynthesis. The data is passed, as described above, from a previously called pvbufread unit. The two k-rate amplitude arguments are used to scale the amplitudes of each files separately before they are added together and used in the resynthesis (see below for further explanation). The frequencies of the first file are not used at all in this process. This unit simply allows for cross-synthesis through the application of the amplitudes of the spectra of one signal to the frequencies of a second signal. Unlike pvinterp, pvcross does allow for the use of the ispecwp as in pvoc and vpvoc.

tableseg and tablexseg are like linseg and expseg but interpolate between values in a stored function tables. The result is a new function table passed internally to any following vpvoc which occurs before a subsequent tableseg or tablexseg (much like lpread/lpreson pairs work). The uses of these are described below under vpvoc.

Initialization

ifile - the pvoc number (n in pvoc.n) or the name in quotes of the analysis file made using pvanal. (See pvoc.)

ibin - the number of the analysis channel from which to return frequency in Hz and magnitude.

ifn1, ifn2, ifn3, etc. - function table numbers for tableseg and tablexseg. ifn1, ifn2, and so on, must be the same size.

idur1, idur2, etc. - durations for tableseg and tablexseg, during which interpolation from one table to the next will take place.

Performance

kfreq, kamp - outputs of the pvread unit. These values, retrieved from a phase vocoder analysis file, represent the values of frequency and amplitude from a single analysis channel specified in the ibin argument. Interpolation between analysis frames is performed at k-rate resolution and dependent of course upon the rate and direction of ktimpnt.

ktimpnt, kfmod, ispecwp - used for pvread exactly the same as for pvoc (see above description of pvinterp for its special use of kfmod).

kfreqscale1, kfreqscale2, kampscale1, kampscale2 - used in pvinterp to scale the frequencies and amplitudes stored in each frame of the phase vocoder analysis file. kfreqscale1 and kampscale1 scale the frequencies and amplitudes of the data from the file read by the previously called pvbufread (this data is passed internally to the pvinterp unit). kfreqscale2 and kampscale2 scale the frequencies and amplitudes of the file named by ifile in the pvinterp argument list and read within the pvinterp unit. By using these arguments it is possible to adjust these values before applying the interpolation. For example, if file1 is much louder than file2, it might be desirable to scale down the amplitudes of file1 or scale up those of file2 before interpolating. Likewise one can adjust the frequencies of each to bring them more in accord with one another (or just the opposite, of course!) before the interpolation is performed.

kfreqinterp, kampinterp - used in pvinterp, determine the interpolation distance between the values of one phase vocoder file and the values of a second file. When the value of kfreqinterp is 0, the frequency values will be entirely those from the first file (read by the pvbufread), post scaling by the kfreqscale1 argument. When the value of kfreqinterp is 1 the frequency values will be those of the second file (read by the pvinterp unit itself), post scaling by kfreqscale2. When kfreqinterp is between 0 and 1 the frequency values will be calculated, on a bin, by bin basis, as the percentage between each pair of frequencies (in other words, kfreqinterp=.5 will cause the frequencies values to be half way between the values in the set of data from the first file and the set of data from the second file). kampinterp1 and kampinterp2 work in the same way upon the amplitudes of the two files. Since these are k-rate arguments, the percentages can change over time making it possible to create many kinds of transitions between sounds.

Example

The example below shows the use pvread to synthesize a single component from a phase vocoder analysis file. It should be noted that the kfreq and kamp outputs can be used for any kind of synthesis, filtering, processing, and so on.

  ktime         line    0, p3, 3 
  kfreq, kamp   pvread  ktime, "pvoc.file", 7 ; read
                                        ;data from 7th analysis bin.  
  asig          oscili  kamp, kfreq, 1  ; function 1
                                        ;is a stored sine

The example below shows an example using pvbufread with pvinterp to interpolate between the sound of an oboe and the sound of a clarinet. The value of kinterp returned by a linseg is used to determine the timing of the transitions between the two sounds. The interpolation of frequencies and amplitudes are controlled by the same factor in this example, but for other effects it might be interesting to not have them synchronized in this way. In this example the sound will begin as a clarinet, transform into the oboe and then return again to the clarinet sound. The value of kfreqscale2 is 1.065 because the oboe in this case is a semitone higher in pitch than the clarinet and this brings them approximately to the same pitch. The value of kampscale2 is .75 because the analyzed clarinet was somewhat louder than the analyzed oboe. The setting of these two parameters make the transition quite smooth in this case, but such adjustments are by no means necessary or even advocated.

  ktime1  line      0, p3, 3.5 ; used as index in the "oboe.pvoc" file
  ktime2  line      0, p3, 4.5 ; used as index in the  "clar.pvoc" file
  kinterp linseg    1, p3*.15, 1, p3*.35, 0, p3*.25, 0, p3*.15, 1, p3*.1, 1
          pvbufread ktime1, "oboe.pvoc"
  apv     pvinterp  ktime2,1,"clar.pvoc",1,1.065,1,.75,1-kinterp,1-kinterp

Below is an example using pvbufread with pvcross. In this example the amplitudes used in the resynthesis gradually change from those of the oboe to those of the clarinet. The frequencies, of course, remain those of the clarinet throughout the process since pvcross does not use the frequency data from the file read by pvbufread.

  ktime1  line    0, p3, 3.5 ; used as index in the "oboe.pvoc" file
  ktime2  line    0, p3, 4.5 ; used as index in the "clar.pvoc" file
  kcross  expon     .001, p3, 1
          pvbufread ktime1, "oboe.pvoc"
  apv     pvcross   ktime2, 1, "clar.pvoc", 1-kcross, kcross

Author

Richard Karpen
Seattle, Wash
1997


Use Non-Frames Version Previous Page Next Page
Signal Generators: STFT Resynthesis (Vocoding)