pvoc
Prev | Orchestra Opcodes and Operators | Next

## pvoc

pvoc — Implements signal reconstruction using an fft-based phase vocoder.

## Description

Implements signal reconstruction using an fft-based phase vocoder.

## Syntax

    ares pvoc ktimpnt, kfmod, ifilcod [, ispecwp] [, iextractmode] \
          [, ifreqlim] [, igatefn]

## Initialization

ifilcod -- integer or character-string denoting a control-file derived from analysis of an audio signal. An integer denotes the suffix of a file pvoc.m; a character-string (in double quotes) gives a filename, optionally a full pathname. If not fullpath, the file is sought first in the current directory, then in the one given by the environment variable SADIR (if defined). pvoc control contains breakpoint amplitude and frequency envelope values organized for fft resynthesis. Memory usage depends on the size of the files involved, which are read and held entirely in memory during computation but are shared by multiple calls (see also lpread).

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

iextractmode (optional) -- determines if spectral extraction will be carried out and if so whether components that have changes in frequency below ifreqlim or above ifreqlim will be discarded. A value for iextractmode of 1 will cause pvoc to synthesize only those components where the frequency difference between analysis frames is greater than ifreqlim. A value of 2 for iextractmode will cause pvoc to synthesize only those components where the frequency difference between frames is less than ifreqlim. The default values for iextractmode and ifreqlim are 0, in which case a simple resynthesis will be done. See examples under pvadd for how to use spectral extraction.

igatefn (optional) -- the number of a stored function which will be applied to the amplitudes of the analysis bins before resynthesis takes place. If igatefn is greater than 0 the amplitudes of each bin will be scaled by igatefn through a simple mapping process. First, the amplitudes of all of the bins in all of the frames in the entire analysis file are compared to determine the maximum amplitude value. This value is then used create normalized amplitudes as indeces into the stored function igatefn. The maximum amplitude will map to the last point in the function. An amplitude of 0 will map to the first point in the function. Values between 0 and 1 will map accordingly to points along the function table. See examples under pvadd for how to use amplitude gating.

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

pvoc implements signal reconstruction using an fft-based phase vocoder. The control data stems from a precomputed analysis file with a known frame rate.

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.

## Examples

Here is an example of the pvoc opcode. It uses the file pvoc.csd.

Example 800. Example of the pvoc 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  --limiter=.95 ;;;realtime audio out, with limiter protection
    ; For Non-realtime ouput leave only the line below:
    ; -o pvoc.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
    asig  pvoc ktime, p4, "fox1.pvx", 1
          outs asig*.6, asig*.6
    endin

    </CsInstruments>
    <CsScore>

    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  25 10   1.2; slowed down and higher pitch

    e
    </CsScore>
    </CsoundSynthesizer>

## See Also

vpvoc, PVANAL.

## Credits

Authors: Dan Ellis and Richard Karpen
Seattle, Wash
1997

Prev | Up | Next
pvinterp | Home | pvread