ofxFFT and vectors

Hi everyone there,
I am trying to work with the advanced example of this addon.
I am trying to control with the audio input a shape that I create with a vector of random points.
So ideally instead of controlling the mesh vertices I should control the random shape vertices.
I am a bit stuck for few reasons.

  1. I am not sure what is the meaning of the & when you build a vector.
    (e.g., vector & vertsOriginal;)
  2. I get this error :
    ‘reference to type of Point requires an initializer’ and I think it’s connected with the & but can’t figure out how.
  3. I am not sure what would be the equivalent of getVertices of the ofMesh for controlling the random shape vertices

any help would be awesome!

cheers

That’s called a reference in C++. An english translation of the case you mention above would be “vertsOriginal is a reference to a vector”.

So in code, if you have something like:

int a = 5;
int b = a;

You end up with two ints, a and b, and they both equal 5. b is just a copy of a.

But in this case:

int a = 5;
int& b = a;

You only have one int (a), and a reference to the same int (b). If you were to do:

b = 10;

afterwards, the int “a” would also be 10, since a and b both refer to the same int.

Your error is probably due to the fact that a reference has to refer to something right when it gets created. You can’t just do int &b; and then decide what b refers to afterwards.

Hi Admsyn,
I think I got the meaning.
I am going back to the code and see if I can make it work.
Thanks for the clear explanation!
:sunny:

Got it!
It’s working.
thanks again!