Skip to main content

Python bindings for Rubber Band audio pitch shifting and time stretching

Project description

rubband

Python bindings for Rubber Band audio pitch shifting and time stretching.

The current API is NumPy-only:

import rubband

shifted = rubband.stretch(
    audio,
    48_000,
    time_ratio=1.25,
    pitch_scale=1.0,
)

For stateful processing, use Stretcher:

stretcher = rubband.Stretcher(
    48_000,
    2,
    options=rubband.Options(
        process=rubband.ProcessOption.real_time,
    ),
    initial_time_ratio=1.0,
    initial_pitch_scale=1.0,
)
stretcher.process(audio, final=False)
stretcher.set_pitch_scale(2.0)
stretcher.set_time_ratio(0.75)

Dynamic set_pitch_scale() and set_time_ratio() changes are intended for real-time processing. In offline mode, call them before study() or process(); after either call, rubband raises ValueError.

Stretcher also exposes original Rubber Band lifecycle and query methods such as reset(), get_time_ratio(), get_pitch_scale(), get_preferred_start_pad(), get_start_delay(), get_channel_count(), set_expected_input_duration(), set_max_process_size(), get_samples_required(), set_transients_option(), set_detector_option(), set_phase_option(), set_formant_option(), and set_pitch_option().

Input constraints:

  • numpy.ndarray only
  • float32 only
  • CPU memory only
  • shape (frames,) for mono or (frames, channels) for multichannel audio
  • C-contiguous arrays only
  • sample rates from 8,000 to 192,000 Hz

The native backend is a nanobind extension over Rubber Band. Building it requires librubberband to be installed and discoverable through pkg-config.

Building

Local source builds need Rubber Band development headers and libraries:

  • macOS: brew install rubberband pkg-config
  • Linux: install your distribution's librubberband-dev or equivalent package
  • Windows: install Rubber Band through vcpkg and pass its CMake toolchain file

Build artifacts with:

uv build --sdist --wheel --out-dir dist

Then smoke-test the wheel in a clean virtual environment:

uv run python scripts/smoke_wheel.py dist/rubband-*.whl

Release builds are tag-driven. Pushing a v* tag runs the GitHub Actions workflow, builds platform artifacts, smoke-tests the wheel, writes checksums, and publishes a GitHub release.

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

rubband-0.1.0.tar.gz (6.9 MB view details)

Uploaded Source

Built Distributions

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

rubband-0.1.0-cp313-cp313-macosx_14_0_arm64.whl (73.3 kB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

rubband-0.1.0-cp311-cp311-macosx_14_0_arm64.whl (78.2 kB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

File details

Details for the file rubband-0.1.0.tar.gz.

File metadata

  • Download URL: rubband-0.1.0.tar.gz
  • Upload date:
  • Size: 6.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for rubband-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b98525a61923307bf8f5b7643067f42e5ec59f8eaff56ebdafa639f98023a25e
MD5 b5e046daaa6b97cb0e5c9e4bf890f212
BLAKE2b-256 cd776e3b6d19a1b3561c37ce94625277d13871d8c0074403bd55e6703112e62b

See more details on using hashes here.

File details

Details for the file rubband-0.1.0-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

  • Download URL: rubband-0.1.0-cp313-cp313-macosx_14_0_arm64.whl
  • Upload date:
  • Size: 73.3 kB
  • Tags: CPython 3.13, macOS 14.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for rubband-0.1.0-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 8218ca246d08ea1f97f1b72520907d4d4d5bb5d64dd09fd0629e71c2fd765d51
MD5 aa0332340da4315e9002ef7ce0972e59
BLAKE2b-256 81bf23d8b67953a381eabc586dd8678e7ed26894ade6a4276d54b71311ad8c12

See more details on using hashes here.

File details

Details for the file rubband-0.1.0-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

  • Download URL: rubband-0.1.0-cp311-cp311-macosx_14_0_arm64.whl
  • Upload date:
  • Size: 78.2 kB
  • Tags: CPython 3.11, macOS 14.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for rubband-0.1.0-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 6cdff70df2016b22313378ed14608df0cd7de558222ae2bde23c3b1b2fe56e1d
MD5 ff7511cbe408cd00c5041ae861cba7e3
BLAKE2b-256 f7792e41faf3d3d2101fdbdb56ba91255b90a3d384f648b4e46460622af5ade5

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