What is KVR Audio? | Submit News | Advertise | Developer Account

Options (Affects News & Product results only):

OS:
Format:
Include:
Quick Search KVR

"Quick Search" KVR Audio's Product Database, News Items, Developer Listings, Forum Topics and videos here. For advanced Product Database searching please use the full product search. For the forum you can use the phpBB forum search.

To utilize the power of Google you can use the integrated Google Site Search.

Products 0

Developers 0

News 0

Forum 0

Videos 0

Search  

A Collection of Useful C++ Classes for Signal Processing

DSP, Plug-in and Host development discussion.

Moderator: Moderators (Main)

KVRer
 
5 posts since 2 Aug, 2012

Postby 0x80; Sat Dec 22, 2012 10:40 am

Hi, I'm just getting my feet wet with you DspFilter lib. This looks very nice, but I'm a bit confused and I can't find a simple example for what I want to do. Basically I have an input vector which I need to process in place with a butterworth filter.

The input, named segment_ is a std::vector<double> type, and it holds 1 channel of data.

I got this far:

Dsp::SimpleFilter<Dsp::Butterworth::HighPass<2>, 1> filter_;

filter_.setup(2, samplerate_, 1000);

filter_.process(segment_.size(), (double * const*)&segment_[0]);

When I run this I get an bad access exception.

I must be doing something stupid. Can you spot the problem? :help:

Also if I want to change the filter type at runtime from low to highpass, what do I store in my program? A pointer to a what generic type?
KVRian
 
767 posts since 30 Nov, 2008
 

Postby thevinn; Sat Dec 22, 2012 3:28 pm

0x80 wrote:filter_.process(segment_.size(), (double * const*)&segment_[0]);


Yeah you can't do that. process() wants an array of pointers. Remove the cast and fix the compile error. For example:

double* channels [1];
channels[0] = &segment_ [0];
filter_.process(segment_.size(), channels);
KVRer
 
5 posts since 2 Aug, 2012

Postby 0x80; Mon Dec 24, 2012 4:39 am

Aha that makes sense. Thanks I got it working now:)

When dealing with multiple channels my input and output data will be interleaved. Is there a way to work (in place) with interleaved channel data or do I need to convert it to separate channels and back?
KVRian
 
767 posts since 30 Nov, 2008
 

Postby thevinn; Mon Dec 24, 2012 6:49 am

0x80 wrote:Is there a way to work (in place) with interleaved channel data or do I need to convert it to separate channels and back?


You have to convert. Routines are provided in DSPFilters for doing this for you.
KVRer
 
1 post since 17 Jan, 2013

Postby Mr.Palace; Thu Jan 17, 2013 3:30 am

Hi all, first of all I love the DSPFilter collection for it's ease of implementation and performance. I'm using it to create octave band filters. The ANSI specification defines the limits of the filters and trying to get within that specification. I'm currently using a 4th order Besselworth filter. I setup the filter as follows:

Code: Select all
Dsp::Filter* f = new Dsp::SmoothedFilterDesign
        <Dsp::Butterworth::Design::BandPass <4>, 1, Dsp::DirectFormII> (numberOfSamples);
       
Dsp::Params params;
params[0] = samplingRate; // sample rate
params[1] = 4; // order
params[2] = centerFrequency; // center frequency
params[3] = bandWidth; // band width
f->setParams (params);


Now when I test this filter with a frequency sweep I get the following result:

http://db.tt/jxsuaM7C

1. First of all the center frequency seems to be off. In this example I set it to 1000 Hz with a bandwidth of 707.106812 Hz.

2. The dropoff is not what I would expect from a Butterworth filter (maybe caused by cascading 2nd order filters?)

3. How could I improve this?
KVRer
 
1 post since 27 Nov, 2008

Postby djrisc; Sun Jan 27, 2013 10:47 am

I just wanted to drop a quick note here as I saw previous posters struggle with getting this to build with linker errors.

The "Download Now" button on the site is an old build (which is the one your most likely trying to build and then include the libs.)

If you download the updated version via the "ZIP" button via GitHub, it will allow you to include 2 files without any libs and build just fine.

Just thought I'd post this as I struggled at first to figure out where these files were that were being referred to in this thread, and then realized that the "Download Now" zip file is out of date.

Enjoy!

Brett
KVRian
 
767 posts since 30 Nov, 2008
 

Postby thevinn; Sun Jan 27, 2013 12:29 pm

Yep, and to make things worse Github has removed the "download" feature so I can't update those files. They will disappear soon (because of Github).
KVRer
 
5 posts since 19 Feb, 2013, from So Cal

Postby ChocoBilly; Wed Feb 20, 2013 3:30 pm

Hello. First of all, thanks for supplying such a wide variety of filters and source ready to drop in. I had been searching for an LPF to handle noise from upsampling and was very happy to find your code project.

I was not able to use the examples from documentation.cpp as they produced compile errors and was wondering if they were out of date? For example, these 2 lines from the sample do not compile for me under VS 2008:

