pvstrace

pvstrace — Retain only the N loudest bins.

Description

Process a PV stream by retaining only the N bins with the highest amplitude, zeroing the others.

Syntax

fsig pvstrace fsigin, kn 
fsig, kBins[] pvstrace fsigin, kn[, isort] 

Initialization

isort -- if nonzero, sort the reported bins in kBins by decreasing amplitude, optional (default 0, off).

Performance

fsig -- output pv stream

kBins[] -- an array of size fftsize/2 + 1 values, whose first N values report the kn bin numbers retained by pvstrace. Other locations are set to 0. It can be sorted or unsorted.

fsigin -- input pv stream

kn -- number of bins to be retained

[Warning] 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.

Example 798. Example of the pvstrace opcode.

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

<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 pvstrace.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

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

instr 1

kn = p4
asig  diskin2	"beats.wav", 1
fsig  pvsanal   asig, 1024, 256, 1024, 1; analyse it
ftps  pvstrace   fsig, kn		; keep kn bins
atps  pvsynth   ftps			; synthesise it
      outs      atps, atps

endin
</CsInstruments>
<CsScore>
	
i1 0 2  5
i1 + 2  10
i1 + 2  20
i1 + 2  40
i1 + 2  80
i1 + 2  160
e
</CsScore>
</CsoundSynthesizer>


See Also

pvsanal, pvsynth, pvsadsyn

Credits

Author: Victor Lazzarini
2017

New plugin in version 6.09