pvstanal
Prev | Orchestra Opcodes and Operators | Next

## pvstanal

pvstanal — Phase vocoder analysis processing with onset detection/processing.

## Description

pvstanal implements phase vocoder analysis by reading function tables containing sampled-sound sources, with GEN01, and pvstanal will accept deferred allocation tables.

This opcode allows for time and frequency-independent scaling. Time is advanced internally, but controlled by a tempo scaling parameter; when an onset is detected, timescaling is momentarily stopped to avoid smearing of attacks. The quality of the effect is generally improved with phase locking switched on.

pvstanal will also scale pitch, independently of frequency, using a transposition factor (k-rate).

## Syntax

    fsig pvstanal ktimescal, kamp, kpitch, ktab, [kdetect, kwrap, ioffset,ifftsize, ihop, idbthresh]

## Initialization

ifftsize -- FFT size (power-of-two), defaults to 2048.

ihop -- hopsize, defaults to 512

ioffset -- startup read offset into table, in secs.

idbthresh -- threshold for onset detection, based on dB power spectrum ratio between two successive windows. A detected ratio above it will cancel timescaling momentarily, to avoid smearing (defaults to 1). By default anything more than a 1 dB inter-frame power difference will be detected as an onset.

## Performance

ktimescal -- timescaling ratio, < 1 stretch, > 1 contract.

kamp -- amplitude scaling

kpitch -- grain pitch scaling (1=normal pitch, < 1 lower, > 1 higher; negative, backwards)

kdetect -- 0 or 1, to switch onset detection/processing. The onset detector checks for power difference between analysis windows. If more than what has been specified in the dbthresh parameter, an onset is declared. It suspends timescaling momentarily so the onsets are not modified.

ktab -- source signal function table. Deferred-allocation tables (see GEN01) are accepted, but the opcode expects a mono source. Tables can be switched at k-rate.

kwrap -- 0 or 1, to switch on/off table wrap-around read (default to 1)

## Examples

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

Example 781. Example of the pvstanal 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 pvstanal.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

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

    gifil     ftgen     0, 0, 0, 1, "fox.wav", 0, 0, 1

    instr 1

    fsig      pvstanal  p4, 1, p5, gifil, p6, p7
    aout      pvsynth   fsig
              outs      aout, aout
    endin

    instr 2

    kspeed    randi     2, 2, 2 ;speed randomly between -2 and 2
    kpitch    randi     2, 2, 2 ;pitch between 2 octaves lower or higher
    fsig      pvstanal  kspeed, 1, octave(kpitch), gifil
    aout      pvsynth   fsig
              outs      aout, aout
    endin

    </CsInstruments>
    <CsScore>
    ;           speed pch det wrap
    i 1 0 2.757 1     1   0   0
    i 1 3 .     2     1   0   0
    i 1 6 .     2     1   0   1
    i 1 9 .     1     .75
    i 2 12 10 ;random scratching
    e
    </CsScore>
    </CsoundSynthesizer>

## Credits

Author: Victor Lazzarini
February 2010

New plugin in version 5.13

February 2005.

Prev | Up | Next
pvspitch | Home | pvstencil