Plug-ins, Hosts, Apps,
Hardware, Soundware
Developers
(Brands)
Videos Groups
Whats's in?
Banks & Patches
Download & Upload
Music Search
KVR
   
KVR Forum » DSP and Plug-in Development
Thread Read
A Collection of Useful C++ Classes for Signal Processing
Goto page Previous  1, 2, 3, ... 19, 20, 21  Next
mateo
KVRist
- profile
- pm
- e-mail
- www
PostPosted: Sat May 02, 2009 9:19 am reply with quote
Thanks for this! Have you considered hosting your code on google code or sourceforge? Seems to me it would be easier for both you and everyoe else that way...
^ Joined: 12 Oct 2001  Member: #1239  Location: montreal
thevinn
KVRian
- profile
- pm
- www
PostPosted: Sat May 02, 2009 9:29 am reply with quote
mateo wrote:
Thanks for this! Have you considered hosting your code on google code or sourceforge? Seems to me it would be easier for both you and everyoe else that way...


Yes I will do all of the above, once I am "done". I don't want to publish unfinished code. I put it up here so I can get feedback on what I need to do to make it perfect. So when we have it bronzed there are no defects.

Before I put it out for wide distribution I would like to let it settle for a couple of weeks and give people a chance to play with it. And also, independent confirmation of the filter's output (by measuring the magnitude and phase response).

I'm working on SSE3 optimized version of CascadeFilter, its looking promising.
^ Joined: 30 Nov 2008  Member: #194779  
MackTuesday
KVRist
- profile
- pm
- e-mail
- www
PostPosted: Sat May 02, 2009 11:54 am reply with quote
thevinn wrote:
I wrote a simple loop to time the performance of the filter. I generate random noise in a buffer and then run the low pass on the data over and over again.

After just 3000 iterations, I get denormals. The debugger shows the samples as -1.#IND00000000

Is running a filter on the same block of data over and over again supposed to do that?

No, sorry to say. A filter should produce bounded output for any bounded input.
^ Joined: 11 Jul 2004  Member: #32838  Location: Southern California, USA
thevinn
KVRian
- profile
- pm
- www
PostPosted: Sat May 02, 2009 11:56 am reply with quote
MackTuesday wrote:
No, sorry to say. A filter should produce bounded output for any bounded input.


What if I'm using a Biquad that has a bit of resonance from the Q? If you filter the same block of noise over and over again it will get high values in the resonating part of the frequency spectrum, I think...

When I lowered the Q the problem went away
^ Joined: 30 Nov 2008  Member: #194779  
thevinn
KVRian
- profile
- pm
- www
PostPosted: Sat May 02, 2009 12:03 pm reply with quote
File is updated:

- Added optimized template specialization for CascadeFilter::ProcessI()
in SSE3 intrinsics (MSVC) when channels=2 and stages=1 (all Biquads)

Sorry for the compiler specific stuff. If someone wants to help me add the necessary stuff to make it work with compilers other than MSVC, I would gladly add it in.

For the case of Biquads, and any Butterworth or Chebyshev filters with poles=2 channels=2, the SSE3_OPTIMIZED version is 38% faster.
^ Joined: 30 Nov 2008  Member: #194779  
MackTuesday
KVRist
- profile
- pm
- e-mail
- www
PostPosted: Sat May 02, 2009 12:16 pm reply with quote
thevinn wrote:
MackTuesday wrote:
No, sorry to say. A filter should produce bounded output for any bounded input.


What if I'm using a Biquad that has a bit of resonance from the Q? If you filter the same block of noise over and over again it will get high values in the resonating part of the frequency spectrum, I think...

When I lowered the Q the problem went away

If the Q value was the cause and you lowered the Q, great. The fact remains that a useful filter gives bounded output no matter what bounded input it receives.
^ Joined: 11 Jul 2004  Member: #32838  Location: Southern California, USA
thevinn
KVRian
- profile
- pm
- www
PostPosted: Sat May 02, 2009 12:27 pm reply with quote
MackTuesday wrote:
thevinn wrote:
MackTuesday wrote:
No, sorry to say. A filter should produce bounded output for any bounded input.


What if I'm using a Biquad that has a bit of resonance from the Q? If you filter the same block of noise over and over again it will get high values in the resonating part of the frequency spectrum, I think...

When I lowered the Q the problem went away

If the Q value was the cause and you lowered the Q, great. The fact remains that a useful filter gives bounded output no matter what bounded input it receives.


