pvcross — Applies the amplitudes from one phase vocoder analysis file to the data from a second file.
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
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.
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.
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. Play pvcross.csd
Example 801. 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 -m0 ;;;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 ; by Menno Knevel 2021 gilen1 filelen "flutec3.wav" ; get length of soundfiles gilen2 filelen "flute.aiff" ; these files are all gilen3 filelen "wave.wav" ; around 2.7 seconds... ; analyze sound files and output results to pvoc-ex files ires1 system_i 1,{{ pvanal flutec3.wav flutec3.pvx }} ; use default settings ires2 system_i 1,{{ pvanal flute.aiff flute.pvx }} ires3 system_i 1,{{ pvanal wave.wav wave.pvx }} instr 1 ; untreated signals asig diskin2 p4 , 1 print gilen1 print gilen2 print gilen3 prints "\n---***YOU NOW HEAR THE UNTREATED SOUND SAMPLES***---\n" outs asig, asig endin instr 2 prints "\n---***YOU NOW HEAR THE RESULT OF THE ANALYZED FILES:***---\n" ktime1 line 0, p3, gilen1 ; timepointer in "flutec3.pvx" file kcross expon 0.001, p3, 1 pvbufread ktime1, "flutec3.pvx" ;take only amplitude from "flute3c.pvx" if p4 = 0 then ktime2 line 0, p3, gilen2 ; timepointer in "flute.pvx" kfreq line .5, p3, 2 ; frequency rise asig pvcross ktime2, kfreq, "flute.pvx", 1-kcross, kcross, p5 ;p5 = preserve spectral envelope prints "--** preserve spectral envelope = %d **--\n", p5 else ktime2 line 0, p3, gilen3 ; timepointer in "wave.pvx" kfreq line .5, p3, 2 ; frequency rise asig pvcross ktime2, kfreq, "wave.pvx", 1-kcross, kcross, p5 ;p5 = preserve spectral envelope prints "--** preserve spectral envelope = %d **--\n", p5 endif outs asig, asig endin </CsInstruments> <CsScore> s i1 0 2.76 "flutec3.wav" ; this is the file to cross with i1 3 2.62 "flute.aiff" ; this one, or.. i1 6 2 "wave.wav" ; this one s; sample formant ; all slowed down to have a good listen i2 0 10 0 0 ; cross flutec3 with the flute, do not preserve formants i2 10 10 1 0 ; cross flutec3 with wave, do not preserve formants s; sample formant i2 0 10 0 1 ; cross flutec3 with the flute & preserve formants i2 10 10 1 1 ; cross flutec3 with wave & preserve formants e </CsScore> </CsoundSynthesizer>