Afficher un message
Vieux 16/10/2007, 20h31   #1
stephen b
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: pasing an array pointer and storing as a class member

On 14 Oct, 19:56, "BobR" <removeBadB...@worldnet.att.net> wrote:
> stephen b wrote in message...
>
> > I am using arrays instead of vector<double> because I found the
> > initialisation of many vector<double>s caused brief CPU spikes each
> > time an object is created.

>
> I'm curious. How did you initialize the vectors?
>
> > Arrays seemed less troublesome which is
> > important for real-time DSP stuff.

>
> I think it's the opposite. :-}


really? right, I think I initialised my vectors like this:
vector<double> vec (8192, 0.); so I guess maybe filling the array
with zeros was causing some overhead. I also found arrays to be
slightly more efficient in use although it's probably negligible even
though I'll be using 20 or so per synth.


> Could it be because you are dereferenceing un-initialized data (the arrays)?
> Let's test something. In your FilterSynth() constructor:
>
> FilterSynth(){
> for( int i(0); i < 10; ++i ){
> std::cout<< filtIn[ i ] <<'\n';
> } // for(i)
> } // Ctor
>
> What's your output from that? (I got garbage (UB)).


well with the filter example I fill the array with zeros first but
otherwise just garbage.

Stephen.

  Réponse avec citation
 
Page generated in 0,05736 seconds with 9 queries