Hello,
I have more C++ question then JUCE or audio at all.
I would ask that on stackoverflows, but they ban me for to much stupid questions ![]()
I am working now on optimisation of my plugin, where I have implemented my own FFT algorithm, so that’s quite heavy calculations.
I’ve heard that C++ works faster (more optimal) if the variables are stored in momory blocks that are as near to each other as possible.
So in concern to class creations I always wonder if faster is create variables as a class member, for example:
public: float someFloat;
and define it for example in constructor, for example like that:
someFloat = 20.0f * log10((double)someVector.size()) / someOtherClassVariable.getSomeValue();
and then use that someFloat in some method where I have some quite big loop like that:
void calcMethod() { for(int i=0; i<bigMaaan; ++i) { for(int j=0; j<bigWoman; ++j) outputValue[i][someIndexVector[j]] = someFloat * something; } }
Or maybe better would be just like that:
void calcMethod() { float someFloat = 20.0f * log10((double)someVector.size()) / someOtherClassVariable.getSomeValue(); for(int i=0; i<bigMaaan; ++i) { for(int j=0; j<bigWoman; ++j) outputValue[i][someIndexVector[j]] = someFloat * something; } }
???
And other question about someIndexVector from example above. Where is the best place in the class to define it and all it’s members, to avoid compiler jumps like crazy throug memory blocks?
Or maybe better would be to calculate it in place, like that:
outputValue[i][(i*(int)someDouble)%(someComponen.getWidth()*(j+1))] = someFloat * something;
Please don’t ask about calculations at all, they have no sense, just wonted to show that there are some complicated (from human point of view) operations.
Could anyone give me some hints?
Great thanks in advance.

