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/
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.
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
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 Distributions
Built Distributions
Hashes for soxr-0.2.6-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4da70cb64460c1d6210e3865fb367b71a50efd2537ba70ca411b17bb3ce41669 |
|
MD5 | 518fdfc856808f17652a67a21fb367f9 |
|
BLAKE2b-256 | 2d20776b5dce3fd670f735aa0b35a32757bda9df94b53a370e59f5bf311ca06d |
Hashes for soxr-0.2.6-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29a7b417e5612dbaee187addc3901d65d9b8b6ccddf3399c04950915d3ee00e5 |
|
MD5 | ab55d199f40df83ef20dd1f9850da4eb |
|
BLAKE2b-256 | f0e6d69d4215be32deb267bbe5ff271c676205781076edd9b566b22a0f2310f9 |
Hashes for soxr-0.2.6-pp37-pypy37_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50f84c1d9738ef6d8e86bbee299a5e03230230f055d4c1ada0cc5fa31e22fb00 |
|
MD5 | aa10c7d7d4a4139a0ae2cd36b095e715 |
|
BLAKE2b-256 | 502f1d51c8a911fc3546874589e010dd6dc62579e359420f3555ec1e4a0ea9d0 |
Hashes for soxr-0.2.6-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cfe80cb0b0dd6908ae0e72db1bd3f643217ea18764a3becc43c87e7cae5c0050 |
|
MD5 | ced554f382d69ee794857c1aebe1c7d9 |
|
BLAKE2b-256 | ce38a8388dc2ad1e8e32431c94601f9b7f5351962d295aafff893269636f53ef |
Hashes for soxr-0.2.6-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0dea0e2addad66f56c45e8a5da32f1b89583356c0db6f20448620e50cc26d638 |
|
MD5 | bd7f87c858a8e3535067933a222d0e44 |
|
BLAKE2b-256 | a08a5b4d1e162dad83d53d70dc2f836226cc95db3375b94bac1709c6ab3f7e2b |
Hashes for soxr-0.2.6-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5482cfde9447597ec793006f9be6353a035fedabd50aa61f0b1bd966713041ee |
|
MD5 | cf4b09e43b8460e73ab082e3b1fde109 |
|
BLAKE2b-256 | f0a56745285ea399df865a041c7716d427437525584e5fe7c12b761cb816d1e6 |
Hashes for soxr-0.2.6-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6b226d9c4d107dcc472b33baa68442c02bc67d1a743f8f8c732d75a2483272b |
|
MD5 | f206f4165b2261707aeb3d806ad3a1c2 |
|
BLAKE2b-256 | b76a4d95f4983a3466c541dfc25e6210376e058d6d23642d7a24ef135a518405 |
Hashes for soxr-0.2.6-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f66500bf4901afebb2e02f23797fc56ea8b913d28e6b0f1e788894ee71681019 |
|
MD5 | 3ed265d6c211e75229433c60d0e47376 |
|
BLAKE2b-256 | 9dc8c5ff6795715e38953f2feaf6e2b202de42f51505f3a3f14988e6fac76e73 |
Hashes for soxr-0.2.6-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63ca053ecf4948b7dbebd59b800191d3dc554adbc7ccd2f77484c0cc1e6c54a1 |
|
MD5 | eada65cf2a04a557b52ecaf1d4128a68 |
|
BLAKE2b-256 | d94ff7b61156702d846179e9bf9c2b2e36c2400200f542b5b05afaa8acd65d9c |
Hashes for soxr-0.2.6-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65d3dbf4d254b16589035228e3b5cc89571759213f07b159d4e8a1d092ae13f6 |
|
MD5 | 28264025bd35d8d93abd19c2d0b19f38 |
|
BLAKE2b-256 | 0146dc1f51856f94a2f613c817cd4abe887ca1b749cf5d0548cf6bf68c23944a |
Hashes for soxr-0.2.6-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2e88372dcb9114a6462b57850d10e5de11dbc955b2805ead98bf5dac44c0fc1 |
|
MD5 | 8b74754f5a06a7501d4e2de8bd7d21e4 |
|
BLAKE2b-256 | 43741440dde5381f577c42bc17526d63ca78cca3de6812d40d6d666b3bd75b18 |
Hashes for soxr-0.2.6-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bfb8f3ce967f1f0153fbde7f0af9777a47601a57316d4cd72b8ab86a8b33c277 |
|
MD5 | cced5ce17a864369650cc4a0935cfe9e |
|
BLAKE2b-256 | a4a2b2e3ab5fdb234a37a40b4cdce690a0abc59339a08c3e63b245dc07bbf74a |
Hashes for soxr-0.2.6-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1683c1e369bb5559953edb853a0f3f58d41dd7d41348b6233cf18d96b140a52a |
|
MD5 | bbb3c27ce16c9aa0b653985be900559e |
|
BLAKE2b-256 | a0dbcf9bfe27bbc468e73d3c0cf9606458f93b2c70685f6dd395d6fb56b94b8b |
Hashes for soxr-0.2.6-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b834c493db4be7eb2445421d089f71ad3cc894345b94ba22f8c986ec5f9775f2 |
|
MD5 | b6dd6672e0464911338faca6d64c49d0 |
|
BLAKE2b-256 | 37590ab2eee76c7d4334354935760eea1ff843b375e90c63037a2d081b2a83fd |
Hashes for soxr-0.2.6-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2935202684019007584546342c394cbc91fd8025f73f968e99378cab56ceafc1 |
|
MD5 | 703a08f6a653f03c5f530cfc10f6e149 |
|
BLAKE2b-256 | ba86939348f18678d3c52d93c680be1e0f518c9c1e288ab04556d1343a9d572c |
Hashes for soxr-0.2.6-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48b719103e2f8b51e51ddc9687713c546077534525173428ded0a08610de80c5 |
|
MD5 | 45b750b278bfd61f870d72429b15e380 |
|
BLAKE2b-256 | f3235e48cd528e5c430a2af4001168cc29d26d255cecd6a392274f9e423429f4 |
Hashes for soxr-0.2.6-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12bbe6516ee5bbc7795bdbe83eee594e7e24c74602704005e61c476a4be46f8e |
|
MD5 | 135b01774a29dad7a970546c0192c26c |
|
BLAKE2b-256 | 9871102f20dfa87308f560bc22f04cf3cc8aa4ffb75719dbb2acc0695558751c |
Hashes for soxr-0.2.6-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5349449306010e9ab446428fe88f81e77a45fcbe5cdb8d10c2756b6f800a75c7 |
|
MD5 | 758eb948b8b7c2dfcbf62f4af9c1412f |
|
BLAKE2b-256 | 1f7ab098b92e423c4a1ace36a45ab105aabb36acfccde3a0276e2c91ff857a19 |
Hashes for soxr-0.2.6-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 827d835991c9148e4b1827c0b8a5165617ee2e28026ea12771d5d4e0fe151c04 |
|
MD5 | 2051cace1f097f69b11c4863df113bfc |
|
BLAKE2b-256 | deb6674a2c5ca64a6a870149429e32578b3b2f9f571dad81e5dd8040b7eaf72f |
Hashes for soxr-0.2.6-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2fb4ea4b552773a749ad6f8d3dc05e2a996f8b8f2b526b9dc7c6f79ec484cd97 |
|
MD5 | 1d948eade3c5a2896ace2062efb87bb6 |
|
BLAKE2b-256 | c420c0250f1af5060af1630b2720d81a166a7035c5bda18709122e23f05f2ab0 |
Hashes for soxr-0.2.6-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1af17a55c049889f68b6ab4549ef0b4fc5071dcc9e8245b7c3bbdfa3c0df5f7b |
|
MD5 | 55f07f8ab241436939584a34bf8f2f93 |
|
BLAKE2b-256 | 9f3c1c021b1dc483116e201c513b3166801513aef96471dc083fad559c7f3cb5 |
Hashes for soxr-0.2.6-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42497a0b2eed2906379fdab206b648dfdde5c8d177bb8b80739486129c2304a2 |
|
MD5 | 75e01f2f2034d97dfa82738abbb1ed80 |
|
BLAKE2b-256 | e0bffa80899028574b8a19e81b392b049d21656519aaaf61382e6f9105ccf21c |
Hashes for soxr-0.2.6-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2d40b7709a4e85b8c969e6bd358e09c86ccd4581bb933cc05e56ba4bfaf1622 |
|
MD5 | 694aaa1795c96f3383877b801468a117 |
|
BLAKE2b-256 | f403e0d65c5e2e5d84a25eb0dd288e7f99d1a54ec50e9e704ce4ff523b04bb15 |
Hashes for soxr-0.2.6-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74eedbfa96737416d66914f7a14978d52d6843d06854ba163b908d41cdf1d911 |
|
MD5 | ce7207d3940ca5fbe2d1b16cde5d4380 |
|
BLAKE2b-256 | 27d186fa899e3bf005d675fdcdfa7dfa5834e2eef6394e89722fc68a4e46aea8 |
Hashes for soxr-0.2.6-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 991bc08ee3abd3bb48b02fc6b6942a5293efbe81ac1adc4aa2f35218923b0be9 |
|
MD5 | a3f89f375e8dff88af20211ab72bc8ce |
|
BLAKE2b-256 | c50b6ebfafc68f6623260eac3d78a23ec7a256eaa4d1b011086d335f76d4311b |
Hashes for soxr-0.2.6-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0532ed9091b6e16bb8f745e3b8490d5a02f7a5f4488af79c71af988584ecc332 |
|
MD5 | 17dbb8fb09dcc38521c75ad65a06a7d4 |
|
BLAKE2b-256 | ea3b4a66959470485a5ea05c7f8535ee6c26bbfdf1f8cc1b28293367060d469b |
Hashes for soxr-0.2.6-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86082461f497f87684190137bca18ee5a36a5ef63b98c329c97de458395f46a7 |
|
MD5 | 70a019f37b52ce6e8e868258e63ea17f |
|
BLAKE2b-256 | 71717e80d62ed7eb800ca95d0130bb71167c37f2664b491624d6b559d381ccee |
Hashes for soxr-0.2.6-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2e9e57e71fd70094d35bde688ed7e855cb358b8aedcd61a3dbd1bd02caa0173 |
|
MD5 | bed4e16f3ca86c9aceefc13eec41a646 |
|
BLAKE2b-256 | a84104740174a0496dceaeeaf4d8018768a293ae4c38ca686c2dfa19e1045eb8 |