QUICK-REF - CsoundManual - Top of this section - Previous - Contents - Index - Next 

pvread, pvbufread, pvinterp, pvcross, tableseg, tablexseg, vpvoc

kfreq,kamp    pvread        ktimpnt,  ifile, ibin                   
              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[...]]
        ar    vpvoc         ktimpnt, kfmod, ifile, [ispecwp]

DESCRIPTION

pvread reads from a pvoc file and returns the frequency and amplitude from a single anaylsis 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 or voscili which occurs before a subsequent tableseg or tablexseg (much like lpread/lpreson pairs work). The uses of these are described below under vpvoc and (see also voscili which allows the use of these units in an interpolating oscillator).

vpvoc is identical to pvoc except that it takes the result of a previous tableseg or tablexseg and uses the resulting function table (passed internally to the vpvoc), as an envelope over the magnitudes of the analysis data channels. The result is spectral enveloping. The function size used in the tableseg should be framesize/2, where framesize is the number of bins in the phase vocoder analysis file that is being used by the vpvoc. Each location in the table will be used to scale a single analysis bin. By using different functions for ifn1, ifn2, etc.. in the tableseg, the spectral envelope becomes a dynamically changing one.

PERFORMANCE

ifile is the pvoc number (n in pvoc.n) or the name in quotes of the analysis file made using pvanal. See pvoc documentation in Csound manual.

kfreq and kamp are the 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, and ispecwp used in pvread and vpvoc are exactly the same as for pvoc (see above description of pvinterp for its special use of kfmod).

ibin is the number of the analysis channel from which to return frequency in cps and magnitude.

kfreqscale1, kfreqscale2, kampscale1, kampscale2 are 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 and 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.

ifn1, ifn2, ifn3, etc... in tableseg and tablexseg are stored functions, created from an f-card in the numeric notelist. ifn1, ifn2, and so on, MUST be the same size.

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

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 sychnronized 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
In following example using vpvoc shows the use of functions such as
        f 1 0 256 5 .001 128 1 128 .001
        f 2 0 256  5 1 128 .001 128 1
        f 3 0 256  7 1 256 1
to scale the amplitudes of the separate analysis bins.
ktime   line            0, p3,3 ; time pointer, in seconds, into file
        tablexseg       1, p3*.5, 2, p3*.5, 3
apv     vpvoc           ktime,1, "pvoc.file"
The result would be a time-varying "spectral envelope" applied to the phase vocoder analysis data. Since this amplifies or attenuates the amount of signal at the frequencies that are paired with the amplitudes which are scaled by these functions, it has the effect of applying very accurate filters to the signal. In this example the first table would have the effect of a band- pass filter , gradually be band-rejected over half the note's duration, and then go towards no modification of the magnitudes over the second half.

AUTHOR:

Richard Karpen
Seattle, Wash
1997
 


QUICK-REF - CsoundManual - Top of this section - Previous - Contents - Index - Next 
HTML Csound Manual - © Jean Piché & Peter J. Nix, 1994-97