Re: [Sndobj-devel] quick question...
Status: Abandoned
Brought to you by:
veplaini
From: Victor L. <Vic...@nu...> - 2007-01-25 11:10:48
|
I'd say it's OK in terms of efficiency. I would move the PushIn to outside the inner loop and call it with DEF_VECSIZE, so you are consuming more samples per function call. You will need to make 'sample' a block of floats. Since you are not doing any function calls in the inner loop, it's probably as efficient as using a SndObj (or even more). Victor At 10:53 25/01/2007, Rory Walsh wrote: >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. > > >------------------------------------------------------------------------- >Take Surveys. Earn Cash. Influence the Future of IT >Join SourceForge.net's Techsay panel and you'll get the chance to share your >opinions on IT & business topics through brief surveys - and earn cash >http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV >_______________________________________________ >Sndobj-devel mailing list >Snd...@li... >https://lists.sourceforge.net/lists/listinfo/sndobj-devel Victor Lazzarini Music Technology Laboratory Music Department National University of Ireland, Maynooth |