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.3.tar.gz (21.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

samplerate-0.2.3-cp314-cp314-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.14Windows x86-64

samplerate-0.2.3-cp314-cp314-macosx_10_15_universal2.whl (2.9 MB view details)

Uploaded CPython 3.14macOS 10.15+ universal2 (ARM64, x86-64)

samplerate-0.2.3-cp313-cp313-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.13Windows x86-64

samplerate-0.2.3-cp313-cp313-macosx_10_13_universal2.whl (2.9 MB view details)

Uploaded CPython 3.13macOS 10.13+ universal2 (ARM64, x86-64)

samplerate-0.2.3-cp312-cp312-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.12Windows x86-64

samplerate-0.2.3-cp312-cp312-macosx_10_13_universal2.whl (2.9 MB view details)

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

samplerate-0.2.3-cp311-cp311-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.11Windows x86-64

samplerate-0.2.3-cp311-cp311-macosx_10_9_universal2.whl (2.9 MB view details)

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

samplerate-0.2.3-cp310-cp310-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.10Windows x86-64

samplerate-0.2.3-cp310-cp310-macosx_10_9_universal2.whl (2.9 MB view details)

Uploaded CPython 3.10macOS 10.9+ universal2 (ARM64, x86-64)

samplerate-0.2.3-cp39-cp39-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.9Windows x86-64

samplerate-0.2.3-cp39-cp39-macosx_10_9_universal2.whl (2.9 MB view details)

Uploaded CPython 3.9macOS 10.9+ universal2 (ARM64, x86-64)

File details

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

File metadata

  • Download URL: samplerate-0.2.3.tar.gz
  • Upload date:
  • Size: 21.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for samplerate-0.2.3.tar.gz
Algorithm Hash digest
SHA256 8da3726c4886946a8da16a08cb2c820b6b6b06ee8262673def72be846b3f3412
MD5 5c5641eb499df30d8ae8e1c61fc378a1
BLAKE2b-256 73ec4884b66131a30fe0ac659644d920b0a9ca21f38580eca54ad3fd6b1c2207

See more details on using hashes here.

File details

Details for the file samplerate-0.2.3-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: samplerate-0.2.3-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for samplerate-0.2.3-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 7826a1f1038b04e1ec29df08a0743fd5ed07c01e48e7d69508c23980ec281da0
MD5 6f4d01d1d7d0c15f40ce097ebae29569
BLAKE2b-256 9e4ebe557917c532ff3a53503a64904db97326abeb11ccad5286cf9883299a77

See more details on using hashes here.

File details

Details for the file samplerate-0.2.3-cp314-cp314-macosx_10_15_universal2.whl.

File metadata

File hashes

Hashes for samplerate-0.2.3-cp314-cp314-macosx_10_15_universal2.whl
Algorithm Hash digest
SHA256 e1ca8b7b77f8b3e47e2690abe323440dc171aa9d22f71f0239f96d26e0f7d396
MD5 5e46446de3064630c3d66da903d87910
BLAKE2b-256 ebaa628c86146ae08f420413a82ffad58d43f243677052f10ef6b492c179a0f4

See more details on using hashes here.

File details

Details for the file samplerate-0.2.3-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: samplerate-0.2.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for samplerate-0.2.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 41e6d09fc2a36ce7f6a26300d3abaffc58dc52f6fe53b2d2b8fc6af2c3aad470
MD5 5c4d96d63e2869b12309db04ea894884
BLAKE2b-256 0b7d11075fac2a2c0292cbaefb9259f9a2c455764a2441e5376793f881f56e29

See more details on using hashes here.

File details

Details for the file samplerate-0.2.3-cp313-cp313-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for samplerate-0.2.3-cp313-cp313-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 4d594028410487c864e7cbbcb6e0d154bdf12674969e7bd9844fc5cb9079fdb5
MD5 41fb6f4ea5146b46512a1893141c0f11
BLAKE2b-256 425ae11d7dc9652e99870f74f2ba0537031f657111e8bdf88839cdd2bb3b2235

See more details on using hashes here.

File details

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

File metadata

  • Download URL: samplerate-0.2.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for samplerate-0.2.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 8322bee1d38358c6f9eda4cc11020ce0462442355d438da470f668f2b1b468bd
MD5 954d84c3e697e5a5431bcdaa0121372c
BLAKE2b-256 2148dc0d204892666ae1814c9200aef1cba14688c77bf00238fdf6f821b408f2

See more details on using hashes here.

File details

Details for the file samplerate-0.2.3-cp312-cp312-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for samplerate-0.2.3-cp312-cp312-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 c1734ef6de0c1b5af0b7d43af89e3ace66c91b2b0c466f62cbffd297cb57f870
MD5 170c96b73ee95bc24214131822d464aa
BLAKE2b-256 a4b8f216eb61d2d54e1c7eaf50f4d3db0129d720761970baaa41d3698832019d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: samplerate-0.2.3-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for samplerate-0.2.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 0e5748685ca4e7501561d66c3fc0c38af0dba57aa788fed698bfaafde1c9e87c
MD5 aa582ae8dbada471f2b7995195806801
BLAKE2b-256 eb66758427b8314ab3c371e9e68b552711fbed39447ec8049354c3520aa07f7d

See more details on using hashes here.

File details

Details for the file samplerate-0.2.3-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for samplerate-0.2.3-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 f31e47cab7714932ba2b2fe65cede94062233e0aa84ceba4785d4187f9ee532e
MD5 76f2e98c859f2abecb90331fbb084b91
BLAKE2b-256 8d6a1dd6ddc6399f50b14c350e4cf2d6e2d9e3f6cc877dd2e6f95fbb4deee093

See more details on using hashes here.

File details

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

File metadata

  • Download URL: samplerate-0.2.3-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for samplerate-0.2.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e0872e87faeab46e63aadb8390d8a3288c797afb3e37a2bdcd3c7a1b9c8fd08c
MD5 4c6a8adeec329a21df0a0af2e530e644
BLAKE2b-256 b04f8432c79bdf86faa6bc03fda15ae4cf7bbf2ab8603577c26e325919b20a03

See more details on using hashes here.

File details

Details for the file samplerate-0.2.3-cp310-cp310-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for samplerate-0.2.3-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 0eef3bb952b7c50297a911f0c5df68ffb03bc91b8161dc7fc1e73360f1714517
MD5 9f2772fe61acf37d4fa1050f52446464
BLAKE2b-256 fee3db53f96a2bade811c8913fad0079af2ae529ffd73ce9671183bd504a7edb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: samplerate-0.2.3-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.13

File hashes

Hashes for samplerate-0.2.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 f7420d1efcb6a4c9955cd82dc4bcf997c1e2aedf7fe64670297a66aba1bcdb47
MD5 da8a0c0049128ed028bc67f928043c6b
BLAKE2b-256 ce2416604175cab081c019c70f0c18002a23294526dfae482e833f165009df3a

See more details on using hashes here.

File details

Details for the file samplerate-0.2.3-cp39-cp39-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for samplerate-0.2.3-cp39-cp39-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 c20823f715e6c925fa58af8145f97a1a9f3c480aaacf402be710fbf5a4f93914
MD5 a35ac55766e3fcddb19f401d5d97d418
BLAKE2b-256 23c37a7faaec1bf6815acb61847f943dd7d9ea12f1dcbcf4afd00ee2ce41a17c

See more details on using hashes here.

Supported by

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