pvslpc
Prev | Orchestra Opcodes and Operators | Next

## pvslpc

pvslpc — Streaming linear prediction analysis.

## Description

This opcode implements streaming linear prediction analysis from an input signal and outputs an fsig, which can be used with other pvs opcodes.

## Syntax

    fsig pvslpc asrc, idftsiz, ihop, iord[,iwin]

## Initialization

idftsiz -- size of lpc input frame in samples and fsig analysis frame. It needs to be a power-of-two.

iord -- linear predictor order.

ihop -- analysis hop size.

iwin -- window function table number (optional).

## Performance

fsig -- fsig output

asrc -- source signal for lpc analysis

This opcode is part of a suite of streaming linear prediction opcodes. It analyses an input signal and produces a set of LPC coefficients for an all-pole filter that models the signal's spectral envelope. The transfer function for this filter is then computed and its magnitude spectrum is output as a streaming phase vocoder signal.

The fundamental analysis parameters are input frame size and filter order. Longer input frames will produce a more accurate result in terms of frequency resolution, but will also involve more computation. This is due to the computation of the autocorrelation function, which is then used in the coefficient computation. This part is more efficient and depends only on the linear prediction order, which is also the number of coefficients computed. Typical lp orders may range from about 30 to 100 coefficients, but larger values can also be used.

The analyses are produced every hopsize samples. Once the signal is extracted from an audio input then it can be optionally windowed if a function table is provided. While this is optional, it is a recommended procedure (GEN20 can provide the most common windows). The signal is then analysed and coefficients produced. The fsig produced by this opcode is given in AMP-FREQ format. The amplitudes contain the spectral envelope of the input signal, and the frequencies are derived from a fundamental frequency estimation computed from the autocorrelation function. These do not represent the frequencies in the input signal to any level of accuracy; they are only placeholders.

## Examples

Here is an example of the pvslpc opcode using an audio input signal as lpc source. It uses the file pvslpc.csd.

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

    ; by Menno Knevel 2021

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

    gifw ftgen 0, 0, 1024, 20, 2, 1             ; Hanning window

    instr 1

    iswap   =   p4                              ; decide which sample goes to pvslpc
    if iswap == 1 then
        a1 diskin "MSjungleMid.wav", 1, 0, 1    ; first the jungle
        a2 diskin "fox.wav", 1, 0, 1
        prints "\n--**the jungle...**--\n"
    else
        a1 diskin "fox.wav", 1, 0, 1            ; then the fox
        a2 diskin "MSjungleMid.wav", 1, 0, 1
        prints "\n--**and the fox...**--\n"
    endif
    iorder  =   p5
    fenv    pvslpc  a1, 1024, 128, p5, gifw
    fsig    pvscale fenv, 1.5                   ; convert lpc to pvs, for
    a3      pvsynth fsig                        ; scaling basic frequency 1.5 times
    a3      dcblock a3
    outs    a3*.1, a3*.1
    endin

    </CsInstruments>
    <CsScore>
    ;         jungle   order
    i1  0  10   1       10
    i1  11 10   1       150
    s
    i1  2  10   0       10
    i1  13 10   0       150
    e
    </CsScore>
    </CsoundSynthesizer>

## See also

Streaming Linear Predictive Coding (SLPC) Resynthesis

Prev | Up | Next
pvsin | Home | pvsmaska