Skip to main content

Monolithic python wrapper for libsamplerate based on pybind11 and NumPy

Project description

https://img.shields.io/pypi/v/samplerate.svg https://img.shields.io/pypi/l/samplerate.svg https://img.shields.io/pypi/wheel/samplerate.svg https://img.shields.io/pypi/pyversions/samplerate.svg Documentation Status

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

samplerate-0.2.1.tar.gz (21.5 kB view details)

Uploaded Source

Built Distributions

samplerate-0.2.1-cp312-cp312-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.12 Windows x86-64

samplerate-0.2.1-cp312-cp312-macosx_12_0_universal2.whl (2.9 MB view details)

Uploaded CPython 3.12 macOS 12.0+ universal2 (ARM64, x86-64)

samplerate-0.2.1-cp311-cp311-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.11 Windows x86-64

samplerate-0.2.1-cp311-cp311-macosx_12_0_universal2.whl (2.9 MB view details)

Uploaded CPython 3.11 macOS 12.0+ universal2 (ARM64, x86-64)

samplerate-0.2.1-cp310-cp310-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.10 Windows x86-64

samplerate-0.2.1-cp310-cp310-macosx_12_0_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.10 macOS 12.0+ x86-64

samplerate-0.2.1-cp39-cp39-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.9 Windows x86-64

samplerate-0.2.1-cp39-cp39-macosx_12_0_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.9 macOS 12.0+ x86-64

samplerate-0.2.1-cp38-cp38-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.8 Windows x86-64

samplerate-0.2.1-cp38-cp38-macosx_12_0_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.8 macOS 12.0+ x86-64

File details

Details for the file samplerate-0.2.1.tar.gz.

File metadata

  • Download URL: samplerate-0.2.1.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for samplerate-0.2.1.tar.gz
Algorithm Hash digest
SHA256 464d3574412024184fb7428ecbaa1b2e207bddf5fbc10a5d9ddc3fc1c7b7ab1e
MD5 9801600a41437221df0d6c4e34fa3fe7
BLAKE2b-256 bf9cd8978b13b8af2f28fdc425e2893f7419d1d6429da1c6a850be83ad095d4f

See more details on using hashes here.

File details

Details for the file samplerate-0.2.1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for samplerate-0.2.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c7f5e81b24debfa25981e367e3f5d191cf72e32b5c92613139f5ba94e7f18c01
MD5 8b579dbc5384183ca74f6e6a81775428
BLAKE2b-256 e9d0ac5500843d947a82d7552c098954219ca460199a14dc5ebf72b090a46b42

See more details on using hashes here.

File details

Details for the file samplerate-0.2.1-cp312-cp312-macosx_12_0_universal2.whl.

File metadata

File hashes

Hashes for samplerate-0.2.1-cp312-cp312-macosx_12_0_universal2.whl
Algorithm Hash digest
SHA256 69cc7ad887c36294129315a04a7f43837c7ed9caf42db94e9687cf66c9709200
MD5 a6b509c087def9c864c9a0cad4386841
BLAKE2b-256 be5e03eee29d705c82137a869333258228746f66a4a065a5dcce98e6dc1d17ef

See more details on using hashes here.

File details

Details for the file samplerate-0.2.1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for samplerate-0.2.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3ebd447f2040950edc1dac32cb4afed3a74ed37e8e5ffe4775470213f799801f
MD5 ccc93182322ce787712f3df9a5ad9c57
BLAKE2b-256 cda5f9deb72c8ba4f7264eb38cb5756a37c87fd3a685a486b2ca97063207d68e

See more details on using hashes here.

File details

Details for the file samplerate-0.2.1-cp311-cp311-macosx_12_0_universal2.whl.

File metadata

File hashes

Hashes for samplerate-0.2.1-cp311-cp311-macosx_12_0_universal2.whl
Algorithm Hash digest
SHA256 b0e1b5cb08edb19d232bd1ba67632590ed7a579b526ab4bf3983b4f2b2e9acb4
MD5 5d06569c2f6c6ce6aee478f78da413b5
BLAKE2b-256 74f7f6c5d7fe3b85a33b29bbf6868c897600492c5258b4b2d4d49bc2a9fdb9cc

See more details on using hashes here.

File details

Details for the file samplerate-0.2.1-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for samplerate-0.2.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c237959ba0fd391b3293f2905c23f1ae15a096fc987cd776aef380ba426491c6
MD5 fdd5ed81ed1189a3cb60c9cf0fb58f55
BLAKE2b-256 72d75d54efb240a691b233a20f5960661e903e5993fddc8a553f804757c0c6ed

See more details on using hashes here.

File details

Details for the file samplerate-0.2.1-cp310-cp310-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for samplerate-0.2.1-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 9b392e857cfeda712585d702871eab7169ba2c63209e8d2314fa2196d6127354
MD5 2eff979b8d39463e259898ecfceb14f7
BLAKE2b-256 a818e8b7d04cdd63ac9eec969519103deae38ea4c75ea8245f90c9a3c5663d05

See more details on using hashes here.

File details

Details for the file samplerate-0.2.1-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for samplerate-0.2.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 0656233932f76af6070f56edf34d8ef56e62e2c503553229d2388953a2166cda
MD5 65dca3918d387360dc1919351d1576bc
BLAKE2b-256 82a426e48ccbbfb0f3add1e7955506f35a3ec8aaf49be691600e991173f3dc65

See more details on using hashes here.

File details

Details for the file samplerate-0.2.1-cp39-cp39-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for samplerate-0.2.1-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 137563c6069e23441b4c2059cf95a3ed5b20a6d747d0488014becb94b4dfc32f
MD5 6e3c8882a5ead76926092be35ec62bcf
BLAKE2b-256 8609bbe626df90664eb0053d7165dbc80780f9169fc490c8e5a2a35febaebf95

See more details on using hashes here.

File details

Details for the file samplerate-0.2.1-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for samplerate-0.2.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 c02d6e0f7541c4f6a64b97ff6d0a84f53a0c432c965031491b48d9d75a81f102
MD5 cbcd77dc6de3544d1987d18d601a6ae7
BLAKE2b-256 c1664c83b56b441dbcc74ac838deb4e7c647f763d4ce1a9c35533f0af62ade10

See more details on using hashes here.

File details

Details for the file samplerate-0.2.1-cp38-cp38-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for samplerate-0.2.1-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 a2b39a7131da065072508548f0ab80c9565d8c75212eac2f61fc1b1f82bb1611
MD5 165fcd52773fcbe1805cbf14f397a2dd
BLAKE2b-256 b17569d049ab3ec2ab16d77891a932414d6e21afb46d5412bb7822f36b927d98

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page