Monolithic python wrapper for libsamplerate based on pybind11 and NumPy
Project description
This is a wrapper around Erik de Castro Lopo’s libsamplerate (aka Secret Rabbit Code) for high-quality sample rate conversion.
It implements all three APIs available in libsamplerate:
Simple API: for resampling a large chunk of data with a single library call
Full API: for obtaining the resampled signal from successive chunks of data
Callback API: like Full API, but input samples are provided by a callback function
The libsamplerate library is statically built together with the python bindings using pybind11.
Installation
$ pip install samplerate
Binary wheels of libsamplerate for macOS and Windows (64 bit) are available. For other systems, a C++ 14 or above compiler is required to build the package.
Usage
import numpy as np
import samplerate
# Synthesize data
fs = 1000.
t = np.arange(fs * 2) / fs
input_data = np.sin(2 * np.pi * 5 * t)
# Simple API
ratio = 1.5
converter = 'sinc_best' # or 'sinc_fastest', ...
output_data_simple = samplerate.resample(input_data, ratio, converter)
# Full API
resampler = samplerate.Resampler(converter, channels=1)
output_data_full = resampler.process(input_data, ratio, end_of_input=True)
# The result is the same for both APIs.
assert np.allclose(output_data_simple, output_data_full)
# See `samplerate.CallbackResampler` for the Callback API, or
# `examples/play_modulation.py` for an example.
See samplerate.resample, samplerate.Resampler, and samplerate.CallbackResampler in the API documentation for details.
See also
scikits.samplerate implements only the Simple API and uses Cython for extern calls. The resample function of scikits.samplerate and this package share the same function signature for compatiblity.
resampy: sample rate conversion in Python + Cython.
License
This project is licensed under the MIT license.
As of version 0.1.9, libsamplerate is licensed under the 2-clause BSD license.
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 samplerate-0.2.0.tar.gz
.
File metadata
- Download URL: samplerate-0.2.0.tar.gz
- Upload date:
- Size: 21.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ad1134fcaae0d9fbc32a4e85eb2c0f9f6e4f7c232999635b38f83aa69fceb18 |
|
MD5 | 2f7883d617dfe9ec55670abdd9044cc9 |
|
BLAKE2b-256 | cd9f9ef134d4b344e7ccd431b93689ff17c73041e6fe9e58a09da948397bc2a7 |
File details
Details for the file samplerate-0.2.0-cp312-cp312-win_amd64.whl
.
File metadata
- Download URL: samplerate-0.2.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5cac97cceb229eeb256baf4d7519c9b3b5b0f92d47ad8d50f0ee38ef1e7d2818 |
|
MD5 | 85e3b6d9e5cc1fcb5bf6e6962e76ef1f |
|
BLAKE2b-256 | 7a607de6f833ccc364de629c4ef0836613f86f129d96bdcdcc578b6dc29252b0 |
File details
Details for the file samplerate-0.2.0-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: samplerate-0.2.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41ec224be933ec9e4638fd813c8fd67503a0c409e3a18ef883295c745caacb52 |
|
MD5 | 7101da7af7f133a6cea1d9c1e640741d |
|
BLAKE2b-256 | 2c3f9d0ad36a6af2e878ec3ffd8f1a5dd159452047c4d94b514a6aa5a71168f7 |
File details
Details for the file samplerate-0.2.0-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: samplerate-0.2.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65f34e2606e9551cc001644106cadc740f2af1dfb70c5c32d603f18d30b4a84f |
|
MD5 | 9874c887e8d684c48d5bcb0c369d8d3d |
|
BLAKE2b-256 | 5658022d26fa27babb50238e2b959040c0b9dbfd96d1c26fa59847e788557dc9 |
File details
Details for the file samplerate-0.2.0-cp310-cp310-macosx_12_0_x86_64.whl
.
File metadata
- Download URL: samplerate-0.2.0-cp310-cp310-macosx_12_0_x86_64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.10, macOS 12.0+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5321b0f8c98e86f71c45329f9576cd1d20cd42dff15e773f0d4b30d27a3852d1 |
|
MD5 | 2de63ed2aa9a93d006d77927e590e85f |
|
BLAKE2b-256 | 6dd6d933e6364069fbf3a61defac23de1cb893d9c928c3d87d9e5cf8cd7b2ab3 |
File details
Details for the file samplerate-0.2.0-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: samplerate-0.2.0-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c51d778f0137970435a1d4121df1863df83363817bddd124725b4e16544b136b |
|
MD5 | c570caa8bf2badedb365ef947c9ba47a |
|
BLAKE2b-256 | 0e46e72c3c33ea3272a2c631366e3d4e029fab61e39f6722d08de03fdb1f7ee3 |
File details
Details for the file samplerate-0.2.0-cp39-cp39-macosx_12_0_x86_64.whl
.
File metadata
- Download URL: samplerate-0.2.0-cp39-cp39-macosx_12_0_x86_64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.9, macOS 12.0+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d65ebb0d1e82b5b62d258471ee84b20eef2eb7b5885f5029a08570c16bea2c67 |
|
MD5 | f286d94b930ecc5139dedc3b6dfa7180 |
|
BLAKE2b-256 | f6a4faa42dcc3a76fa5737e5c7dcfe71d38a80f23042fa7e159525da8e8d647f |
File details
Details for the file samplerate-0.2.0-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: samplerate-0.2.0-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48560b115a04cff07de04c9ff6527eb6360f2321bbe9453c58e04cc661182850 |
|
MD5 | 92b4a5c97fb227d07633dde0a95e24a1 |
|
BLAKE2b-256 | 321c929d9e284fdb2961f2d18d9ca89e2cad5802f799b887613da0d1c6c60744 |
File details
Details for the file samplerate-0.2.0-cp38-cp38-macosx_12_0_x86_64.whl
.
File metadata
- Download URL: samplerate-0.2.0-cp38-cp38-macosx_12_0_x86_64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.8, macOS 12.0+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96b38fdb738f203deeabb8525f64cfd9946ce3141079280b22be5f5a80037beb |
|
MD5 | 455a7f49bbb033e8f7ece4fdb471ec9d |
|
BLAKE2b-256 | 0907bdcd385b5365634805ae8760dfd01b9e5543f842097701f7f2283ab59d5b |