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


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.


pvbufread ktimpnt, ifile


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


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.


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 800. Example of the pvbufread opcode.

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

; Select audio/midi flags here according to platform
-odac  -m0  ;;;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

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

; by Menno Knevel 2021

gilen1  filelen "flute.aiff"    ; get length of soundfiles
gilen2  filelen "beats.wav"

; analyze sound files and output results to pvoc-ex files
ires1 system_i 1,{{ pvanal flute.aiff flute.pvx }} ; use default settings
ires2 system_i 1,{{ pvanal beats.wav beats.pvx }}  

instr 1 ; untreated signals

asig    diskin2   p4 , 1
print gilen1
print gilen2
    outs    asig, asig

instr 2

ktime1 line  0, p3, .8		; use a part of "flute.pvx" file
ktime2 line  0, p3, 1		; use a part of "beats.pvx" file
kcross line  0, p3, 1       ; from flute to beats
       pvbufread ktime1, "flute.pvx"
asig   pvcross   ktime2, 1, "beats.pvx", 1-kcross, kcross
       outs asig, asig

i1 0 2.62   "flute.aiff"
i1 3 2      "beats.wav"
i2 1 3
i2 5 10

See Also

pvcross, pvinterp, pvread, tableseg, tablexseg


Author: Richard Karpen
Seattle, WA USA