I agree but now that I think about it, the filter's input was unbounded. Because I was passing the same buffer back in over and over - each successive pass kept raising the value until it overflowed.
^ Joined: 30 Nov 2008  Member: #194779  
ZonderP
KVRist
- profile
- pm
PostPosted: Sat May 02, 2009 1:56 pm reply with quote
Wow, this code looks cool.
But since I don't understand those depths of dsp programming, I'm sorry I can't say anything about the quality of the code itself, but how it is documented and how it is written (I mean it's style) is great.
One thing I noticed is the use of the postfix decrement and increment operators. Whenever possible, you should use the prefix versions of them for better efficiency. Most modern compilers will optimize the postfix versions of them under specific circumstances, but to be sure you should go for the prefix versions yourself. Especially the for loops seem to be predestinated for this little change, some other code must not be changed for sure, since it relies on the not yet incremented/decremented value of the variables.
If you do not already know, see e.g. here
http://www.thunderguy.com/semicolon/2002/08/13/prefer-prefix -operators-over-postfix/
for a more detailed explanation.

Keep up the good work,
Patrik
----
Half human, half mayfly.
^ Joined: 18 Nov 2008  Member: #193937  
MackTuesday
KVRist
- profile
- pm
- e-mail
- www
PostPosted: Sat May 02, 2009 2:21 pm reply with quote
thevinn wrote:
MackTuesday wrote:
thevinn wrote:
MackTuesday wrote:
No, sorry to say. A filter should produce bounded output for any bounded input.


What if I'm using a Biquad that has a bit of resonance from the Q? If you filter the same block of noise over and over again it will get high values in the resonating part of the frequency spectrum, I think...

When I lowered the Q the problem went away

If the Q value was the cause and you lowered the Q, great. The fact remains that a useful filter gives bounded output no matter what bounded input it receives.

I agree but now that I think about it, the filter's input was unbounded. Because I was passing the same buffer back in over and over - each successive pass kept raising the value until it overflowed.

Do you mean that you were feeding the output data back into the input? That can cause a perfectly good filter to overflow. On the other hand, if you keep your input and output buffers separate, never changing your input buffer data, feeding it to the filter repeatedly, and the filter overflows, you have a problem.
^ Joined: 11 Jul 2004  Member: #32838  Location: Southern California, USA
thevinn
KVRian
- profile
- pm
- www
PostPosted: Sat May 02, 2009 3:16 pm reply with quote
MackTuesday wrote:
Do you mean that you were feeding the output data back into the input?


Yes that is what I was doing. I wrote a loop to time the performance and it filtered the same buffer repeatedly. Eventually as you said, it overflowed.
^ Joined: 30 Nov 2008  Member: #194779  
asomers
KVRian
- profile
- pm
PostPosted: Sat May 02, 2009 6:02 pm reply with quote
I'm not sure I'm following the conversation here, because it morphed from denormals to overflow... unless I'm missing something in which case just ignore me. But one thing I learned recently is that filters often use internal saturation to prevent 'overflow' and keep things stable under all conditions. The result in your case (the feedback loop) will be a ringing at the center frequency.
^ Joined: 17 Feb 2006  Member: #98700  Location: California
thevinn
KVRian
- profile
- pm
- www
PostPosted: Sun May 03, 2009 3:05 am reply with quote
Updated the file:

- Added SSE3 optimization for a general number of stages in
ProcessI() when channels==2

The general case of N stage 2 channel filtering in ProcessI() is now 65% faster with SSE3 instructions.
^ Joined: 30 Nov 2008  Member: #194779  
thevinn
KVRian
- profile
- pm
- www
PostPosted: Sun May 03, 2009 6:24 am reply with quote
Updated the file. Provided lots of examples (see the function at the bottom) on how to use the classes for template-impaired folks (which I was not too long ago).
^ Joined: 30 Nov 2008  Member: #194779  
rafa1981
KVRist
- profile
- pm
- e-mail
PostPosted: Sun May 03, 2009 12:00 pm reply with quote
I'll provide feedback as soon as I finish my oscillators, thanks for the stuff.
^ Joined: 03 Jan 2007  Member: #134546  
thevinn
KVRian
- profile
- pm
- www
PostPosted: Mon May 04, 2009 12:00 pm reply with quote
SourceForge page:

http://sourceforge.net/projects/dspfilterscpp/
^ Joined: 30 Nov 2008  Member: #194779  
All times are GMT - 8 Hours

Printable version
Page 2 of 21
Goto page Previous  1, 2, 3, ... 19, 20, 21  Next
Display posts from previous:   
ReplyNew TopicPrevious TopicNext Topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Username: Password:  
KVR Developer Challenge 2012