Dsp::SmoothedFilterDesign <Dsp::RBJ::Design::LowPass, 2> f (1024);
Dsp::Filter* f = new Dsp::SmoothedFilterDesign <Dsp::Butterworth::Design::BandPass <4>, 2, Dsp::DirectFormII> (1024);

These 2 do:

Dsp::Filter* f = new Dsp::FilterDesign <Dsp::Butterworth::Design::LowPass <LPF_ORDER>, 1>;
Dsp::Filter* f = new Dsp::FilterDesign <Dsp::Butterworth::Design::LowPass <LPF_ORDER>, 1, Dsp::DirectFormII>;

Perhaps an issue with SmoothedFilterDesign or my setup? I'm thinking something may have changed since the time documentation.cpp was written.

From some of the posts I've read, it seems I am not alone in being naive in the understanding of filters. I would greatly appreciate setup sample code for all the filters as it does not seem straightforward or rather not straightforward to someone that isn't fluent in filter design. For example, since the params are generic, the "order" param can be in any position. I wanted to try different LPF filters to see which I might prefer for general use but it seems necessary to dive into the code to suss it out. Filter::getParamInfo() sounded useful but I couldn't get the syntax to use it it. Also, I don't know what Direct Form II realization is but I liked the result better on my test case.

If I missed any of this in the documentation, I apologize. Perhaps I should have made the subject should be clues for the clueless. There are several more filters I'd like to use. Filtering is a necessity for the project I'm working on. I'm hoping I can just drop in the ones that work best for my needs (being lazy by nature). I'm willing to learn more but it's clear that I am not likely to ever have a full understanding of the subject and I greatly appreciate the work done to make these filters available to everyone.
KVRer
 
1 post since 21 Mar, 2013

Postby Eric56; Thu Mar 21, 2013 6:05 am

Hi! Can you help me? i have got a problem with including dspfilters files to my project in vs2012.
The following method
Code: Select all
I suppose I should make things more clear.

 There are no libraries...you just add the one source file dsp_filters.cpp to your project, and that's it!
is causing the link error 2005:
Code: Select all
Spectrum.obj : error LNK2005: "public: class std::vector<struct Dsp::PoleZeroPair,class std::allocator<struct Dsp::PoleZeroPair> > __thiscall Dsp::Cascade::getPoleZeros(void)const " (?getPoleZeros@Cascade@Dsp@@$$FQBE?AV?$vector@UPoleZeroPair@Dsp@@V?$allocator@UPoleZeroPair@Dsp@@@std@@@std@@XZ) already defined in dsp_filters.obj

i have tried to disaple precompiled headers but it does not produce any effect.
what i should to do to avoid this error?
KVRAF
 
3648 posts since 8 Mar, 2004, from Berlin, Germany
 

Postby Robin from www.rs-met.com; Thu Mar 21, 2013 12:48 pm

Eric56 wrote:Hi! Can you help me? i have got a problem with including dspfilters files to my project in vs2012.
The following method
Code: Select all
I suppose I should make things more clear.

 There are no libraries...you just add the one source file dsp_filters.cpp to your project, and that's it!
is causing the link error 2005:
Code: Select all
Spectrum.obj : error LNK2005: "public: class std::vector<struct Dsp::PoleZeroPair,class std::allocator<struct Dsp::PoleZeroPair> > __thiscall Dsp::Cascade::getPoleZeros(void)const " (?getPoleZeros@Cascade@Dsp@@$$FQBE?AV?$vector@UPoleZeroPair@Dsp@@V?$allocator@UPoleZeroPair@Dsp@@@std@@@std@@XZ) already defined in dsp_filters.obj

i have tried to disaple precompiled headers but it does not produce any effect.
what i should to do to avoid this error?


this error is typical when you include some .cpp into another .cpp file and compile and link both. i suppose "Spectrum.cpp" somehow includes "dsp_filters.cpp" (maybe indirectly via "Spectrum.h") and both files get compiled. the remedy is to either get rid of of the inclusion of the dsp_filters.cpp file (and include a corresponding .h file instead) or the exclude dsp_filters.cpp from the build (right-click on the file, open the "Properties" and set "Excluded From Build" to "Yes" - a red sign appears on top of the icon of the file)
Image
KVRist
 
334 posts since 18 May, 2010

Postby FLWrd; Thu Mar 21, 2013 11:11 pm

Just found out about this, and I wanted to say thanks. I'll be checking it out in the next days, but as a software engineer, I can say I really like some of the design decisions from the README.md.
KVRist
 
31 posts since 14 Aug, 2010

Postby foge; Wed Mar 27, 2013 6:08 am

Not sure if its bad form to ask such a basic question.

I am interested in using your wonderful filter library.
However I have so far only ever included single .cpp/.h files when I have wanted to use a library that someone else has created.

Building the DSPFilters.xcodeproj works fine for me with no errors.

I am working in Xcode and would like to include your filter library in my future work as it looks so thorough.

However I am not sure how to add all the files to... for example my vst iplug project or an openframeworks iphone template project etc.

