A Collection of Useful C++ Classes for Signal Processing
-
Jeff McClintock Jeff McClintock https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=56398
- KVRist
- 413 posts since 30 Jan, 2005 from New Zealand
Anyone else get problems with Elliptic filters on Mac?
When I run the demo application Elliptic Low Pass filters show a single narrow peak on the magnitude graph, the requency response graph is all wrong, and the audio turns to a loud high pitched ringing sound?
( The same setup on PC works fine.)
Any help appreciated.
Cheers, Jeff
When I run the demo application Elliptic Low Pass filters show a single narrow peak on the magnitude graph, the requency response graph is all wrong, and the audio turns to a loud high pitched ringing sound?
( The same setup on PC works fine.)
Any help appreciated.
Cheers, Jeff
-
- KVRer
- 1 posts since 11 Nov, 2011
I recently downloaded your DSPFilters library and I must thanks Vincent for making this code open source and providing it to different communities. I was able to use it very fast in Visual Studio 2010 and it all worked good. I am using the library in the context of prepossessing ultrasound signals for B-mode ultrasound scanners.
I have a question about the group delay of these filters. In my application i need to have a zero or constant delay. I know this is impossible with IIR filters but in some implementations we can have quasi-linear phase iir filters.
So, far I used Butterworth filter with
order = 4, samplingFrequency = 12e6 Hz; centerFrequency = 2e6 Hz; bandwidth = 3.8e6 Hz
and the phase seems to be zero, what is good for me.
However, I need to know under what conditions I can have this quasi-linear phase. Could anyone give me the exact implementation formulas or point to the paper where this is discussed or shed some light on the linear phase issue?
I have a question about the group delay of these filters. In my application i need to have a zero or constant delay. I know this is impossible with IIR filters but in some implementations we can have quasi-linear phase iir filters.
So, far I used Butterworth filter with
order = 4, samplingFrequency = 12e6 Hz; centerFrequency = 2e6 Hz; bandwidth = 3.8e6 Hz
and the phase seems to be zero, what is good for me.
However, I need to know under what conditions I can have this quasi-linear phase. Could anyone give me the exact implementation formulas or point to the paper where this is discussed or shed some light on the linear phase issue?
-
- KVRist
- 44 posts since 11 Sep, 2011
Can anyone help me figure out what I'm doing wrong in my attempt to incorporate dspfilters into my project?
Just adding this as a test, and trying to compile, I get a lot of errors like this.
Error 1 error C2039: 'Parameters' : is not a member of 'Dsp' C:\Users\Tyson\Documents\Visual Studio 2010\Projects\UNIVERSIFYER\UNIVERSIFYER\UV.cpp 75 1 UNIVERSIFYER
Error 8 error C2039: 'setParameters' : is not a member of 'Dsp::Filter' C:\Users\Tyson\Documents\Visual Studio 2010\Projects\UNIVERSIFYER\UNIVERSIFYER\UV.cpp 79 1 UNIVERSIFYER
Error 20 error C2065: 'Parameters' : undeclared identifier C:\Users\Tyson\Documents\Visual Studio 2010\Projects\UNIVERSIFYER\UNIVERSIFYER\UV.cpp 102 1 UNIVERSIFYER
I'm just trying to get a n order butterworth high pass and low pass to work, and I don't need parameter smoothing, and I'm not working in real time. I just have an array of audio samples I would like to process.
Just adding this as a test, and trying to compile, I get a lot of errors like this.
Error 1 error C2039: 'Parameters' : is not a member of 'Dsp' C:\Users\Tyson\Documents\Visual Studio 2010\Projects\UNIVERSIFYER\UNIVERSIFYER\UV.cpp 75 1 UNIVERSIFYER
Error 8 error C2039: 'setParameters' : is not a member of 'Dsp::Filter' C:\Users\Tyson\Documents\Visual Studio 2010\Projects\UNIVERSIFYER\UNIVERSIFYER\UV.cpp 79 1 UNIVERSIFYER
Error 20 error C2065: 'Parameters' : undeclared identifier C:\Users\Tyson\Documents\Visual Studio 2010\Projects\UNIVERSIFYER\UNIVERSIFYER\UV.cpp 102 1 UNIVERSIFYER
I'm just trying to get a n order butterworth high pass and low pass to work, and I don't need parameter smoothing, and I'm not working in real time. I just have an array of audio samples I would like to process.
Code: Select all
#include "DspFilters\Dsp.h"
static void UsageExamples ()
{
// create a two channel audio buffer
int numSamples = 2000;
float* audioData[2];
audioData[0] = new float[numSamples];
audioData[1] = new float[numSamples];
// create a 2-channel RBJ Low Pass with parameter smoothing
// and apply it to the audio data
{
// "1024" is the number of samples over which to fade parameter changes
Dsp::Filter* f = new Dsp::SmoothedFilterDesign
<Dsp::RBJ::Design::LowPass, 2> (1024);
Dsp::Parameters params;
params[0] = 44100; // sample rate
params[1] = 4000; // cutoff frequency
params[2] = 1.25; // Q
f->setParameters (params);
f->process (numSamples, audioData);
}
// set up a 2-channel RBJ High Pass with parameter smoothing,
// but bypass virtual function overhead
{
// the difference here is that we don't go through a pointer.
Dsp::SmoothedFilterDesign <Dsp::RBJ::Design::LowPass, 2> f (1024);
Dsp::Parameters params;
params[0] = 44100; // sample rate
params[1] = 4000; // cutoff frequency
params[2] = 1.25; // Q
f.setParameters (params);
f.process (numSamples, audioData);
}
// create a 2-channel Butterworth Band Pass of order 4,
// with parameter smoothing and apply it to the audio data.
// Output samples are generated using Direct Form II realization.
{
Dsp::Filter* f = new Dsp::SmoothedFilterDesign
<Dsp::Butterworth::Design::BandPass <4>, 2, Dsp::DirectFormII> (1024);
Dsp::Parameters params;
params[0] = 44100; // sample rate
params[1] = 4; // order
params[2] = 4000; // center frequency
params[3] = 880; // band width
f->setParameters (params);
f->process (numSamples, audioData);
}
// create a 2-channel Inverse Chebyshev Low Shelf of order 5
// and passband ripple 0.1dB, without parameter smoothing and apply it.
{
Dsp::Filter* f = new Dsp::FilterDesign
<Dsp::ChebyshevII::Design::LowShelf <5>, 2>;
Dsp::Parameters params;
params[0] = 44100; // sample rate
params[1] = 5; // order
params[2] = 4000; // corner frequency
params[3] = 6; // shelf gain
params[4] = 0.1; // passband ripple
f->setParameters (params);
f->process (numSamples, audioData);
}
// create an abstract Butterworth High Pass of order 4.
// This one can't process channels, it can only be used for analysis
// (i.e. extract poles and zeros).
{
Dsp::Filter* f = new Dsp::FilterDesign
<Dsp::Butterworth::Design::HighPass <4> >;
Dsp::Parameters params;
params[0] = 44100; // sample rate
params[1] = 4; // order
params[2] = 4000; // cutoff frequency
f->setParameters (params);
// this will cause a runtime assertion
f->process (numSamples, audioData);
}
// Use the simple filter API to create a Chebyshev Band Stop of order 3
// and 1dB ripple in the passband. The simle API has a smaller
// footprint, but no introspection or smoothing.
{
// Note we use the raw filter instead of the one
// from the Design namespace.
Dsp::SimpleFilter <Dsp::ChebyshevI::BandStop <3>, 2> f;
f.setup (3, // order
44100,// sample rate
4000, // center frequency
880, // band width
1); // ripple dB
f.process (numSamples, audioData);
}
}
-
- KVRer
- 14 posts since 22 Mar, 2011
Same problem. The screenshot shows windows version (running in Parallels software under OSX) next to native OSX version.Anyone else get problems with Elliptic filters on Mac?
- KVRian
- Topic Starter
- 775 posts since 30 Nov, 2008
I wouldn't even know where to start in diagnosing this...
...could it be a build setting, or call to one of the built in trigonometric functions?
...could it be a build setting, or call to one of the built in trigonometric functions?
My Open Source:
Beast, rippled, DSPFilters, LayerEffects, SimpleDJ
Beast, rippled, DSPFilters, LayerEffects, SimpleDJ
-
- KVRer
- 14 posts since 22 Mar, 2011
I think that this is the most likely candidate. The calculation of the poles is screwed up on mac. I made a new project so that the demo would build using the new modular juce and then compiled using both GCC 4.2 and Apple compiler 3.0. The problem persisted with both.thevinn wrote: or call to one of the built in trigonometric functions?
I will try and make a simple command line project next to see if I can get to the root of the problem . . . as in at least see the function call returns a different number on the mac compared to the pc.
-
- KVRist
- 30 posts since 22 Dec, 2010
I just downloaded and took a very quick look—the use of "abs" instead of "fabs" gives an "Implicit conversion shortens 64-bit value into a 32-bit value" warning, and there are several in AnalogLowPass::design. Running the demo app, it's easy to see a quantization-like problem if you run a second order elliptic lowpass, and rotate through the "w" parameter—the poles jump to the until circle at a point.thevinn wrote:I wouldn't even know where to start in diagnosing this...
...could it be a build setting, or call to one of the built in trigonometric functions?
-
- KVRist
- 30 posts since 22 Dec, 2010
Yeah, that fixed it for me—change abs to fabs.codehead wrote:I just downloaded and took a very quick look—the use of "abs" instead of "fabs" gives an "Implicit conversion shortens 64-bit value into a 32-bit value" warning...thevinn wrote:I wouldn't even know where to start in diagnosing this...
...could it be a build setting, or call to one of the built in trigonometric functions?
- KVRian
- Topic Starter
- 775 posts since 30 Nov, 2008
Wow awesome!!!codehead wrote:Yeah, that fixed it for me—change abs to fabs.
I'm in the midst of updating DSP Filters Demo to the latest juce tip so I will be testing it on Mac shortly.
My Open Source:
Beast, rippled, DSPFilters, LayerEffects, SimpleDJ
Beast, rippled, DSPFilters, LayerEffects, SimpleDJ
- KVRian
- Topic Starter
- 775 posts since 30 Nov, 2008
I updated the SVN repo for DSP Filters:
- Replaced abs() with fabs()
- Revised the JuceAmalgam sources to use an amalgamation built from the latest modules tip
- Updated the Windows and Macintosh project files to use the new amalgamation
It seems to work great, feedback is appreciated!
- Replaced abs() with fabs()
- Revised the JuceAmalgam sources to use an amalgamation built from the latest modules tip
- Updated the Windows and Macintosh project files to use the new amalgamation
It seems to work great, feedback is appreciated!
My Open Source:
Beast, rippled, DSPFilters, LayerEffects, SimpleDJ
Beast, rippled, DSPFilters, LayerEffects, SimpleDJ
-
- KVRer
- 14 posts since 22 Mar, 2011
Awesome.codehead wrote: Yeah, that fixed it for me—change abs to fabs.
- KVRian
- Topic Starter
- 775 posts since 30 Nov, 2008
"A Collection of Useful C++ Classes for Digital Signal Processing" has moved to Github! Please update your bookmarks:
https://github.com/vinniefalco/DSPFilters
Feel free to follow and/or contribute to the project.
Thanks!
https://github.com/vinniefalco/DSPFilters
Feel free to follow and/or contribute to the project.
Thanks!
My Open Source:
Beast, rippled, DSPFilters, LayerEffects, SimpleDJ
Beast, rippled, DSPFilters, LayerEffects, SimpleDJ
- KVRian
- Topic Starter
- 775 posts since 30 Nov, 2008
FYI I have updated the DSP Filters source tree to include my amalgamated version of Juce. It is split up by module - each module is in a single amalgamated .cpp. So it's really convenient.billythekidd wrote:I made a new project so that the demo would build using the new modular juce
My Open Source:
Beast, rippled, DSPFilters, LayerEffects, SimpleDJ
Beast, rippled, DSPFilters, LayerEffects, SimpleDJ
-
Jeff McClintock Jeff McClintock https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=56398
- KVRist
- 413 posts since 30 Jan, 2005 from New Zealand
*double* awesome. Thanks, that had me stumped.billythekidd wrote:Awesome.codehead wrote: Yeah, that fixed it for me—change abs to fabs.
- KVRian
- Topic Starter
- 775 posts since 30 Nov, 2008
Can someone give me a hand with a very simple Makefile for this thing so I can build it in my Ubuntu virtual box?
A while back someone told me it could easily be compiled by just compiling all the .cpp together, adding the magic switches to link in the right libs (X11 and whatever audio api flavor) and presto.
It should go in shared/DSPFiltersDemo/Builds/Make as Makefile (replacing the 1 line nonsense that I wrote). Fork and pull request on Github, thanks!
A while back someone told me it could easily be compiled by just compiling all the .cpp together, adding the magic switches to link in the right libs (X11 and whatever audio api flavor) and presto.
It should go in shared/DSPFiltersDemo/Builds/Make as Makefile (replacing the 1 line nonsense that I wrote). Fork and pull request on Github, thanks!
My Open Source:
Beast, rippled, DSPFilters, LayerEffects, SimpleDJ
Beast, rippled, DSPFilters, LayerEffects, SimpleDJ