2
$\begingroup$

In a soundfile, I'd like to remove a frequency and all its harmonics. What is the best solution in your opinion ?

  1. Do a loop with 20 notch filters, one after another.

    // f is the fundamental frequency
    for (i=0; i++; i<21)
    {
    file.notchfilter(f*i);
    }
    
    Question : does each notch filter create some unwanted side-effects, and the fact that we use 20 filters one after another will create very high unwanted artefacts?

  2. Is it possible to design a filter that will remove 20 frequencies in ONE STEP ? Then we wouldn't need to do a loop, just one pass wil be okay? Is it called a Comb filter ?

  3. Other method ?

$\endgroup$
  • 2
    $\begingroup$ If you know the frequency accurately and have some control over your signal's sample rate, then a comb filter like the one you linked could indeed be a good choice. They are very easy to implement, but the level of control that you have over the comb spacing is pretty coarse. $\endgroup$ – Jason R Oct 12 '13 at 18:28
  • $\begingroup$ @JasonR : great! Would you have an example of C++ implementation of a comb filter that would remove for example frequency 440Hz and all the multiples (880, 1320, etc.) on a 16bit 44.1khz stereo WAV file ? Thanks in advance! (C++ implementation is exactly the thing that is really difficult for me here!) $\endgroup$ – Basj Oct 12 '13 at 18:39
  • 5
    $\begingroup$ If you need help with coding a C++ implementation, I recommend that you plan out what you want your program to do (inputs, outputs, specs.) and then get started with everything you do know how to do. If along the way you have questions that are specific to C++, take them to Stack Overflow. If you have questions specific to filter implementation come back here and we would be happy to help! Unfortunately it is not very likely that anyone will have ready-to-use C++ code that they can share. $\endgroup$ – nispio Oct 13 '13 at 0:14
2
$\begingroup$

The choice of algorithm depends on your application scenario - i.e. there is no best solution per se. If your focus is on minimum computational requirements, a comb filter will probably be optimum. If you want optimum sound quality, a notch filter based approach could be a better choice.

To gain an overview about advantages and disadvantages of the different methods, maybe our article is of interest. We compared

  • comb filters
  • subband comb filters (only processing the lowpass frequencies) and
  • notch filters

in terms of disturbance reduction capabilities and degradation of the desired signal.

Answers to Your Questions

  1. Yes, each notch filter creates unwanted side-effects. On the one hand, you will get audible ringing artifacts - especially noticeable for narrow bandwidths. On the other hand, higher bandwidths suffer less from audible ringing but bring about increased degradation of the desired signal.

  2. Comb filters remove evenly-spaced harmonics in one step by placing notches that cover the full frequency range. As a consequence, you have no control about how many teeth they have as the notches reach up to the Nyquist frequency. If you want to have control about the affected frequency range, you can split the frequency range into high and low bands, process only one with a comb filter and add both bands together.

  3. Except for the mentioned subband comb filter, none that I know of.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.