pvbufread
Prev | Orchestra Opcodes and Operators | Next

## pvbufread

pvbufread — Reads from a phase vocoder analysis file and makes the retrieved data available.

## Description

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.

## Syntax

    pvbufread ktimpnt, ifile

## 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.

## 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

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 pvbufread opcode. It uses the file pvbufread.csd

Example 733. Example of the pvbufread 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 pvbufread.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, .8		; use a part of "flute.pvx" file
    ktime2 line  0, p3, 1.2		; use a part of "beats.pvx" file
    kcross expon .03, p3, 1
           pvbufread ktime1, "flute.pvx"
    asig   pvcross   ktime2, 1, "beats.pvx", 1-kcross, kcross
           outs asig, asig

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

    e
    </CsScore>
    </CsoundSynthesizer>

## See Also

pvcross, pvinterp, pvread, tableseg, tablexseg

## Credits

Author: Richard Karpen
Seattle, WA USA
1997

Prev | Up | Next
pvadd | Home | pvcross