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, # input array – mono(1D) or multi-channel(2D of [frame, channel])
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, # input aray – mono(1D) or multi-channel(2D of [frame, channel])
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, ...])
Benchmark
Sweep, impulse, speed compairsion with other resamplers for Python.
https://colab.research.google.com/drive/1_xYUs00VWYOAXShB85W1MFWaUjGHfO4K?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) | 10.8 |
torchaudio | 13.8 |
soxr (VHQ) | 14.5 |
scipy.signal.resample | 21.3 |
lilfilter | 24.7 |
julius | 31 |
resampy (kaiser_fast) | 108 |
samplerate (sinc_medium) | 223 |
resampy (kaiser_best) | 310 |
samplerate (sinc_best) | 794 |
Technical detail
For technical details behind resampler, see libsoxr docs.
- https://sourceforge.net/p/soxr/wiki/Home/
- http://sox.sourceforge.net/SoX/Resampling (archive)
- https://sourceforge.net/p/soxr/code/ci/master/tree/src/soxr.h
Python-SoXR package comes with modified version of libsoxr. See changes here.
These changes do not apply to dynamic-linked builds (e.g. conda-forge build).
To check the version of libsoxr, use soxr.__libsoxr_version__
.
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
File details
Details for the file soxr-0.5.0.post1.tar.gz
.
File metadata
- Download URL: soxr-0.5.0.post1.tar.gz
- Upload date:
- Size: 170.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7092b9f3e8a416044e1fa138c8172520757179763b85dc53aa9504f4813cff73 |
|
MD5 | 31c59fcccf4e51d65cb55cd8c8f97b58 |
|
BLAKE2b-256 | 02c04429bf9b3be10e749149e286aa5c53775399ec62891c6b970456c6dca325 |
File details
Details for the file soxr-0.5.0.post1-cp312-abi3-win_amd64.whl
.
File metadata
- Download URL: soxr-0.5.0.post1-cp312-abi3-win_amd64.whl
- Upload date:
- Size: 164.9 kB
- Tags: CPython 3.12+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1be9fee90afb38546bdbd7bde714d1d9a8c5a45137f97478a83b65e7f3146f6 |
|
MD5 | 92cbe5abc0f5e822a7e7289153555e88 |
|
BLAKE2b-256 | bc10440f1ba3d4955e0dc740bbe4ce8968c254a3d644d013eb75eea729becdb8 |
File details
Details for the file soxr-0.5.0.post1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: soxr-0.5.0.post1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 248.5 kB
- Tags: CPython 3.12+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3f16810dd649ab1f433991d2a9661e9e6a116c2b4101039b53b3c3e90a094fc |
|
MD5 | 3ee89c2c54fa4263fc36db477a3e99fc |
|
BLAKE2b-256 | e11a569ea0420a0c4801c2c8dd40d8d544989522f6014d51def689125f3f2935 |
File details
Details for the file soxr-0.5.0.post1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: soxr-0.5.0.post1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 216.6 kB
- Tags: CPython 3.12+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd052a66471a7335b22a6208601a9d0df7b46b8d087dce4ff6e13eed6a33a2a1 |
|
MD5 | 62edccfcf048789fa1cf3a494285a45a |
|
BLAKE2b-256 | b838bad15a9e615215c8219652ca554b601663ac3b7ac82a284aca53ec2ff48c |
File details
Details for the file soxr-0.5.0.post1-cp312-abi3-macosx_11_0_arm64.whl
.
File metadata
- Download URL: soxr-0.5.0.post1-cp312-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 156.4 kB
- Tags: CPython 3.12+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4704ba6b13a3f1e41d12acf192878384c1c31f71ce606829c64abdf64a8d7d32 |
|
MD5 | ddf8cf0caf5775fa6e219f57995fb9a4 |
|
BLAKE2b-256 | 20f188adaca3c52e03bcb66b63d295df2e2d35bf355d19598c6ce84b20be7fca |
File details
Details for the file soxr-0.5.0.post1-cp312-abi3-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: soxr-0.5.0.post1-cp312-abi3-macosx_10_14_x86_64.whl
- Upload date:
- Size: 200.0 kB
- Tags: CPython 3.12+, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fef509466c9c25f65eae0ce1e4b9ac9705d22c6038c914160ddaf459589c6e31 |
|
MD5 | b16abbe3d2f6b7827959cae94847a8c4 |
|
BLAKE2b-256 | 5de3d422d279e51e6932e7b64f1170a4f61a7ee768e0f84c9233a5b62cd2c832 |
File details
Details for the file soxr-0.5.0.post1-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: soxr-0.5.0.post1-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 166.7 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4d8d5283ed6f5efead0df2c05ae82c169cfdfcf5a82999c2d629c78b33775e8 |
|
MD5 | d5ec7a015781494957cca1dc71ec30de |
|
BLAKE2b-256 | 86946a7e91bea7e6ca193ee429869b8f18548cd79759e064021ecb5756024c7c |
File details
Details for the file soxr-0.5.0.post1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: soxr-0.5.0.post1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 252.5 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca6903671808e0a6078b0d146bb7a2952b118dfba44008b2aa60f221938ba829 |
|
MD5 | 47fd9e97dd6d120bc4da03567ac64f64 |
|
BLAKE2b-256 | 9fe5400e3bf7f29971abad85cb877e290060e5ec61fccd2fa319e3d85709c1be |
File details
Details for the file soxr-0.5.0.post1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: soxr-0.5.0.post1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 221.0 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f0b558f445ba4b64dbcb37b5f803052eee7d93b1dbbbb97b3ec1787cb5a28eb |
|
MD5 | 4c808ccba5ce976a73bbbcecbf708c5a |
|
BLAKE2b-256 | 9ca56b439164be6871520f3d199554568a7656e96a867adbbe5bac179caf5776 |
File details
Details for the file soxr-0.5.0.post1-cp311-cp311-macosx_11_0_arm64.whl
.
File metadata
- Download URL: soxr-0.5.0.post1-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 159.9 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39e0f791ba178d69cd676485dbee37e75a34f20daa478d90341ecb7f6d9d690f |
|
MD5 | ba875f163d18dd6a1fe965c46bd879dc |
|
BLAKE2b-256 | 0e483e88329a695f6e0e38a3b171fff819d75d7cc055dae1ec5d5074f34d61e3 |
File details
Details for the file soxr-0.5.0.post1-cp311-cp311-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: soxr-0.5.0.post1-cp311-cp311-macosx_10_14_x86_64.whl
- Upload date:
- Size: 203.6 kB
- Tags: CPython 3.11, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6fb77b626773a966e3d8f6cb24f6f74b5327fa5dc90f1ff492450e9cdc03a378 |
|
MD5 | 3aa9d45f6c85618077091a3e5799db2f |
|
BLAKE2b-256 | 2928dc62dae260a77603e8257e9b79078baa2ca4c0b4edc6f9f82c9113d6ef18 |
File details
Details for the file soxr-0.5.0.post1-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: soxr-0.5.0.post1-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 166.9 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97f269bc26937c267a2ace43a77167d0c5c8bba5a2b45863bb6042b5b50c474e |
|
MD5 | 0c9fa9e9fcde2bafbd761aade6b54c5f |
|
BLAKE2b-256 | ad6486082b6372e5ff807dfa79b857da9f50e94e155706000daa43fdc3b59851 |
File details
Details for the file soxr-0.5.0.post1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: soxr-0.5.0.post1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 252.8 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fcc049b0a151a65aa75b92f0ac64bb2dba785d16b78c31c2b94e68c141751d6d |
|
MD5 | 755d3d6e1443cd68f068ae5f2a9cc737 |
|
BLAKE2b-256 | bae6059070b4cdb7fdd8ffbb67c5087c1da9716577127fb0540cd11dbf77923b |
File details
Details for the file soxr-0.5.0.post1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: soxr-0.5.0.post1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 221.2 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b01d3efb95a2851f78414bcd00738b0253eec3f5a1e5482838e965ffef84969 |
|
MD5 | 50481503459d153bb6e73ea54184760d |
|
BLAKE2b-256 | 7f09e43c39390e26b4c1b8d46f8a1c252a5077fa9f81cc2326b03c3d2b85744e |
File details
Details for the file soxr-0.5.0.post1-cp310-cp310-macosx_11_0_arm64.whl
.
File metadata
- Download URL: soxr-0.5.0.post1-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 160.2 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa0a382fb8d8e2afed2c1642723b2d2d1b9a6728ff89f77f3524034c8885b8c9 |
|
MD5 | b59bc2a33ecfbbb007ce6b28de60bd4f |
|
BLAKE2b-256 | 1f5d56ad3d181d30d103128f65cc44f4c4e24c199e6d5723e562704e47c89f78 |
File details
Details for the file soxr-0.5.0.post1-cp310-cp310-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: soxr-0.5.0.post1-cp310-cp310-macosx_10_14_x86_64.whl
- Upload date:
- Size: 203.8 kB
- Tags: CPython 3.10, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7406d782d85f8cf64e66b65e6b7721973de8a1dc50b9e88bc2288c343a987484 |
|
MD5 | 795b5c26a771ac97d9121c9a9ebef760 |
|
BLAKE2b-256 | 7d96bee1eb69d66fc28c3b219ba9b8674b49d3dcc6cd2f9b3e5114ff28cf88b5 |
File details
Details for the file soxr-0.5.0.post1-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: soxr-0.5.0.post1-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 167.3 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e71b0b0db450f36de70f1047505231db77a713f8c47df9342582ae8a4b828f2 |
|
MD5 | a6c9b35cf5f851628b0250ffbd29b4a8 |
|
BLAKE2b-256 | cd2e1fbad5cc8c49c45a0b94221d16445792f55b63fe4f6d3885db960d92892c |
File details
Details for the file soxr-0.5.0.post1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: soxr-0.5.0.post1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 253.0 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c8e9c980637e03d3f345a4fd81d56477a58c294fb26205fa121bc4eb23d9d01 |
|
MD5 | cc02d2de2c898afdf7b38e175d83f302 |
|
BLAKE2b-256 | 25d183a66e795381ddfc5c3ebf34cc0ac68735c7c459ed1fe65a2193a52c57b1 |
File details
Details for the file soxr-0.5.0.post1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: soxr-0.5.0.post1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 221.4 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94de2812368e98cb42b4eaeddf8ee1657ecc19bd053f8e67b9b5aa12a3592012 |
|
MD5 | a6251a7d87c9c6099522d53a660c621b |
|
BLAKE2b-256 | a54a6a11d62cfd6383c88f4918bdc5191d9c437f649c9101ceb5eec7e2837f0b |
File details
Details for the file soxr-0.5.0.post1-cp39-cp39-macosx_11_0_arm64.whl
.
File metadata
- Download URL: soxr-0.5.0.post1-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 160.4 kB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1dda616fc797b1507b65486f3116ed2c929f13c722922963dd419d64ada6c07 |
|
MD5 | 33f5e651b00fa198606676325dc67270 |
|
BLAKE2b-256 | 885cf6cf6b90ce1628def17c746d6cde9991fdd29667ef1d5fb5bd3b22eb788f |
File details
Details for the file soxr-0.5.0.post1-cp39-cp39-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: soxr-0.5.0.post1-cp39-cp39-macosx_10_14_x86_64.whl
- Upload date:
- Size: 204.1 kB
- Tags: CPython 3.9, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5af7b355959061beb90a1d73c4834ece4549f07b708f8c73c088153cec29935 |
|
MD5 | fa16ece2707ef9c941e6d3cdc5979d02 |
|
BLAKE2b-256 | d97bc8d797235d06ae316e0c9bc2b1d0d5d948834dfac17eba0ad10fd177524b |