{"id":2750,"library":"resampy","title":"Efficient Signal Resampling","description":"resampy is a Python module for efficient time-series resampling, primarily designed for audio applications. It implements the band-limited sinc interpolation method for sampling rate conversion, offering performance advantages over `scipy.signal.resample` for long-duration signals. The current version is 0.4.3, with maintenance releases occurring periodically to ensure compatibility and address minor issues.","status":"active","version":"0.4.3","language":"en","source_language":"en","source_url":"https://github.com/bmcfee/resampy","tags":["signal processing","audio","resampling","time-series"],"install":[{"cmd":"pip install resampy","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Core array manipulation","package":"numpy","optional":false},{"reason":"Scientific computing functionalities","package":"scipy","optional":false},{"reason":"Just-in-time compilation for performance, core implementation is Numba-based","package":"numba","optional":false}],"imports":[{"note":"The primary resampling function is exposed directly under the 'resampy' namespace.","wrong":"from resampy import resample","symbol":"resample","correct":"import resampy\nresampy.resample(...)"}],"quickstart":{"code":"import numpy as np\nimport resampy\n\n# Generate a 5-second sine wave at 440 Hz\nsr_orig = 44100  # Original sample rate\nduration = 5     # seconds\nfrequency = 440  # Hz\n\nt = np.arange(int(sr_orig * duration)) / sr_orig\nx = np.sin(2 * np.pi * frequency * t)\n\n# Resample the signal to a new sample rate (e.g., 22050 Hz)\nsr_new = 22050\ny = resampy.resample(x, sr_orig, sr_new)\n\nprint(f\"Original signal length: {len(x)} samples\")\nprint(f\"Resampled signal length: {len(y)} samples\")\nprint(f\"Original sample rate: {sr_orig} Hz\")\nprint(f\"New sample rate: {sr_new} Hz\")","lang":"python","description":"This example demonstrates how to generate a sine wave using NumPy and then resample it to a different sample rate using `resampy.resample`."},"warnings":[{"fix":"If integer outputs are required, explicitly cast the output array (e.g., `y.astype(int)`) after resampling. Be aware of potential data loss during casting.","message":"Since version 0.4.0, integer-valued inputs to `resampy.resample` will always produce floating-point outputs. Prior versions could potentially return integer outputs if the input was integer-valued.","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"To re-enable parallel processing for performance on multi-core systems, explicitly set `parallel=True` in the `resampy.resample` call: `resampy.resample(..., parallel=True)`.","message":"Starting from version 0.4.0, parallel computation in `resampy.resample` is disabled by default (`parallel=False`). In previous versions, it was `True` by default.","severity":"gotcha","affected_versions":">=0.4.0"},{"fix":"Upgrade to `resampy` version 0.4.3 or newer (`pip install --upgrade resampy`) to resolve this warning.","message":"Versions of `resampy` prior to 0.4.3 may raise a `DeprecationWarning` related to the `importlib_resources` API when used with newer Python versions, as the internal usage has been updated in 0.4.3.","severity":"deprecated","affected_versions":"<0.4.3"},{"fix":"Avoid using version 0.3.0. Ensure you are on version 0.3.1 or newer if you encounter unexpected performance degradation after upgrading from older releases.","message":"Version 0.3.0 introduced an efficiency regression that could lead to slower performance compared to previous versions. This regression was fixed in version 0.3.1.","severity":"gotcha","affected_versions":"0.3.0"},{"fix":"If precise output length matching another library is critical, carefully compare the output shapes or use a wrapper function to normalize lengths if possible. For most audio applications, the difference is negligible.","message":"The output length of signals resampled with `resampy` might differ slightly from other libraries like `scipy.signal.resample` for the same upsampling ratio, due to different internal calculation and rounding strategies.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure `numba` is correctly installed and configured. If performance changes are observed, review Numba's documentation for potential optimization or troubleshooting tips.","message":"In version 0.2.0, the core resampling implementation was rewritten from Cython to Numba. This change may affect performance characteristics or introduce new dependency considerations (e.g., Numba installation issues) for users upgrading from 0.1.x versions.","severity":"gotcha","affected_versions":"From 0.1.x to 0.2.0+"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}