To limit the audio file input.wav containing noise mixed with a pure 1000 Hz frequency sinusoidal tone to 995-1005 Hz, using SoX :

sox input.wav output.wav sinc 995-1005

However, the volume changes dramatically as well, which I don't want. It should simply block everything above and below without messing up the rest. The aim is to extract the RMS amplitude of the pure sinus tone from this. I know how to do it in GoldWave, but this program is GUI-only, and thus not practical for many files. What needs to be added to the SoX commandline to get the desired result ? The SoX manual is just gibberish to me (undocumented options, lacks examples).

  • Maybe try --norm? – vapid May 30 '19 at 19:16
  • This changes - normalizes - the volume, not what I want. – Petoetje59 May 30 '19 at 21:26

The man page for sox is quite clear on this. The 'sinc' option defines two '6dB' points for highpass and lowpass boundaries to the bandpass filter.

Thus, at these '6dB' points, the signal will be 6dB lower at the stated frequency.

This is the reason why your overall volume is being lowered. Due to the width of the filter you are trying to implement, it is highly likely that the target frequency (1kHz) is likely to be attenuated by both the shoulder of the highpass and the lowpass boundaries combined.

Note that the sinc function is not a 'brickwall' filter and thus will roll off at a set amount of 'dB' per octave.

You might want to try a bandpass filter that has a 'center' frequency with a variable 'Q'. That might give you what you are seeking.

| improve this answer | |
  • "You might want to try a bandpass filter that has a 'center' frequency with a variable 'Q'" I don't get any wiser without examples. – Petoetje59 May 31 '19 at 12:59
  • I generally won't respond to people that exhibit even a hint of entitlement. What I will suggest is that you put some effort into trying an alternative solution with the information you have been provided and see where that gets you. More than happy to respond if you are willing to put some effort into this on your part. – Mark Jun 1 '19 at 3:05

No need for the gobbledygook about Q. After fiddling with some parameters, it turns out that

sox input.wav output.wav sinc -n 32767 995-1005

does exactly what I want. I know what the sinc function does, but have no clue what "-n 32767" means, apart from the fact that it does the job. The manual refers to "number of taps". I have taps at home but they only produce running water. So, if someone could elucidate me on this...

| improve this answer | |
  • Nice to see you've put some effort into this and had another read of the manual. You'll find further information on FIR filters here: dspguru.com/dsp/faqs/fir/basics – Mark Jun 22 '19 at 10:41
  • The number of taps is an indication of 1) the amount of memory required to implement the filter, 2) the number of calculations required, and 3) the amount of “filtering” the filter can do; in effect, more taps means more stopband attenuation, less ripple, narrower filters, etc. That's clear enough to me. Thx. – Petoetje59 Jun 22 '19 at 16:14

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.