Skip to content

pvsgain

Scale the amplitude of a pv stream.

Syntax

fsig = pvsgain(fsigin, kgain)
fsig pvsgain fsigin, kgain

Performance

fsig -- output pv stream

fsigin -- input pv stream in amplitude-frequency or amplitude-phase format

kgain -- amplitude multiplier. This argument is required. A value of 1 leaves the magnitudes unchanged; 0 sets them to zero. Frequencies or phases remain unchanged.

For frame-based input, gain changes take effect on the next new input frame. The output holds its values between frames. For sliding input, the current gain applies to each active sample in the control block.

You can restart the source with the same analysis settings while pvsgain keeps running. If you change the FFT size, hop size, window, or data format, reinitialize pvsgain too.

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

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

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

instr 1

kgain = p4
asig  diskin2   "drumsMlp.wav", 1
fsig  pvsanal   asig, 1024, 256, 1024, 1; analyse it
ftps  pvsgain   fsig, kgain             ; amplify it
atps  pvsynth   ftps                    ; synthesise it
      outs      atps, atps

endin
</CsInstruments>
<CsScore>

i1 0 2 .5
i1 + 2  1

e
</CsScore>
</CsoundSynthesizer>

See also

Tools for Real-time Spectral Processing (pvs opcodes)

Credits

Author: Victor Lazzarini
2011

New plugin in version 5

2011