pvstrace
Process a PV stream by retaining only the N bins with the highest amplitude, zeroing the others.
Syntax
Initialization
isort -- if nonzero, list the selected bins in decreasing amplitude order. Otherwise, list them in increasing bin-number order. Default: 0.
imin, imax -- search range in bin numbers, including imin and excluding imax. Bin numbers start at 0. An imax of 0 includes all bins from imin through Nyquist. Both default to 0, which searches the whole frame.
Csound discards fractional parts and limits values beyond the frame to its end. Negative limits cause an initialization error. If the resulting range is empty or reversed, the output is silent and the bin array contains zeros. For example, limits of 2 and 6 search bins 2, 3, 4, and 5.
Performance
fsig -- output PV stream. Selected bins retain their input amplitude and frequency or phase; all other bins are zero.
kBins[] -- array of fftsize/2 + 1 values. The first values list the selected bin numbers; the remaining values are zero. isort controls their order.
fsigin -- input PV stream in amplitude/frequency or amplitude/phase format. Sliding analyses are not supported.
kn -- number of bins to retain from the search range. Csound discards the fractional part, treats values below 1 as 1, and limits the count to the number of bins in the range.
When amplitudes tie, lower bin numbers take priority. Sorting the bin list does not change which bins the output retains.
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 pvstrace opcode. It uses the file pvstrace.csd.
See also
Tools for Real-time Spectral Processing (pvs opcodes)
Credits
Author: Victor Lazzarini
2017
New plugin in version 6.09