[chuck-users] Sample Playback Efficiency

Juan-Pablo Caceres jcaceres at ccrma.stanford.edu
Mon Nov 26 18:07:36 EST 2007


Dear list,

Lets say I have an array of SndBuf, and I want to playback one of the 
samples each time. What is the most efficient way? What I am doing is 
just connecting everything to dac, and then setting all but one of the 
gains to non-zero, something like this:

SndBuf buf[20];
for ( 0 => int i; i < 20; i++ )  {
         sample_names[i] => buf[i].read; //assuming I have an array of
					//string names
         buf[i] => dac;
         0. => buf[i].gain;
     }

//then to playback one at the time:
int isamp;
while (true) {
         Std.rand2(0, 19 ) => isamp;
	0 => buf[isamp].pos;
         0.1 => buf[isamp].gain; //set gain to something different
				// than zero
         200::ms => now;
         0. => buf[isamp].gain; //bring it back to zero
     }


This works, but doesn't feel right. All the DSP connections are made, so 
I would guess this is inefficient. The other option will be to connect 
(=>) and disconnect (=<) dynamically but that solution also feels wrong...

Any ideas? Thanks so much again,
Juan-Pablo




More information about the chuck-users mailing list