Skip to content

pvsifd

Instantaneous Frequency Distribution, magnitude and phase analysis.

The pvsifd opcode takes an input a-rate signal and performs an Instantaneous Frequency, magnitude and phase analysis, using the STFT and pvsifd (Instantaneous Frequency Distribution), as described in Lazzarini et al, "Time-stretching using the Instantaneous Frequency Distribution and Partial Tracking", Proc.of ICMC05, Barcelona. It generates two PV streaming signals: one containing magnitudes and frequencies, and another containing magnitudes and phases.

Syntax

ffr, fphs = pvsifd(ain, ifftsize, ihopsize, iwintype [,iscal])
ffr, fphs pvsifd ain, ifftsize, ihopsize, iwintype [,iscal]

Initialization

ifftsize -- FFT size in samples. It must be a power of two, at least 2, and an integer multiple of ihopsize. The Hann window requires at least 4 samples.

ihopsize -- positive whole number of samples between analysis frames.

iwintype -- window type: 0 for Hamming, 1 for Hann.

iscal -- amplitude scaling (defaults to 1).

Performance

ain -- input audio signal.

ffr -- output PV stream in AMP_FREQ format, with magnitudes and frequencies in Hz.

fphs -- output PV stream in AMP_PHASE format, with magnitudes and phases in radians, wrapped to the range from -pi to pi.

Both outputs have nonnegative magnitudes, including at DC and Nyquist. At those two bins, a negative real coefficient has phase pi; a positive or zero coefficient has phase zero.

⚠ 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

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

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

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

instr 1

ifftsize    =   p4
ihopsize    =   p5
ain     diskin2  "drumsMlp.wav", 1, 0, 1                  
fs1,fsi2 pvsifd  ain, ifftsize, ihopsize, 1             ; pvsifd analysis
fst     partials fs1, fsi2, .1, 1,3, 500        ; partial tracking
aout    resyn    fst, 1, 1.5, 500, 1            ; resynthesis (up a 5th)
        outs    aout, aout

endin
</CsInstruments>
<CsScore>
;sine
f1 0 4096 10 1
;           size    hop
i 1 0 2     2048    512  
i 1 3 2     1024    256      
e
</CsScore>
</CsoundSynthesizer>

The example above shows the pvsifd analysis feeding into partial tracking and cubic-phase additive resynthesis with pitch shifting.

See also

Tools for Real-time Spectral Processing (pvs opcodes)

Credits

Author: Victor Lazzarini
June 2005

New plugin in version 5

November 2004.