GEN43 — Loads a PVOCEX file containing a PV analysis.
This subroutine loads a PVOCEX file containing the PV analysis (amp-freq) of a soundfile and calculates the average magnitudes of all analysis frames of one or all audio channels. It then creates a table with these magnitudes for each PV bin.
size -- number of points in the table, power-of-two or power-of-two plus 1. GEN 43 does not make any distinction between these two sizes, but it requires the table to be at least the fftsize/2. PV bins cover the positive spectrum from 0Hz (table index 0) to the Nyquist (table index fftsize/2+1) in equal-size frequency increments (of size sr/fftsize).
filcod -- a pvocex file (which can be generated by pvanal).
channel -- audio channel number from which the magnitudes will be extracted; a 0 will average the magnitudes from all channels.
Reading stops at the end of the file.
![]() |
Note |
---|---|
if p4 is positive, the table will be post-normalised. A negative p4 will cause post-normalisation to be skipped. |
This is a selection of some reverb and noise of the sound file. The selection has a duration of 0.8 seconds. We need this duration for the Csound utility pvanal to create the pvocex file.
Here is an example of the GEN43 routine. It uses the files gen43.csd.
Example 1301. An example of the GEN43 routine.
<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 GEN43.wav -W ;;; for file output any platform </CsOptions> <CsInstruments> ; by Menno Knevel 2021 sr = 44100 ksmps = 32 nchnls = 2 0dbfs = 1 ; Audacity shows the selection of reverb and noise- see image above instr 1 ; analyze this selection and output result to pvx file ires system_i 1,{{ pvanal -b1.04 -d0.8 finneganswake1.flac reverbnoise.pvx }} endin instr 2 ; untreated signal, contains some reverb and noise asig diskin2 "finneganswake1.flac", 1 outs asig, asig endin instr 3 ; use .pvx file from instr. 1 to remove reverb and noise ; pvanal created 1 frame of size 1024, so size of table for GEN 43 = 512 (fftsize/2) ipvx ftgen 1, 0, 512, -43, "reverbnoise.pvx", 0 ; can be found in examples folder asig diskin2 "finneganswake1.flac", 1 fsig pvsanal asig, 1024, 256, 1024, 1 fclean pvstencil fsig, 0, 1, ipvx ; maximum cleaning aclean pvsynth fclean outs aclean, aclean endin </CsInstruments> <CsScore> i1 0 2 ; first analyze i2 5 12.7 ; untreated signal i3 20 12.7 ; denoised gignal e </CsScore> </CsoundSynthesizer>
These tables can be used as a masking table for pvstencil and pvsmaska.
f1 0 512 43 "viola.pvx" 1 f1 0 -1024 -43 "noiseprint.pvx" 0
The first example uses a 1024-point FFT phase vocoder analysis file from which the first channel is used. The second uses all channels of a 2048-point file, without post-normalisation. For noise reduction applications with pvstencil, it is easiest to skip table normalisation (negative GEN code).