Skip to content

pvsmaska

Modify amplitudes using a function table, with dynamic scaling.

Syntax

fsig pvsmaska fsrc, ifn, kdepth

Initialization

ifn -- The f-table to use. Given fsrc has N analysis bins, table ifn must be of size N or larger. The table need not be normalized, but values should lie within the range 0 to 1. It can be supplied from the score in the usual way, or from within the orchestra by using pvsinfo to find the size of fsrc, (returned by pvsinfo in inbins), which can then be passed to ftgen to create the f-table.

Performance

kdepth -- Controls the degree of modification applied to fsrc, using simple linear scaling. 0 leaves amplitudes unchanged, 1 applies the full profile of ifn.

Note that power-of-two FFT sizes are particularly convenient when using table-based processing, as the number of analysis bins (inbins) is then a power-of-two plus one, for which an exactly matching f-table can be created. In this case it is important that the f-table be created with a size of inbins, rather than as a power of two, as the latter will copy the first table value to the guard point, which is inappropriate for this opcode.

⚠ 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