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, ...])
Requirement
x86 and ARM processors are supported.
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 (archive)
- 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)
To determine 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
Hashes for soxr-0.5.0b1-cp312-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 704af419aa6651f0f134a5fa4258bf4d6a87dc5ab8c36b566f1433a300697249 |
|
MD5 | 1c6a176e3d311f05c1ae44e45fc79446 |
|
BLAKE2b-256 | 4af6c7ba3f23161e2407885472b788f887968dac7927c9adcf28daef0e4ecba2 |
Hashes for soxr-0.5.0b1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9cd3452fcb2f8bd88590232f94be6a7504728b25478ece5c38cc1012af0422ca |
|
MD5 | a6fa1bad24af6f82ecde041f1cb7375e |
|
BLAKE2b-256 | b0515e569057344cf73713ebf7ddc1908f146e32b41d59cd001a75fe4d141dec |
Hashes for soxr-0.5.0b1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 684128870900623e1521689e336e941c903e8cbe127cef881709e368d64c592c |
|
MD5 | 641b8656be3b25bca650803cad80b069 |
|
BLAKE2b-256 | 5785076a384d5c31633b91fd28c635a064a4e62fc3e0016633d3a9c864458766 |
Hashes for soxr-0.5.0b1-cp312-abi3-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 459f41dc4a1dc92497d2ddae93783d951bb44a5901b74f816999d32cd796c45d |
|
MD5 | fbf412f6c600354073287d478d6797cb |
|
BLAKE2b-256 | b75aa92ed42e9f077e4cd56decdf76c0bfa735edc482c341169202527fc00d75 |
Hashes for soxr-0.5.0b1-cp312-abi3-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0169e01bc8256c6413006cd2151445061b3b2da8a3ab03b81403b53aaf6d85f |
|
MD5 | 7152c4b9bd0935b42a5fa6e7d5d17f9d |
|
BLAKE2b-256 | 12fecac0079ecd7a1f472418f3de7ce8613aefa6119c1c863dfbb18831d1f9d9 |
Hashes for soxr-0.5.0b1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06a93910aed046ac364096df747af743b643bb16dec0fa2d7b20e20b235d21df |
|
MD5 | d901a772ef78c025d373391bd0469cd8 |
|
BLAKE2b-256 | 53a3e1e473db4053105df885a99852b34dadce0622613dac92b9f892268f429b |
Hashes for soxr-0.5.0b1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 134b05c528b11f48a3cec9b65fd1804ea2cb93f0d8073e1802fe9093454e3ac0 |
|
MD5 | 911767c07659e2b5410616c9590360f2 |
|
BLAKE2b-256 | fc83cca7fac36f84887bcef0a7e5417267c215063148179bdafbb63b1c6ff068 |
Hashes for soxr-0.5.0b1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6018f69efb5996bb2fad48001777c7f0fff598ad11cc532fe67a21e910f322c8 |
|
MD5 | ddd178afa501c72bfd3f6d8f8bdc25f8 |
|
BLAKE2b-256 | fbbcb09bf6e1c6dea47f2f3fabf2115a08bb21bfd4f741b467a9e88279d3ce77 |
Hashes for soxr-0.5.0b1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c34771b1502350aaa30651d430a8231f9318c362f28b02ecb260cfd78e363578 |
|
MD5 | 1f6a96e09b0d7f19c2219be36126564d |
|
BLAKE2b-256 | 5d38925b980d38f7070de2cb43da69c72d25005bb17438185f5ade74dde4626c |
Hashes for soxr-0.5.0b1-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a7f9ea63e932967371bb3e240d3eb40bbcacfa2c09290fcdded9163a01a9a48 |
|
MD5 | 455310817eb67fb6736ddafef4b74983 |
|
BLAKE2b-256 | a5bb8124a7b0cb40e7f3b5fd5c4da1a086a62dbc24b566c1c0fea81aab9025d0 |
Hashes for soxr-0.5.0b1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7753accbfa1c9dfcb6e46805f413756af9e5d8e003da5610d98abc8c420f7258 |
|
MD5 | 2b435972929dad260658e1fcec40287c |
|
BLAKE2b-256 | 3364111ee0a953134defae82b9c47fb97b7aeb8d05eef88c251e450bd85317c3 |
Hashes for soxr-0.5.0b1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f973c47a2a1cc55768a02cb2fbbff3ce451dafaab7f6e08d2354a61a7b917bbe |
|
MD5 | e66323d93eb7bfdd0fa0f3c4107ea6fb |
|
BLAKE2b-256 | e133b1f290d616890702a1112dabe637cbfa315c5d798c64a99a323340e03501 |
Hashes for soxr-0.5.0b1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e04ed371a7f0460173fc2af7b313c4c74b70eb37bb664b21030fec3de6a4a9e1 |
|
MD5 | ea6424b0e6607b17e1e6b88fbdb91310 |
|
BLAKE2b-256 | dc5aab33a34e5243ba14ce501b4244d1d25251b27919003c4b7e47860224accd |
Hashes for soxr-0.5.0b1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab10b8181e825d4295ecdd35acc839e6aceb136f3a2437c72ef86f0f2e882463 |
|
MD5 | c9c76d7dfc14cc9d23f28f13f42228a8 |
|
BLAKE2b-256 | 2e491fcc95cb69ff8e5e651dd3c43fed767c0f69918ab249bf2982d825e795ee |
Hashes for soxr-0.5.0b1-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4263a78cdc40d6935707439160e4a3ea045a7ca837524e63abffc55970c73ef5 |
|
MD5 | 0be3032a5ca9de1b335a01a9f14adeaf |
|
BLAKE2b-256 | d62532a2cbc571f7ee80a0ea43e8f93d3761d6bb5e72640ebe608361d89e86b1 |
Hashes for soxr-0.5.0b1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b022c8e5bdfc0f9f0e5e9a1c547b96c8dbc26e36228ffb38e4c8e7c7c16ec7d |
|
MD5 | 783c4e38ff5241d13408fd964885b449 |
|
BLAKE2b-256 | 9f1268b3026e923581158d426273651c7f4efcf5acb9713bda18a5c8a44b3644 |
Hashes for soxr-0.5.0b1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e4490a23eb4f43155fd6a65c0e8e94092d2d63346859189303859d99b81cd3b |
|
MD5 | 5b441e041025b931c475577960d04aa7 |
|
BLAKE2b-256 | 3f9420a17c1990d830d082cfcfba8c8182437d5ba5a005aa5d470e1c44cb4829 |
Hashes for soxr-0.5.0b1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95f4248576da2305868fd2b10ce4a3884972179dddb642aa290cd53aec7e7d6f |
|
MD5 | bddbab6b72f89d947fc16afe18c3bc7b |
|
BLAKE2b-256 | 75c36d68adbf43e8f4cf03ddf651b5246686eda61d23ab583cd70b866cbc84bd |
Hashes for soxr-0.5.0b1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92ae3339b6f8db0bd52359adc832fed44abc2ed551c97323e7a13e4a9798cb88 |
|
MD5 | d3a784327b1cfff3ccc85c6c775d8d3c |
|
BLAKE2b-256 | 42094566e3b4bb4474a97713becd9a50746831bfa8ed8662fc4082d37a063bb2 |
Hashes for soxr-0.5.0b1-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ad44d6c62667c9cc0a63231022c24ded87dd72f76471aea8457660879b9fb90 |
|
MD5 | 74fea262f995a7ffa26ed6e486892f44 |
|
BLAKE2b-256 | cbbffeb314a364aa8ecc3626edcfd71286435773177291b6d225b85211c685fa |