1
$\begingroup$

I was trying to use the scipy.decimate function provided in the library, but I had a question - I want a pre-processing algorithm to downsample audio in such a way that it is fully deterministic i.e, It would always output the same decimated signal, provided an original signal.

So, the algorithm should be able to downsample it in a similar way on all audio pieces - and having a way to reconstruct the original signal would a bonus, but not necessary to accomplish.

Does anyone know if such a method exists? And is the chebyshev filter used by scipy.decimate fully deterministic, and fitting my intended purpose?

$\endgroup$
1
  • $\begingroup$ Resampling algorithms tends to be deterministic unless dithering is applied. They are often time-variant in that one sample of shift in input produce a different output. Multirate algorithms contains lots of «state» that typically is not communicated outside of the library. $\endgroup$ – Knut Inge Jun 10 at 21:51
1
$\begingroup$

I would not recommend either default filter in the signal.decimate function for decimation operations. The "non-deterministic" effects if observed may be due to noise aliasing. An FIR filter designed using the least squared algorithm (scipy.signal.firls) is much better suited given it will have the least noise overall in a least squared sense for the same number of coefficients (complexity) and importantly will exhibit a stop-band roll-off that goes down as frequency increases. This is a significant point as the decimation rate increases since for every decimation factor $D$ there are $D-1$ aliased regions that fold directly onto the primary frequency band of interest. The Type 1 Chebyshev also has a significant stop band roll-off as desired (unlike the Hamming which is minor or equiripple FIR designs using Parks-McLellan which has none), but the rejection over much of the band is far inferior to what can be easily achieved with a multiband firls filter. Having a stopband roll-off will limit the growth in aliasing noise to first couple folding regions.

That said, my favored approach to decimating is to use a multiband filter designed using firls (this will concentrate the rejection to just the regions where it matters) and then select every Dth sample for the down-sampling.

Decimation

$\endgroup$
2
$\begingroup$

I want a pre-processing algorithm to downsample audio in such a way that it is fully deterministic

All coded algorithms are deterministic unless they are specifically designed not to (with random seeds) or there is inconsistent initialization. That's the fundamental idea behind regression testing. So yes: Unless you do something wrong any down-sampling algorithm will be deterministic.

and having a way to reconstruct the original signal would a bonus

Cannot be done in the general case.

$\endgroup$
1
$\begingroup$

These algorithms are all deterministic.

Whether a chebyshev design is what your decimation needs is a bit of a broad question. Probably you're just as good off designing a low-pass filter with scipy.firdes, and then using that to filter your input before just dropping the amount of samples (e.g, every odd one) you want to ignore.

$\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.