A Python submodule to hold constants representing different resampler backends.

Babycat comes with different backends for resampling audio waveforms to different frame rates. For example, CD audio is typically sampled at 44,100 hz and DVD audio is sampled at 48,000 hz. It is a common operation to resample audio from one frame rate to another.

Babycat’s Python bindings are typically compiled with support for the following resamplers:

  • DEFAULT_RESAMPLE_MODE: Currently defaults to the RESAMPLE_MODE_LIBSAMPLERATE resampler.

  • RESAMPLE_MODE_LIBSAMPLERATE: This uses libsamplerate at the SRC_SINC_BEST_QUALITY. This backend produces the highest-quality output audio, but is often slightly slower than the other backends. The libsamplerate backend is always available in Babycat’s Python bindings, but is currently not available in Babycat’s WebAssembly bindings.

  • RESAMPLE_MODE_BABYCAT_LANCZOS: This is a simple implementation of a Lanczos resampler. This is the fastest (and lowest-quality) resampler available in Babycat.

  • RESAMPLE_MODE_BABYCAT_SINC: This is an implementation of a sinc resampler as described by Stanford professor Julius O. Smith. The speeed and quality of this resampler is in between the above two.


Resample using the `BABYCAT_SINC` resampler.

>>> from babycat import Waveform
>>> from babycat.resample_mode import *
>>> waveform = Waveform.from_frames_of_silence(
...     frame_rate_hz=44100,
...     num_channels=2,
...     num_frames=1000,
... )
>>> waveform
<babycat.Waveform: 1000 frames, 2 channels, 44100 hz>
>>> resampled = waveform.resample_by_mode(
...     frame_rate_hz=11025,
...     resample_mode=RESAMPLE_MODE_BABYCAT_SINC,
... )
<babycat.Waveform: 250 frames, 2 channels, 11025 hz>