Where to do processing?
-
- KVRAF
- 2458 posts since 3 Oct, 2002 from SF CA USA NA Earth
Per sample, you want to avoid unnecessary function calls. By using inline functions, you can write code the way you're supposed to but avoid the performance hit of function calls. Under MSVC, you will want to use the __forceinline keyword and double-check the assembly output to be sure things were inlined.
-
- KVRAF
- 4641 posts since 20 Feb, 2004 from Gothenburg, Sweden
Just don't use any virtual methods if you want to inline stuff. But, if you don't do a "per-sample-based" synth and work on frames instead, you should design as efficiently as you can with frames. Some stuff does not need to be calculated per sample.
Stefan H Singer
Musician, coder and co-founder of We made you look Web agency
Musician, coder and co-founder of We made you look Web agency
-
- KVRian
- 1325 posts since 1 Sep, 2004
Maybe it's more a conceptional question.gav_b wrote:Would it be recommended to do all the real-time sample processing inside processReplacing/process or put everything in functions?
Probably you will start with a clear modular structure to get the concept basicly working and to keep the overview.
After this, you can successive analyze, profile and optimize your code, move functions to inline and see what is neccessry per sample and what not (per audio block)...
Other questions occur, if you want to build entire frameworks for re-use in the manner of "building blocks". This mostly happens, if you want to build more than one plugin in the future and/or want to easy reuse the code fragments. (Infact a smart modularity can improve many things, even in DSP programming.)
In that case you probably will take more attention on reusability and easy exchangebility of your functions and classes, than on extreme performance optimizations.
To achieve both, is definately not that easy and introduces allot of compromises never the less.
In fact, a good structurized code is a solid base for any improvement and extension.
Because only very view people are actually able to produce highly optimized code of big complexity on demand (and then keep really the overview of their entire output over the time)...
And don't forget, that in the meantime most compilers do a great job for optimizing your code automatically. In many situations you will lose the fight against the highly optimizing compilers and also lose the benefits of a well structurized programming this way. Then, once, you probably will need days to introduce yourself into your own written code (this are at least my experienxces).