pvscale — Scale the frequency components of a pv stream.
Scale the frequency components of a pv stream, resulting in pitch shift. Output amplitudes can be optionally modified in order to attempt formant preservation.
fsig -- output pv stream
fsigin -- input pv stream
kscal -- scaling ratio.
kkeepform -- attempt to keep input signal formants; 0: do not keep formants; 1: keep formants using a liftered cepstrum method; 2: keep formants by using a true envelope method (defaults to 0).
kgain -- amplitude scaling (defaults to 1).
kcoefs -- number of cepstrum coefs used in formant preservation (defaults to 80).
The quality of the pitch shift will be improved with the use of a Hanning window in the pvoc analysis. Formant preservation method 1 is less intensive than method 2, which might not be suited to realtime use.
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. |
Example 818. Example
asig in ; get the signal in fsig pvsanal asig, 1024, 256, 1024, 1 ; analyse it ftps pvscale fsig, 1.5, 1, 1 ; transpose it keeping formants atps pvsynth ftps ; synthesise it adp delayr 0.1 ; delay original signal adel deltapn 1024 ; by 1024 samples delayw asig out atps + adel ; add tranposed and original
The example above shows a vocal harmoniser. The delay is necessary to time-align the signals, as the analysis-synthesis process will imply a delay of 1024 samples between the analysis input and the synthesis output.
Here is an example of the use of the pvscale opcode. It uses the file pvscale.csd.
Example 819. Example of the pvscale 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 ; Audio out Audio in -odac ;;;RT audio I/O ; For Non-realtime ouput leave only the line below: ; -o pvscale.wav -W ;;; for file output any platform </CsOptions> <CsInstruments> sr = 44100 ksmps = 32 nchnls = 2 0dbfs = 1 ;; example written by joachim heintz 2009 instr 1 ifftsize = 1024 ioverlap = ifftsize / 4 iwinsize = ifftsize iwinshape = 1; von-Hann window Sfile = "fox.wav" ain soundin Sfile fftin pvsanal ain, ifftsize, ioverlap, iwinsize, iwinshape; fft-analysis of the audio-signal fftblur pvscale fftin, p4, p5, p6; scale aout pvsynth fftblur; resynthesis outs aout*.5, aout*.5 endin </CsInstruments> <CsScore> i 1 0 3 1 0 1 ; original sound i 1 3 3 1.5 0 2 ; fifth higher without ... i 1 6 3 1.5 1 2 ; ... and with different ... i 1 9 3 1.5 2 5 ; ... kinds of formant preservation e </CsScore> </CsoundSynthesizer>