[Sndobj-devel] quick question...
Status: Abandoned
Brought to you by:
veplaini
From: Rory W. <ror...@ea...> - 2007-01-25 10:53:56
|
Am I correct to assume that the following code which uses SndObj's PushIn() method is just as efficient as writing a simple class and calling it's DoProcess()? int main(int argc, char** argv) { int dur = 10; float* sample; float index; float incr; int freq=420; int length = 256; float table[256]; SndObj test; SndRTIO output(1, SND_OUTPUT); SndObj mySndObj(&test); output.SetOutput(1, &mySndObj); for(int i=0; i < length; i++) table[i] = sin(i*2*PI/length); for(int i=0; i<dur*(DEF_SR/DEF_VECSIZE); i++) { for(int y=0;y<DEF_VECSIZE;y++) { *sample = 10000*table[(int)index]; incr = freq*length/DEF_SR; index += incr; while(index >= length) index -= length; while(index < 0) index += length; mySndObj.PushIn(sample, 1); } output.Write(); } return 1; } I'm aware of the different oscillator classes available in the SndObj library, and obviously building a simple class would be more elegant, this is just something I'm preparing for pedagogic purposes. Cheers, Rory. |