pvinterp
Prev | Orchestra Opcodes and Operators | Next

## pvinterp

pvinterp — Interpolates between the amplitudes and frequencies of two phase vocoder analysis files.

## Description

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.

## Syntax

    ares pvinterp ktimpnt, kfmod, ifile, kfreqscale1, kfreqscale2, \
          kampscale1, kampscale2, kfreqinterp, kampinterp

## Initialization

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

## Performance

ktimpnt -- the passage of time, in seconds, through this file. ktimpnt must always be positive, but can move forwards or backwards in time, be stationary or discontinuous, as a pointer into the analysis file.

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.

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 1, 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 0 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=0.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).

kampinterp works 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.

## Examples

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 0.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*0.15, 1, p3*0.35, 0, p3*0.25, 0, p3*0.15, 1, p3*0.1, 1
            pvbufread ktime1, "oboe.pvoc"
    apv     pvinterp  ktime2,1,"clar.pvoc", 1, 1.065, 1, 0.75, 1-kinterp, 1-kinterp

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

Example 750. Example of the pvinterp opcode.

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

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

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

    instr 1
    ; analyze "fox.wav" and "flute.aiff" with PVANAL first
    ktime1 line 0, p3, 2.8		 ; used as index in the "fox.pvx" file
    ktime2 line 0, p3, 3		 ; used as index in the "flute.pvx" file
    kinterp line 1, p3, 0
    	pvbufread ktime1, "fox.pvx"
    asig	pvinterp ktime2,1,"flute.pvx",.9, 3, .6, 1, kinterp,1-kinterp
            outs asig, asig

    endin
    </CsInstruments>
    <CsScore>
    i 1 0 3
    i 1 + 10

    e
    </CsScore>
    </CsoundSynthesizer>

## See Also

pvbufread, pvcross, pvread, tableseg, tablexseg

## Credits

Author: Richard Karpen
Seattle, Wash
1997

Prev | Up | Next
pvcross | Home | pvoc