Csound Csound-dev Csound-tekno Search About

[Csnd] pvsbuffer - store many buffers, share between instruments

Date2012-10-16 13:32
FromTarmo Johannes
Subject[Csnd] pvsbuffer - store many buffers, share between instruments
Hello,

I would like to store a number of pvs buffers from live input and later 
use them in another instrument with   pvsbufread.

My plan was to store the buffer handles in a table but it does not work 
since the table gets populated always with 0-s and thus only the last 
recorded buffer can be reached.

I know I could use giBuf1, giBuf2 etc and set up the cascade of huge 
number of if-else statements, but there must bbe a better solution.


My writing instrument is called in specific moment and  looks like:

instr writebuf
	prints "BUFWRITE"
	ibufindex = p4
	ibuflen = p3
	fsig  pvsanal     gaBufSig, 1024, 256, 1024, 1
	ktime		line 0,ibuflen,ibuflen
	ibuf, ktime  pvsbuffer   fsig, ibuflen 
	print ibuf,ibufindex
	tabw_i ibuf, ibufindex, giBufIndexes ; store the index in table
	gaBufSig = 0
endin

to play the buffer back I used:

instr bufout
	prints "BUFOUT"
	ibufindex = p4
	ibuf tab_i ibufindex, giBufIndexes
	;print ibufindex,ibuf
	ktime expon 0.1 ,p3,$BUFLEN-0.1
	fread  pvsbufread  	ktime, giBuffer1;ibuf
	aout		pvsynth	fread
	kenv linen 1,0.1,p3,1
	out		aout*kenv*gkLevel,aout*kenv*gkLevel
endin


What I used one long buffer with a global variable handele like 
giBigBuffer and stored the info to specific time-areas, like
1st clip to seconds 0..3, second 4..7 etc?

I did not try yet, but I am afraid every new pvsbuffer call would erase the 
whole buffer and previously stored data will be erased?

thanks,
tarmo