Skip to content

pvsfread

Read a selected channel from a PVOC-EX analysis file.

Create an fsig stream by reading a selected channel from a PVOC-EX analysis file loaded into memory, with frame interpolation. Only format 0 files (amplitude+frequency) are currently supported. The operation of this opcode mirrors that of pvoc, but outputs an fsig instead of a resynthesized signal.

Syntax

fsig pvsfread ktimpt, ifn [, ichan]

Initialization

ifn -- Name of the analysis file. This must have the .pvx file extension.

A multi-channel PVOC-EX file can be generated using the extended pvanal utility.

ichan -- (optional) The channel to read (counting from 0). Default is 0.

Performance

ktimpt -- Time pointer into analysis file, in seconds. See the description of the same parameter of pvoc for usage.

Note that analysis files can be very large, especially if multi-channel. Reading such files into memory will very likely incur breaks in the audio during real-time performance. As the file is read only once, and is then available to all other interested opcodes, it can be expedient to arrange for a dedicated instrument to preload all such analysis files at startup.

Examples

Here is an example of the pvsfread opcode. It uses the file pvsfread.csd.

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

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

; analyze sound file, creating a PVOC-EX file
ires1 system_i 1,{{ pvanal stereoJungle.wav stereoJungle.pvx }} ; default settings

instr 1
; create a PVOC-EX (*.pvx) file with PVANAL first
idur  filelen   "stereoJungle.pvx"      ;find duration of (stereo) analysis file
kpos  line      0,p3,idur               ;to ensure we process whole file
fsigr pvsfread  kpos,"stereoJungle.pvx", 1  ;create fsig from right channel
aout  pvsynth   fsigr                   ;resynthesise it
      outs  aout, aout

endin
</CsInstruments>
<CsScore>

i 1 0 20    ; slow down
i 1 21 1    ; speed up
e
</CsScore>
</CsoundSynthesizer>

Here is another example of the pvsfread opcode. It uses the file pvsfread-2.csd.

Another example of the pvsfread 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 pvsfread-2.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

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

instr 1 ; play and analyze sound file, but one channel only

idur    filelen   "stereoJungle.wav"        ; check duration of sample  
prints  "\nsound file duration = %f\n", idur
ichn    filenchnls  "stereoJungle.wav"      ; check channels- a stereo sound!
prints  "number of channels = %f\n\n", ichn

asigL, asigR diskin2 "stereoJungle.wav"     ; stereo sound file
fss pvsanal  asigR, 1024, 256, 1024, 0      ; choose which channel- here the Right channel
pvsfwrite fss, "stereoJungle.pvx"           ; write that analyzed channel to pvocex file
ase pvsynth fss                             ; lets hear it
outs ase, ase

endin

instr 2 ; must be called after instr 1 finishes

prints  "\n--**analyzed file is played back**--\n\n"
idur    filelen   "stereoJungle.pvx"        ; find duration of (stereo) analysis file
kpos  line      0,p3,idur                   ; to ensure we process whole file
fsigr pvsfread  kpos,"stereoJungle.pvx", 0  ; read the fsig from this (= Right) channel
aout  pvsynth   fsigr                       ; resynthesise it
outs    aout, aout

endin
</CsInstruments>
<CsScore>
s
i 1 0 7
s
i 2 0 7
i 2 8 4     ; faster
e
</CsScore>
</CsoundSynthesizer>

See also

Tools for Real-time Spectral Processing (pvs opcodes)

Credits

Author: Richard Dobson
August 2001

New in version 4.13