pvsbufread
Prev | Orchestra Opcodes and Operators | Next

## pvsbufread

pvsbufread — This opcode reads a circular buffer of f-signals (streaming PV signals).

## Description

This opcode sets up and writes to a circular buffer of length ilen (secs), giving a handle for the buffer and a time pointer, which holds the current write position (also in seconds). It can be used with one or more pvsbufread opcodes. Writing is circular, wrapping around at the end of the buffer.

## Syntax

    fsig pvsbufread  ktime, khandle[, ilo, ihi]

## Initialisation

ilo, ihi -- set the lowest and highest freqs to be read from the buffer (defaults to 0, Nyquist).

fsig -- output pv stream

ktime -- time position of reading pointer (in secs).

khandle -- handle identifying the buffer to be read. When using k-rate handles, it is important to initialise the k-rate variable to a given existing handle. When changing buffers, fsig buffers need to be compatible (same fsig format).

pvsbufread reads f-signals from a buffer created by

With this opcode and pvsbuffer, it is possible to, among other things:

| Note
It is important that the handle value passed to pvsbufread is valid and was created by pvsbuffer. Csound will crash with invalid handles.

## Examples

Here is an example of the pvsbufread opcode. It does 'brassage' by switching between two buffers.

Example 468. Example of the pvsbufread opcode

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

    fsig1   pvsanal   asig1,1024,256,1024,1
    fsig2   pvsanal   asig2,1024,256,1024,1

    ibuf1,kt1   pvsbuffer   fsig1, 10  ; 10-sec buf with fsig1
    ibuf2,kt2   pvsbuffer  fsig2, 7      ; 7-sec buf with fsig2

    khan init ibuf1    ; initialise handle to buf1

    if  ktrig  > 0 then   ; switch buffers according to trigger
    khan = ibuf2
    else
    khan = ibuf1
    endif

    fsb  pvsbufread  kt1, khan   ; read buffer

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

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

    sr = 44100
    ksmps = 16
    nchnls = 1
    0dbfs = 1

    ;; example written by joachim heintz 2009

    opcode FileToPvsBuf, iik, Siiii
    ;;writes an audio file at the first k-cycle to a fft-buffer (via pvsbuffer)
    Sfile, ifftsize, ioverlap, iwinsize, iwinshape xin
    ktimek		timeinstk
    if ktimek == 1 then
    ilen		filelen	Sfile
    kcycles	=		ilen * kr; number of k-cycles to write the fft-buffer
    kcount		init		0
    loop:
    ain		soundin	Sfile
    fftin		pvsanal	ain, ifftsize, ioverlap, iwinsize, iwinshape
    ibuf, ktim	pvsbuffer	fftin, ilen + (ifftsize / sr)
    		loop_lt	kcount, 1, kcycles, loop
    		xout		ibuf, ilen, ktim
    endif
    endop

    instr 1
    ifftsize	=		1024
    ioverlap	=		ifftsize / 4
    iwinsize	=		ifftsize
    iwinshape	=		1; von-Hann window
    ibuffer, ilen, k0		FileToPvsBuf	"fox.wav", ifftsize, ioverlap, iwinsize, iwinshape
    ktmpnt		linseg		ilen, p3, 0; reads the buffer backwards in p3 seconds
    fread 		pvsbufread  	ktmpnt, ibuffer
    aout		pvsynth	fread
    		out		aout
    endin

    </CsInstruments>
    <CsScore>
    i 1 0 5
    e
    </CsScore>
    </CsoundSynthesizer>

## See Also

pvsanal, pvsynth, pvsbuffer, pvsadsyn

## Credits

Author: Victor Lazzarini
July 2007

Prev | Up | Next
pvsbuffer | Home | pvscale