There is a source folder and a include folder with the DspFilter folder.
I can see that the source folder contains all the .cpp files and the DspFilter folder includes all the .h files

I understand that to include all of your dsp library in my Application.h file I should write #include Dsp.h
or for example in my VST I should write #include Dsp.h in my MyPlugin.h

However I don't know how to correctly add the DSPFilter folder and Source folder to my Xcode project.

Apologies for asking such a basic question but the libraries that I have used so far have just been in a .cpp/.h format and I have just had to drag them (add them) into the top part of the navigator area and make such they are added and them included in my App/vst.

Any guidance appreciated
thanks
GEoff
KVRist
 
33 posts since 16 Oct, 2012

Postby cisdsp; Wed Apr 10, 2013 12:51 pm

Hi Guys, hi Vinn

First of all: Really GREEEAAAAAT WORK! Thank you for this awesome collection!

i have a question about implementation in VST framework(s).

Is my method the right method? Or are there other methods?


Code: Select all


Dsp::Filter* f = new Dsp::SmoothedFilterDesign <Dsp::RBJ::Design::LowPass, 2> (1024);


void DSPFILTERTEST::ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames)
{
 
  double fs = (double) GetSampleRate();

  double *filteredInput[2];
 
  filteredInput[0] = new double[nFrames];
  filteredInput[1] = new double[nFrames];
 
  filteredInput[0] = *inputs;
  filteredInput[1] = *inputs;
 

    Dsp::Params params;
    params[0] = fs; // sample rate
    params[1] = mFreq; // cutoff frequency
    params[2] = 1.25; // Q
    f->setParams (params);
    f->process (nFrames, filteredInput);

    // Normally here is a while or for statement. Is it necessary in your code?

    outputs[0] = filteredInput[0];
    outputs[1] = filteredInput[1];


}


Seems it works all.
Some people can feel the rain,while others are just wet.
KVRist
 
225 posts since 15 Apr, 2012, from Toronto, ON

Postby LemonLime; Wed Apr 10, 2013 1:19 pm

cisdsp wrote:Hi Guys, hi Vinn

First of all: Really GREEEAAAAAT WORK! Thank you for this awesome collection!

i have a question about implementation in VST framework(s).

Is my method the right method? Or are there other methods?


Code: Select all


Dsp::Filter* f = new Dsp::SmoothedFilterDesign <Dsp::RBJ::Design::LowPass, 2> (1024);


void DSPFILTERTEST::ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames)
{
 
  double fs = (double) GetSampleRate();

  double *filteredInput[2];
 
  filteredInput[0] = new double[nFrames];
  filteredInput[1] = new double[nFrames];
 
  filteredInput[0] = *inputs;
  filteredInput[1] = *inputs;
 

    Dsp::Params params;
    params[0] = fs; // sample rate
    params[1] = mFreq; // cutoff frequency
    params[2] = 1.25; // Q
    f->setParams (params);
    f->process (nFrames, filteredInput);

    // Normally here is a while or for statement. Is it necessary in your code?

    outputs[0] = filteredInput[0];
    outputs[1] = filteredInput[1];


}


Seems it works all.


The processing part looks fine, but..

You've got quite the memory leak there. Regardless, you don't want to allocate memory inside the processing block. Dynamic memory allocation is relatively slow, so putting it inside a block that gets called repeatedly many many times is a waste.

Most allocation, declaration and initializing of objects should go in resume() (e.g. updating the sample rate) unless it needs to go in the process block (updating frequency and Q). The processing block should be as lean as possible for performance reasons.

And remember to delete objects created with new. :)
KVRist
 
33 posts since 16 Oct, 2012

Postby cisdsp; Wed Apr 10, 2013 3:02 pm

The processing part looks fine, but..

You've got quite the memory leak there. Regardless, you don't want to allocate memory inside the processing block. Dynamic memory allocation is relatively slow, so putting it inside a block that gets called repeatedly many many times is a waste.

Most allocation, declaration and initializing of objects should go in resume() (e.g. updating the sample rate) unless it needs to go in the process block (updating frequency and Q). The processing block should be as lean as possible for performance reasons.

And remember to delete objects created with new.


Thanks for this.


resume() is the word of the day :)
I started using IPlug because it's very easy and has very very easy GUI handling. I haven't found out 'til now if there's a resume() in there :roll:

Can you give me maybe a hint how to delete the "new" stuff? I thought must not delete the object " filteredInput[0] = new double[nFrames];" - for example...

I asked about implementations because of following situation:

I did a four Band Filter with HP and LP with the RBJ Filterclass. This was very easy and fast done. In the Process Block for example
Code: Select all
for(i = 0; ......) {
outLeft = HiPass->process(LowShelf->process(Peak1->process(Peak2->process(HiShelf->process(LowPass->process(inLeft))))));
}


Really easy to implement.

With Vinn's Classes it's a little different :shock:

I have to figure out how this works.


PS: I hope I'm not confusing you [/code][/quote]
Some people can feel the rain,while others are just wet.
PreviousNext

Moderator: Moderators (Main)

Return to DSP and Plug-in Development