A Collection of Useful C++ Classes for Signal Processing

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

Have you considered breaking out some of the redundant stuff into separate source files? Having everything in two files is pretty cumbersome... Of course I could do this on my own but if you're concerned about readability...

Post

When sending zeros or very low values it needs to normalise the filter. I had 6% CPU with audio and when stopped (in FL studio) it shot to just over 50%.
Adding a small number to the end of the coeffs multiply seems to fix it:-

Code: Select all

out=s->b[0]*in+ s->b[1]*h->v[0] + s->b[2]*h->v[1] + s->a[1]*h->v[2] + s->a[2]*h->v[3] + 1e-22f;
I'm a bit confused now though, because all the filters appear to be 2 pole. And when I specify 4 pole it runs a 2 pole twice.
*EDIT* Oh yeah, using more stages give better stability a low cut-offs.

Post

asomers wrote:Have you considered breaking out some of the redundant stuff into separate source files? Having everything in two files is pretty cumbersome... Of course I could do this on my own but if you're concerned about readability...
It is so much easier to maintain as just two source files

Post

AUTO-ADMIN: Non-MP3, WAV, OGG, SoundCloud, YouTube, Vimeo, Twitter and Facebook links in this post have been protected automatically. Once the member reaches 5 posts the links will function as normal.
Hi! First, thx for your work! Perfect library.
So, go to my troubles. I write bandstop filter for .wav files.
Code:

Code: Select all (#)

  WaveReader::WaveReaderPtr reader = WaveReader::GetInstance();
  WaveWriter::WaveWriterPtr writer = WaveWriter::GetInstance();
  
  writer->SetMeta(reader->GetRiff(), reader->GetWave());

  int window = 4096; 
  int sampleRate = 44100;
  Dsp::BesselBandStop<4, 1> filter;
  filter.SetupAs(6000.0 / sampleRate, 1000.0 / sampleRate);

   for (int step = -window / 2; step < reader->GetDataSize() / 2; step += window / 2)
   {
    double *buffer = new double[window];
    for (unsigned i = 0; i < window; ++i)
    {
      buffer[i] = reader->at(i + step);
    }    

    filter.Process(window, buffer, 0);

    for (unsigned i = window / 4; i < window / 4 * 3; ++i)
    {
      writer->AddValToData(buffer[i]);
    }

    delete[] buffer;
  }

  writer->SaveWave();
I read block of data from wave file and use filter on it. And... as result i have trash:( Look, spectrum of original file (http://picasaweb.google.com/lh/photo/6Tz8KDLBHnK1vkr_ZJ5s7w?authkey=Gv1sRgCJL4nICZouO03AE&feat=directlink) and spectrum of output file (http://picasaweb.google.com/lh/photo/1jUpekFVWvfw1d3Z5k7cwg?authkey=Gv1sRgCJL4nICZouO03AE&feat=directlink).
Filter settings:

Code: Select all (#)

filter.SetupAs(6000.0 / sampleRate, 1000.0 / sampleRate);
That I do wrong?
And I'm sorry for my very very bad english:)

Post

thevinn: hey, i just read the whole thread (well, 90% of it)
great work!

i'm interested in the bessel-lowpass filter
i know a bessel filter has the *best* phase-response of them all, and is suitable for AA-filtering where the phase is important to be preserved
i've already used a bessel filter (generated with a an applet (mkfilter)) and it worked quite well, but after that, i can't really *change* the filter in any way
now i need another bessel filter but not for AA-filtering, so the filter coefficients have to be calculated on init, the applet i used won't work in this case
i'm also not sure about the order of the filter, i'm modeling some noise attenuation and i might need something betwee 4 and 8 poles (i have to test it)

and now your filter classes are the thing that'll work perfectly for me (i guess)
but, i'm not sure i understand the license..

can i use it for closed-source application?
to be exact, the filter itself is going to be used in a SynthEdit module, which will be then compiled into a VST.. (tho, it'll be freeware)
thanks!
It doesn't matter how it sounds..
..as long as it has BASS and it's LOUD!

irc.libera.chat >>> #kvr

Post

Sorry for the late reply.

Since it is MIT licensed, you can use it for whatever you'd like. Including UNLIMITED COMMERCIAL USE.

Unfortunately I was not able to get the Bessel or Legendere working before I stopped. However I will be returning to this project most likely later in the year. If anyone can provide some pointers to resources for helping me implement these filters it would be appreciated.

Thanks!

Post

ah, cool!
what i need from the Bessel is just a LowPass version with uhm, selectable order (from the minimum up to.. 12 maybe)
and most importantly, i will need to set the cutoff frequency in realtime (it won't be modulated, but it might need to be recalculated from time to time)
i needed this filter for my Cassette-Tape simulator
it seems the Tape has very sharp attenuation of high frequencies above iirc 13KHz.. but i need to preserve the original signal's "looks" as much as i can

so does your current Bessel class have these things right now?
i'm not sure how can i help with a bessel filter :shrug:
It doesn't matter how it sounds..
..as long as it has BASS and it's LOUD!

irc.libera.chat >>> #kvr

Post

I think the current Bessel filter is completely unimplemented, since I was not able to find sufficient material on the Internet to figure out how to write it.

Post

I'm in the middle of rewriting this library, with the following goals:

- Break everything out into multiple files
- Fix denormalization issues with the cascade filter stages
- More programmer-friendly method of constructing filter objects
- Support for time-varying parameter changes via pole/zero interpolation
- Implementation of Bessel polynomials for filters...psst...Robin :-)

I'm considering changing my design criteria of avoiding operator new (which was done to be more embedded-system friendly). Anyone have thoughts on this for, or against?

Does anyone have any suggestions or requests they would like?

Post

thevinn wrote:Does anyone have any suggestions or requests they would like?
Well, since you asked...

Some way 'patch' another audio signal to the filter cutoff (or other parameters), somehow avoiding per-sample coefficient calcuations.

Glad to see you're working on this again. The first round was very impressive.

Post

asomers wrote:Some way 'patch' another audio signal to the filter cutoff (or other parameters), somehow avoiding per-sample coefficient calcuations.
I don't understand. Are you asking for time-varying parameter changes (e.g. a low frequency filter sweep)?
Glad to see you're working on this again. The first round was very impressive.
Thanks! I've learned a lot and I think this next iteration is going to be a lot better.

Post

Did anyone find the avoidance of new/delete in the library helpful for embedded systems?

Post

thevinn wrote:
asomers wrote:Some way 'patch' another audio signal to the filter cutoff (or other parameters), somehow avoiding per-sample coefficient calcuations.
I don't understand. Are you asking for time-varying parameter changes (e.g. a low frequency filter sweep)?
Yep :)

Post

asomers wrote:Some way 'patch' another audio signal to the filter cutoff (or other parameters), somehow avoiding per-sample coefficient calcuations.
Yeah you and me both. I was going to try interpolation of coefficients between either the starting and ending point, or through the use of "key frames" (i.e. recalculate some of the coefficients along the way but not every sample).

I get the feeling I'm in over my head though. I remember reading some stuff about keeping a filter stable through parameter changes but I don't recall where it was.

Post

if you want someone really nescient to see if your bessel implementation is widely intelligible, pick me :p
you come and go, you come and go. amitabha neither a follower nor a leader be tagore "where roads are made i lose my way" where there is certainty, consideration is absent.

Post Reply

Return to “DSP and Plugin Development”