pvcross
Prev | Orchestra Opcodes and Operators | Next

## pvcross

pvcross — Applies the amplitudes from one phase vocoder analysis file to the data from a second file.

## Description

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.

## Syntax

    ares pvcross ktimpnt, kfmod, ifile, kampscale1, kampscale2 [, ispecwp]

## Initialization

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

ispecwp (optional, default=0) -- if non-zero, attempts to preserve the spectral envelope while its frequency content is varied by kfmod. The default value is zero.

## 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 0.5 down an octave.

kampscale1, kampscale2 -- used to scale the amplitudes stored in each frame of the phase vocoder analysis file. kampscale1 scale the amplitudes of the data from the file read by the previously called pvbufread. kampscale2 scale the amplitudes of the file named by ifile.

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.

## Examples

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     0.001, p3, 1
            pvbufread ktime1, "oboe.pvoc"
    apv     pvcross   ktime2, 1, "clar.pvoc", 1-kcross, kcross

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

Example 602. Example of the pvcross 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 pvcross.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

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

    instr 1
    ; analyze "beats.wav", "flute.aiff" and "mary.wav" with PVANAL first
    ktime1 line 0, p3, 2			; used as index in the "beats.pvx" file
    ktime2 line 0, p3, 2.6			; used as index in the "flute.pvx" or "mary.pvx"
           pvbufread ktime1, "beats.pvx"	;take only amplitude from "beats.pvx"
    if p4 = 0 then
    asig   pvcross	ktime2, 1, "flute.pvx", 1, 0 ;and keep freqs of "flute.aiff"
    asig   = asig*.8			;scale output
    else
    asig   pvcross	ktime2, 1, "mary.pvx", 1, 0 ;and keep freqs of "mary.wav"
    asig   = asig*.4			;scale output
    endif
           outs asig, asig

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

    e
    </CsScore>
    </CsoundSynthesizer>

## See Also

pvbufread, pvinterp, pvread, tableseg, tablexseg

## Credits

Author: Richard Karpen
Seattle, Wash
1997

New in version 3.44

Prev | Up | Next
pvbufread | Home | pvinterp