Skip to content

pvsmaska

Modify amplitudes using a function table, with dynamic scaling.

Syntax

fsig = pvsmaska(fsrc, ifn, kdepth)
fsig pvsmaska fsrc, ifn, kdepth

Initialization

ifn -- The mask table, with one value per analysis bin, from DC through Nyquist. Use pvsinfo to get the bin count and ftgen to create a table of that size. Values between 0 and 1 attenuate the signal; values above 1 amplify it. At initialization, pvsmaska replaces negative values in the table with zero.

Performance

kdepth -- Blends between unchanged amplitudes (0) and the full mask (1). Values outside this range are clipped with a warning. For each bin, the gain is (1 - kdepth) + kdepth * mask_value.

fsrc must use amplitude+frequency (format 0) or amplitude+phase (format 1). The output keeps the input frequencies or phases unchanged. Reinitialize pvsmaska when changing the input's analysis properties, such as FFT size or sliding mode.

For ordinary analysis frames, the mask and depth take effect when a new input frame arrives. For sliding signals, they apply to every active sample in the control block. Samples before the note starts or after it ends have zero output.

For a power-of-two FFT size, use a table size of ifftsize / 2 + 1 so you can set the Nyquist-bin value explicitly. A power-of-two table size uses its guard point for that bin, which may repeat the first table value.

⚠ 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 use of the pvsmaska opcode. It uses the file pvsmaska.csd.

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

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

;; example written by joachim heintz 2009

; function table for defining amplitude peaks (from the example of Richard Dobson)
giTab           ftgen           0, 0, 513, 8, 0, 2, 1, 3, 0, 4, 1, 6, 0, 10, 1, 12, 0, 16, 1, 32, 0, 1, 0, 436, 0

instr 1
imod            = p4; degree of midification (0-1)
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
fmask           pvsmaska        fftin, giTab, imod
aout            pvsynth fmask; resynthesize
out             aout, aout
endin

</CsInstruments>
<CsScore>
i 1 0 2.757 0 
i 1 3 2.757 .5
i 1 6 2.757 1
e
</CsScore>
</CsoundSynthesizer>

See also

Tools for Real-time Spectral Processing (pvs opcodes)

Credits

Author: Richard Dobson
August 2001

New in version 4.13