High quality, one-dimensional sample-rate conversion library
Project description
Python-SoXR
High quality, one-dimensional sample-rate conversion library for Python.
- Homepage: https://github.com/dofuuz/python-soxr
- Documentation: https://python-soxr.readthedocs.io
- PyPI: https://pypi.org/project/soxr/
Keywords: Resampler, Audio resampling, Samplerate conversion, DSP(Digital Signal Processing)
Python-SoXR is a Python wrapper of libsoxr.
Installation
pip install soxr
If installation fails, upgrade pip with python -m pip install --upgrade pip
and try again.
in Conda environment
conda install -c conda-forge soxr-python
Note: Conda packge name is soxr-python
, not python-soxr.
Basic usage
import soxr
y = soxr.resample(
x, # 1D(mono) or 2D(frames, channels) array input
48000, # input samplerate
16000 # target samplerate
)
If input is not numpy.ndarray
, it will be converted to numpy.ndarray(dtype='float32')
.
dtype should be one of float32, float64, int16, int32.
Output is numpy.ndarray
with same dimension and data type of input.
Streaming usage
Use ResampleStream
for real-time processing or very long signal.
import soxr
rs = soxr.ResampleStream(
44100, # input samplerate
16000, # target samplerate
1, # channel(s)
dtype='float32' # data type (default = 'float32')
)
eof = False
while not eof:
# Get chunk
...
y_chunk = rs.resample_chunk(
x, # 1D(mono) or 2D(frames, channels) array input
last=eof # Set True at end of input
)
Output frame count may not be consistent. This is normal operation.
(ex. [0, 0, 0, 186, 186, 166, 186, 186, 168, ...])
Requirement
x86 and ARM processors are supported.
Neon extension is required for ARM CPUs. Without Neon, it may crash or return inaccurate result.
Benchmark
Sweep, impulse, speed compairsion with other Python resamplers.
https://colab.research.google.com/drive/1XgSOvWlRIau1FYwQG_yRSAhDK3KB8bEL?usp=sharing
Speed comparison summary
Downsampling 10 sec of 48000 Hz to 44100 Hz.
Ran on Google Colab.
Library | Time on CPU (ms) |
---|---|
soxr (HQ) | 7.2 |
scipy.signal.resample | 13.4 |
soxr (VHQ) | 15.8 |
torchaudio | 19.2 |
lilfilter | 21.4 |
julius | 23.1 |
resampy (kaiser_fast) | 62.6 |
samplerate (sinc_medium) | 92.5 |
resampy (kaiser_best) | 256 |
samplerate (sinc_best) | 397 |
Technical detail
For technical details behind resampler, see libsoxr docs.
- https://sourceforge.net/p/soxr/wiki/Home/
- http://sox.sourceforge.net/SoX/Resampling
- https://sourceforge.net/p/soxr/code/ci/master/tree/src/soxr.h
Python-SoXR uses forked version of libsoxr. See difference here.
These changes does not apply to dynamic linked builds(e.g. conda-forge build)
Credit and License
Python-SoXR is LGPL v2.1+ licensed, following libsoxr's license.
OSS libraries used
libsoxr (LGPLv2.1+)
The SoX Resampler library
https://sourceforge.net/projects/soxr/
Python-SoXR is a Python wrapper of libsoxr.
PFFFT (BSD-like)
PFFFT: a pretty fast FFT.
https://bitbucket.org/jpommier/pffft/
libsoxr dependency.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for soxr-0.3.6-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba651652a64623a61ea86717357dcbf4d71f7f3695da979056ca257890f47d10 |
|
MD5 | f9e677276fccb46fbf67b696b9d3e5c1 |
|
BLAKE2b-256 | 3a29cd396aefb3a07e62b10c01ea9963d66a29a7516dacc7a5dfaaa02cec2da7 |
Hashes for soxr-0.3.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1add0aeed67f2396d7b4cefa36887ba8db1a185791f085c12aafa82e96d6fdf |
|
MD5 | b5971057d990cebcdf2a19400c2bc296 |
|
BLAKE2b-256 | 03fab9746abdb70253fdbe8a223a23f3724ae0caae1a74b95298d5763a6fc453 |
Hashes for soxr-0.3.6-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e73f8b9fb5ac3ad26155a6c789284bea1de98701c184e0ecb9cb328e9f81dfc2 |
|
MD5 | 859f78fcef714241445efa95d8224bb8 |
|
BLAKE2b-256 | d7a1c2cb9b837399bee62f442f6d2510711afbaea736cc1b6b38821249560324 |
Hashes for soxr-0.3.6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 705af37f7a63d3abecf9121bff392241636b403bcf6e232fb527d0b108aa8700 |
|
MD5 | 862511b9576f5fa1279d92b0af2a8cfa |
|
BLAKE2b-256 | 136bc162457850c2e7db02a71db1ca1933aa2518cfac0f5524a6b8f93d737475 |
Hashes for soxr-0.3.6-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97a89e3798f22bd04c475b30c041ee2f2e223effb4f80a71d4f5e278f7939138 |
|
MD5 | a45168b7abc65effabe0e5148b34c364 |
|
BLAKE2b-256 | 5946cb9965a341570c697af1e8df305f4fd9b9a1b528abafc6d4abfbd43164df |
Hashes for soxr-0.3.6-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03834c82977dc8976a183e22dfc9dd0f65198f416ac79f6bb13310e63c795662 |
|
MD5 | f8fd5a5ad5ad64ab0a0ae507ab79cd4d |
|
BLAKE2b-256 | 509cd3c40a61d980aeaafa16441f5446698a366024226272aa41be1f745a3a5e |
Hashes for soxr-0.3.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0b01688e7e591411a3499a62427a87236be31c84d6a88afd381947568f445df |
|
MD5 | af8bef25dedc72a96af4f7504c329306 |
|
BLAKE2b-256 | c0ef12d855b465dc3d85d5c53c666e8963f87557d50bfad68d26cb16348b3747 |
Hashes for soxr-0.3.6-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9074ee0901057353455febc5fe91a83dae1f97ade4e96acc8b95bd3d70cb495 |
|
MD5 | f2de18b64a5c22414baba2d8f233b664 |
|
BLAKE2b-256 | e9130241fe721a7afac03b42c8f06b43b8a6e85032839e7c832fe5f1d5774f80 |
Hashes for soxr-0.3.6-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8fe418fcee2173422b5c25ca4d9e03a86dd9d08f1502b0077987e2018ac943df |
|
MD5 | 807bf86290a9bd124f18de1b448248ff |
|
BLAKE2b-256 | a444fb9478671e6c365acd2ca6c4cfca408e08555019ce3ca7f9525dc530ba53 |
Hashes for soxr-0.3.6-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f64bc45a30ee6d9765cc4b1fdb6b9d5ec7d2880fc42a2e968c662ed3abe83c7 |
|
MD5 | 2f9b3db1bc3ff117453882d09692d593 |
|
BLAKE2b-256 | 65ac1da6a463c867a32f28be7ddcf2a0dcc9c2553ef785af1017340ee0f47cdc |
Hashes for soxr-0.3.6-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b2dd2e2625b4b98360cd1607d72e4bd2eac60de3a18244b8a4d45f9168a4541 |
|
MD5 | 4d209f84b6805900a360f3fb66df6ed1 |
|
BLAKE2b-256 | 876a00f1d2c16a6440672e80764f1d5fca9fa2b98087c7fdf4f8e4374b5068f1 |
Hashes for soxr-0.3.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c72ab44bfd72ecadb0a29e38487c241eb69a9867d3476e528c64e957fc06ff7 |
|
MD5 | 4b753983c9dd98dc53e42c6ebe3c9513 |
|
BLAKE2b-256 | a0502b49ce3aee3fca3be752ca81c36bc0aee13ec9186adf98c14c78ed2d3586 |
Hashes for soxr-0.3.6-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79872546786c3d05ff90260197863811532823fcfb58aeb647e916c6aa57299d |
|
MD5 | 78fce6097041486e72ceb2d0dc8c4da0 |
|
BLAKE2b-256 | 51d3f837dafbda64eee9fb75ec218af5dff67e0e32ab319246038fc11c6060d2 |
Hashes for soxr-0.3.6-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a78c61bf65b2e9d5612cbcab449a4a070ea84a18ff0757a840e0fa49b574225 |
|
MD5 | 52ac9f4f1eff543a9d9396d4aca0c7e7 |
|
BLAKE2b-256 | 05b87f4d4126976c713ce4f32bd364c76c2aa217a5fb583e985b0529c6528814 |
Hashes for soxr-0.3.6-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 385a37d39813e1d633229bcd94ab6bd76b27b779d38f2f6cbc390926f3965d31 |
|
MD5 | ce68895a5d7bc21858cbda53158d00f7 |
|
BLAKE2b-256 | 9956f84a05a53059508706403957b76ad205a9bf198a49641d52f9daa5226d1f |
Hashes for soxr-0.3.6-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dcf107a32d971e329b330a8f2026fedb118e39f5d549f65743184f8ec5d38204 |
|
MD5 | b239e275fde5cadc964a12daf7e46bc8 |
|
BLAKE2b-256 | 0a60233ee1d2552eda84b883701bd7178ddb450879704db3956a094f29f68a9e |
Hashes for soxr-0.3.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ad635ee478635efca9457b811bba373272319b45a1941d7f9d9ac8c2e98b3bc |
|
MD5 | 5654825894fa0b2dc4e2b7fa1f80525e |
|
BLAKE2b-256 | a1e69e489be17740fed23b014b3d4ed4d8353871d0215f377fb098d4a8411e7f |
Hashes for soxr-0.3.6-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0c40a25ae9520d7752e7ece07c3ec2bc58f30893c20a58c9d7a5311e7499290 |
|
MD5 | 79a7c56c459fcc541266a03fcb5028c1 |
|
BLAKE2b-256 | 310d1307bc2c342ec7a20ce9f6599cd316011fe14a86f2b52b5fdb241733f2d2 |
Hashes for soxr-0.3.6-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd1874aa176b5ae755f26c5bd7d9d45217839719a4343862d2fe72e50c57dd16 |
|
MD5 | 732a3d2869b513cf23bfa1a03f723794 |
|
BLAKE2b-256 | b3c36030ee7572a995c6213cd6fdf085060f81d2c21507b4dbab7dcf5b967675 |
Hashes for soxr-0.3.6-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac7da6054eff748f414cfaa8172249c492da7e88dde6aa97bfb2272d87727060 |
|
MD5 | 5a475e0d42ec6ba708e4064b8bd01274 |
|
BLAKE2b-256 | 9c1c42b1d4ad8e8062759e61dae1844b4b799b3f3f90d898803d3ccf3c6dd777 |
Hashes for soxr-0.3.6-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15277be23858ae9e1eeaec8151bbcd41ebf70c35ea067bb5e897f6834804256c |
|
MD5 | 6311fb7c1f6e8653a63e71eb4fb17ca6 |
|
BLAKE2b-256 | 813393b815d72bc252cb72bbd80f09083c4267f31cae051b3d14403f023ee094 |
Hashes for soxr-0.3.6-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f5d31d750886651137664cf55283e96a6f324d914d137f758d339d08a18347d |
|
MD5 | 876491c7fc579415f7669048a8ba4038 |
|
BLAKE2b-256 | cd6bf9612918f118b2f374238f324b1cf2b0185000d8e1588ab80334e2be85c3 |
Hashes for soxr-0.3.6-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 475f86acd92e97275b86940afabf0f108252b6a684fc724cef8019308d234162 |
|
MD5 | ddc0dbeae3a076340014fff1e26784e4 |
|
BLAKE2b-256 | 674dc487ab8deb3c43489350010e0495c7de13a2547ef7f2c4b844e85ea0449a |
Hashes for soxr-0.3.6-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c17f5efa78575afdbb854afbead11be5b209340e0ba801073ea4af31eeb567e7 |
|
MD5 | 4bfedc29678f06e5ffb5c076ab3cb494 |
|
BLAKE2b-256 | 85bce58aa015cfb7a5854aa1c8ecc7498218aaa6e59390f0d0c0e81ca2cedd3c |