Skip to content

tabifd

Instantaneous Frequency Distribution, magnitude and phase analysis.

The tabifd opcode takes an input function table and performs an Instantaneous Frequency, magnitude and phase analysis, using the STFT and tabifd (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 = tabifd(ktimpt, kamp, kpitch, ifftsize, ihopsize, iwintype,ifn)
ffr,fphs tabifd ktimpt, kamp, kpitch, ifftsize, ihopsize, iwintype,ifn

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. The opcode produces at most one frame per control period, so use a hop size of at least ksmps to receive every frame.

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

ifn -- source function table

Performance

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.

ktimpt -- position in seconds at which to start reading. Reading wraps at the table boundaries and uses linear interpolation between samples, including at negative positions.

kamp -- amplitude scaling

kpitch -- table samples to advance per analysis sample: 1 reads forward at the original pitch, -1 reads backward, and 0 holds the value at ktimpt.

Examples

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

Example of the tabifd 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 tabifd.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>
sr=44100
ksmps=1
nchnls=1
0dbfs=1
opcode TrackPlay, a, kkiiii
 ktime,kthr,isiz,ihsiz,ifcos,ifn  xin 
 idel = isiz-ihsiz*(isiz/(2*ihsiz)-1)
 ffr,fphs tabifd ktime,10000,1, isiz, ihsiz, 1, ifn
 ftrk partials ffr, fphs,kthr, 1, 1, 500
 aout tradsyn   ftrk, 2,1, 500, ifcos 
 xout aout
endop
instr 1
p3 = ftlen(2)/sr
ktime line 0,p3,p3
ares TrackPlay ktime, 0.003,2048,256,1,2
     outs ares
endin

</CsInstruments>
<CsScore>
f1 0 16384 9 1 1 90
f2 0 0 1 "fox.wav" 0 0 1
i1      0 1 
</CsScore>
</CsoundSynthesizer>

The example above shows the tabifd analysis feeding into partial tracking andcubic-phase additive resynthesis with pitch shifting.

See also

Tools for Real-time Spectral Processing (pvs opcodes)

Credits

Author: Victor Lazzarini
Aug 2015

New plugin in version 6

Aug 2015