Skip to content

pvsftr

Reads amplitude and/or frequency data from function tables.

Syntax

pvsftr(fsrc, ifna [, ifnf])
pvsftr fsrc, ifna [, ifnf]

Initialization

ifna -- Table number for amplitude data. Use 0 to leave the signal's amplitudes unchanged.

ifnf (optional) -- Table number for frequency data, or phase data when fsrc uses amplitude/phase format. The default is 0, which leaves these values unchanged.

Each enabled table needs room for N/2 + 1 values, where N is the signal's FFT size. These include the DC and Nyquist bins. The table's guard point can hold the last value.

Performance

fsrc -- A non-sliding spectral signal in amplitude/frequency or amplitude/phase format. pvsftr modifies this signal in place. Reinitialize pvsftr if the signal's FFT size or format changes.

pvsftr reads the enabled tables at initialization and whenever a new frame is available in fsrc. Editing a table does not cause another read of the same frame. To change only frequency data, set ifna to zero.

When used with pvsftw, edit the tables when that opcode's kflag is 1, then call pvsftr to read the edited values back into the signal.

As the function tables are required only to store data from fsrc, there is no advantage in defining then in the score, and they should generally be created in the instrument, using ftgen.

By exporting amplitude data, say, from one fsig and importing it into another, basic cross-synthesis (as in pvscross) can be performed, with the option to modify the data beforehand using the table manipulation opodes.

Note that the format data in the source fsig is not written to the tables. This therefore offers a means of transferring amplitude and frequency data between non-identical fsigs. Used this way, these opcodes become potentially pathological, and can be relied upon to produce unexpected results. In such cases, resynthesis using pvsadsyn would almost certainly be required.

To perform a straight copy from one fsig to another one of identical format, the conventional assignment syntax can be used:

fsig1 = fsig2

It is not necessary to use function tables in this case.

Examples

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

Example of the pvsftr 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 pvsftr.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

ifftsize = 1024                         ;fft size
ioverlap = 256                          ;overlap
knewamp  = 0                            ;new value for amplitudes

;create fsig stream from function table
fsrc    pvstanal 1, 1, 1, gifil, 0, 0, 0, ifftsize, ioverlap, 0
ifn     ftgen   0, 0, ifftsize/2, 2, 0  ;create empty function table
kflag   pvsftw  fsrc,ifn                ;export amps to table   
;overwrite the first 10 bins each time the table has been filled new
if kflag == 1 then
kndx = 0
kmaxbin = p4
loop:
tablew knewamp, kndx, ifn
loop_le kndx, 1, kmaxbin, loop
endif
        pvsftr  fsrc,ifn                ;read modified data back to fsrc
aout    pvsynth fsrc                    ;and resynth
        outs    aout, aout

endin
</CsInstruments>
<CsScore>
;           maxbins
i 1 0 4       10
i 1 4 4       100
e
</CsScore>
</CsoundSynthesizer>

See also

Tools for Real-time Spectral Processing (pvs opcodes)

Credits

Author: Richard Dobson
August 2001

New in version 4.13