0
$\begingroup$

Let's apply a 400-2000Hz bandpass filter on a respiratory .wav file:

sox audio1.wav audio1.bandpass.wav sinc -t 10 400-2000

Now I'd like to generate a spectrogram that takes advantage of the reduced bandwidth to still generate a full size image. But how to to do that? Notice what the result is from running spectrogram on the bandpass file:

sox audio1.bandpass.wav -n spectrogram -r -o audio1.bandpass.png -m

enter image description here

That's clearly a big waste of image real estate. What step(s) am I missing here to use the full image size to focus on that already-limited frequency bands?

Update From accepted answer: works great

Add a step after the initial bandpass:

  sox audio1.bandpass.wav -r 4000  audio1.bandpass1.wav

Then

sox audio1.bandpass1.wav -n spectrogram -o audio1.bandpass.png -m

enter image description here

$\endgroup$
1
$\begingroup$

sox is doing exactly what you tell it to do – it plots a spectrogram of the bandwidth you can represent with your sampling rate. The fact that most of your picture shows no energy just shows your filter is working, and that's exactly what one would want to see!

However, as you can see, your signal is solidly oversampled: You can downsample it to a much lower sampling rate after filtering! (and downsampling by a factor $N$ here really is just throwing away $N-1$ samples, keeping one, throwing away $N-1$ samples..., since your filter is an excellent anti-aliasing filter.)

| improve this answer | |
$\endgroup$
  • $\begingroup$ ah i see what you mean - trying that out. I'll just use nyquist 2*2K = 4K as final sampling rate $\endgroup$ – javadba Apr 24 at 21:36
  • $\begingroup$ treat yourself to more than critical sampling :) $\endgroup$ – Marcus Müller Apr 24 at 21:39
  • $\begingroup$ yea - but actually 2khz is already generous $\endgroup$ – javadba Apr 24 at 21:48

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.