Afficher un message
Vieux 17/10/2007, 03h27   #3
Andre Kostur
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: pasing an array pointer and storing as a class member

"BobR" <removeBadBobR@worldnet.att.net> wrote in
news:BvcRi.226524$ax1.159736@bgtnsc05-news.ops.worldnet.att.net:

>
> stephen b <kernel@audiospillage.com> wrote in message
> news:1192563109.115307.88440@i38g2000prf.googlegro ups.com...
>> 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.
>>

>
> By the time you initialize your raw arrays, there should be very
> little difference with std::vectors. (you don't need the '0.0' in
> init, it is the default.)


Keep in mind that std::vector has to do (Well, is very likely to do)
dynamic memory to store its contents. Arrays do not. You might try
std::tr1:array instead...
  Réponse avec citation
 
Page generated in 0,05298 seconds with 9 queries