pvshift
Prev | Orchestra Opcodes and Operators | Next

## pvshift

pvshift — Shift the frequency components of a pv stream, stretching/compressing its spectrum.

## Description

Shift the frequency components of a pv stream, stretching/compressing its spectrum.

## Syntax

    fsig pvshift fsigin, kshift, klowest[, kkeepform, igain, kcoefs]

## Performance

fsig -- output pv stream

fsigin -- input pv stream

kshift -- shift amount (in Hz, positive or negative).

klowest -- lowest frequency to be shifted.

kkeepform -- attempt to keep input signal formants; 0: do not keep formants; 1: keep formants using a liftered cepstrum method; 2: keep formants by using a true envelope method (defaults to 0).

kgain -- amplitude scaling (defaults to 1).

kcoefs -- number of cepstrum coefs used in formant preservation (defaults to 80).

This opcode will shift the components of a pv stream, from a certain frequency upwards, up or down a fixed amount (in Hz). It can be used to transform a harmonic spectrum into an inharmonic one. The kkeepform flag can be used to try and preserve formants for possibly interesting and unusual spectral modifications.

| Warning
It is unsafe to use the same f-variable for both input and output of pvs opcodes. Using the same one might lead to undefined behavior on some opcodes. Use a different one on the left and right sides of the opcode.

## Examples

Example 653. Example

    asig  in                                 ; get the signal in

    fsig  pvsanal   asig, 1024, 256, 1024, 1 ; analyse it
    ftps  pvshift   fsig, 100, 0             ; add 100 Hz to each component
    atps  pvsynth   ftps                     ; synthesise it

Depending on the input, this will transform a pitched sound into an inharmonic, bell-like sound.

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

Example 654. Example of the pvshift opcode.

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

    <CsoundSynthesizer>
    <CsOptions>
    -odac
    </CsOptions>
    <CsInstruments>

    sr = 44100
    ksmps = 16
    nchnls = 1
    0dbfs = 1

    ;; example written by joachim heintz 2009

    instr 1
    ishift		=		p4; shift amount in Hz
    ilowest	=		p5; lowest frequency to be shifted
    ikeepform	=		p6; 0=no formant keeping, 1=keep by amps, 2=keep by spectral envelope
    ifftsize	=		1024
    ioverlap	=		ifftsize / 4
    iwinsize	=		ifftsize
    iwinshape	=		1; von-Hann window
    Sfile		=		"fox.wav"
    ain		soundin	Sfile
    fftin		pvsanal	ain, ifftsize, ioverlap, iwinsize, iwinshape; fft-analysis of file
    fshift		pvshift  	fftin, ishift, ilowest, ikeepform; shift frequencies
    aout		pvsynth	fshift; resynthesize
    		out		aout
    endin

    </CsInstruments>
    <CsScore>
    i 1 0 2.757 0 0 0; no shift at all
    i 1 3 2.757 100 0 0; shift all frequencies by 100 Hz
    i 1 6 2.757 200 0 0; by 200 Hz
    i 1 9 2.757 200 0 1; keep formants by method 1
    i 1 12 2.757 200 0 2; by method 2
    i 1 15 2.757 200 1000 0; shift by 200 Hz but just above 1000 Hz
    i 1 18 2.757 1000 500 0; shift by 1000 Hz above 500 Hz
    i 1 21 2.757 1000 300 0; above 300 Hz
    e
    </CsScore>
    </CsoundSynthesizer>

## See Also

pvsanal, pvsynth, pvsadsyn

## Credits

Author: Victor Lazzarini
November 2004

New plugin in version 5

November 2004.

Prev | Up | Next
pvsgain | Home | pvsifd