vpvoc
Prev | Orchestra Opcodes and Operators | Next

## vpvoc

vpvoc — Implements signal reconstruction using an fft-based phase vocoder and an extra envelope.

## Description

Implements signal reconstruction using an fft-based phase vocoder and an extra envelope.

## Syntax

    ares vpvoc ktimpnt, kfmod, ifile [, ispecwp] [, ifn]

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

ifn (optional, default=0) -- optional function table containing control information for vpvoc. If ifn = 0, control is derived internally from a previous tableseg or tablexseg unit. Default is 0. (New in Csound version 3.59)

## Performance

ktimpnt -- The passage of time, in seconds, through the analysis 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.

This implementation of pvoc was orignally written by Dan Ellis. It is based in part on the system of Mark Dolson, but the pre-analysis concept is new. The spectral extraction and amplitude gating (new in Csound version 3.56) were added by Richard Karpen based on functions in SoundHack by Tom Erbe.

vpvoc is identical to pvoc except that it takes the result of a previous tableseg or tablexseg and uses the resulting function table (passed internally to the vpvoc), as an envelope over the magnitudes of the analysis data channels. Optionally, a table specified by ifn may be used.

The result is spectral enveloping. The function size used in the tableseg should be framesize/2, where framesize is the number of bins in the phase vocoder analysis file that is being used by the vpvoc. Each location in the table will be used to scale a single analysis bin. By using different functions for ifn1, ifn2, etc.. in the tableseg, the spectral envelope becomes a dynamically changing one. See also tableseg and tablexseg.

## Examples

The following example, using vpvoc, shows the use of functions such as

    f 1 0 256 5 .001 128 1 128 .001
    f 2 0 256 5 1 128 .001 128 1
    f 3 0 256 7 1 256 1

to scale the amplitudes of the separate analysis bins.

    ktime   line         0, p3, 3 ; time pointer, in seconds, into file
            tablexseg    1, p3*0.5, 2, p3*0.5, 3
    apv     vpvoc        ktime, 1, "pvoc.file"

The result would be a time-varying “spectral envelope” applied to the phase vocoder analysis data. Since this amplifies or attenuates the amount of signal at the frequencies that are paired with the amplitudes which are scaled by these functions, it has the effect of applying very accurate filters to the signal. In this example the first table would have the effect of a band-pass filter, gradually be band-rejected over half the note's duration, and then go towards no modification of the magnitudes over the second half.

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

Example 1201.

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
    ; For Non-realtime ouput leave only the line below:
    ; -o vpvoc.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

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

    ; by Menno Knevel 2021

    gilen  filelen "fox.wav"	    ; get length of impulse soundfile

    ; analyze sound file and output result to pvoc-ex file
    ires system_i 1,{{ pvanal fox.wav fox1.pvx }}          ; default settings

    instr 1 ; untreated signal
    asig    diskin2   "fox.wav", 1
    prints  "\n---***YOU NOW HEAR THE UNTREATED SOUND SAMPLE***---\n"
    outs    asig*.8, asig*.8
    endin

    instr 2

    prints  "\n---***YOU NOW HEAR THE RESULT OF THIS ANALYZED FILE:***---\n"
    ktime line 0, p3, gilen     ; timepointer over the entire sample
          tablexseg 1, p3, 2	; morph from table 1 to table 2
    prints  "2 tables are used as filter envelopes (tables 1 & 2)\n"
    asig  vpvoc ktime, p4, "fox1.pvx"
          outs asig, asig
    endin

    </CsInstruments>
    <CsScore>
    f 1 0 512 9 .5 1 0
    f 2 0 512 5 1 60 0.01 390 0.01 62 1

    i1 0 2.76      ; original sample

    i2  5 2.76  1  ; no change so original sample is played
    i2  10 2    1  ; played faster

    i2  15 10   1  ; slowed down, same pitch &
    i2  15 10   1.2; higher pitch, forming a chord

    e
    </CsScore>
    </CsoundSynthesizer>

## See Also

pvoc

## Credits

Authors: Dan Ellis and Richard Karpen
Seattle, WA USA
1997

New in version 3.44

Prev | Up | Next
vps | Home | vrandh