pvsmorph
Performs morphing (or interpolation) between two source fsigs.
Syntax
pvsmorph interpolates the amplitudes and frequencies of two input spectra. Unlike pvinterp, it uses _fsig_s instead of analysis files and does not preserve the spectral envelope.
fsig1, fsig2 -- input spectra, such as those produced by pvsanal. Both must use the same FFT size, hop size, window size, window type, and format. Amplitude/frequency and amplitude/phase formats are supported. Both inputs must use the same analysis mode: ordinary frames or sliding analysis. Reinitialize pvsmorph if these settings change.
kampint -- amplitude blend. A value of 0 selects amplitudes from fsig1; 1 selects amplitudes from fsig2. Values between 0 and 1 give a linear blend.
kfrqint -- frequency blend, independent of kampint. A value of 0 selects frequencies from fsig1; 1 selects frequencies from fsig2. For amplitude/phase input, this control blends phases linearly instead.
Both blend controls are limited to the range 0 to 1. Ordinary analysis produces a new output frame when fsig1 supplies a new frame. Sliding analysis processes a spectrum for each active audio sample.
Warning
Use an output f-variable distinct from both inputs. pvsmorph reports an initialization error if an input is also its output.
Examples
Here is an example of the pvsmorph opcode. It uses the file pvsmorph.csd.
| Example of the pvsmorph opcode. |
|---|
| <CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
; Audio out Audio in
-odac ;;;RT audio I/O
; For Non-realtime ouput leave only the line below:
; -o pvsmorph.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
;; example written by joachim heintz 2009
; additions by Menno Knevel 2021
giSine ftgen 0, 0, 4096, 10, 1
instr 1
iampint1 = p4
iampint2 = p5
ifrqint1 = p6
ifrqint2 = p7
kampint linseg iampint1, p3*.2, iampint1, p3*.6, iampint2, p3*.2, iampint2
kfrqint linseg ifrqint1, p3*.2, ifrqint1, p3*.6, ifrqint2, p3*.2, ifrqint2
ifftsize = 1024
ioverlap = ifftsize / 4
iwinsize = ifftsize
iwinshape = 1 ; von-Hann window
Sfile1 = "fox.wav"
ain1 diskin2 Sfile1, 1, 0, 1
kfreq line 30, p3, 500
ain2 buzz .8, kfreq, 50, giSine
fftin1 pvsanal ain1, ifftsize, ioverlap, iwinsize, iwinshape
fftin2 pvsanal ain2, ifftsize, ioverlap, iwinsize, iwinshape
fmorph pvsmorph fftin1, fftin2, kampint, kfrqint
aout pvsynth fmorph
outs aout * .6, aout * .6
endin
</CsInstruments>
<CsScore>
; iampint1 iampint2 ifrqint1 ifrqint2
i 1 0 12.2 0 0 1 1
i 1 14 12.2 1 0 1 0
i 1 28 12.2 0 1 0 1
e
</CsScore>
</CsoundSynthesizer>
|
Here is another example of the pvsmorph opcode. It uses the file pvsmorph2.csd.
| Example of the pvsmorph opcode. |
|---|
| <CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
; Audio out Audio in
-odac ;;;RT audio I/O
; For Non-realtime ouput leave only the line below:
; -o pvsmorph-2.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
;; example written by joachim heintz 2009, additions by Menno Knevel 2021
; this example uses the files "flute.aiff" and "saxophone-alto-C-octave0.wav"
instr 1
iampint1 = p4 ; value for interpolating the amplitudes at the beginning ...
iampint2 = p5 ; ... and at the end
ifrqint1 = p6 ; value for unterpolating the frequencies at the beginning ...
ifrqint2 = p7 ; ... and at the end
kampint linseg iampint1, p3, iampint2
kfrqint linseg ifrqint1, p3, ifrqint2
ifftsize = 1024
ioverlap = ifftsize / 4
iwinsize = ifftsize
iwinshape = 1 ; von-Hann window
Sfile1 = "flute.aiff"
Sfile2 = "saxophone-alto-C-octave0.wav"
ain1 soundin Sfile1
ain2 soundin Sfile2
fftin1 pvsanal ain1, ifftsize, ioverlap, iwinsize, iwinshape
fftin2 pvsanal ain2, ifftsize, ioverlap, iwinsize, iwinshape
fmorph pvsmorph fftin1, fftin2, kampint, kfrqint
aout pvsynth fmorph
outs aout , aout
endin
instr 2 ; moving randomly in certain borders between two spectra
iampintmin = p4 ; minimum value for amplitudes
iampintmax = p5 ; maximum value for amplitudes
ifrqintmin = p6 ; minimum value for frequencies
ifrqintmax = p7 ; maximum value for frequencies
imovefreq = p8 ; frequency for generating new random values
kampint randomi iampintmin, iampintmax, imovefreq
kfrqint randomi ifrqintmin, ifrqintmax, imovefreq
ifftsize = 1024
ioverlap = ifftsize / 4
iwinsize = ifftsize
iwinshape = 1 ; von-Hann window
Sfile1 = "flute.aiff"
Sfile2 = "saxophone-alto-C-octave0.wav"
ain1 soundin Sfile1
ain2 soundin Sfile2
fftin1 pvsanal ain1, ifftsize, ioverlap, iwinsize, iwinshape
fftin2 pvsanal ain2, ifftsize, ioverlap, iwinsize, iwinshape
fmorph pvsmorph fftin1, fftin2, kampint, kfrqint
aout pvsynth fmorph
outs aout, aout
endin
</CsInstruments>
<CsScore>
i 1 0 3 0 0 1 1 ; amplitudes from flute, frequencies from saxophone
i 1 3 3 1 1 0 0 ; amplitudes from saxophone, frequencies from flute
i 1 6 3 0 1 0 1 ; amplitudes and frequencies moving from flute to saxophone
i 1 9 3 1 0 1 0 ; amplitudes and frequencies moving from saxophone to flute
i 2 13 3 .2 .8 .2 .8 10 ; amps and freqs moving randomly between the two spectra
e
</CsScore>
</CsoundSynthesizer>
|
See also
Tools for Real-time Spectral Processing (pvs opcodes)
Credits
Author: Victor Lazzarini
April 2007
New in Csound 5.06