Skip to content

Commit ec23a11

Browse files
authored
Add README for python-samplerate-ledfx project
This README provides an overview of the python-samplerate-ledfx project, including its purpose, installation instructions, usage examples, and related projects.
1 parent 52f4d99 commit ec23a11

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# python-samplerate-ledfx
2+
> **Note:** This is a fork of the original [python-samplerate](https://github.com/tuxu/python-samplerate) maintained by the [LedFx](https://github.com/LedFx) team.
3+
>
4+
> **Why this fork exists:**
5+
> - The original python-samplerate project is sporadically active
6+
> - We need Python 3.14 support with pre-built wheels on PyPI
7+
> - We require the latest fixes and improvements from the main branch of python-samplerate
8+
> - LedFx depends on python-samplerate and needs a reliable, up-to-date release
9+
>
10+
> All credit for python-samplerate goes to the original authors. This fork exists solely to provide maintained releases for projects that depend on python-samplerate.
11+
>
12+
> **Original project:** https://github.com/tuxu/python-samplerate
13+
> **This fork:** https://github.com/LedFx/python-samplerate-ledfx
14+
[![image](https://img.shields.io/pypi/v/samplerate-ledfx.svg)](https://pypi.python.org/pypi/samplerate-ledfx)[![image](https://img.shields.io/pypi/l/samplerate-ledfx.svg)](https://pypi.python.org/pypi/samplerate)[![image](https://img.shields.io/pypi/wheel/samplerate-ledfx.svg)](https://pypi.python.org/pypi/samplerate-ledfx)[![image](https://img.shields.io/pypi/pyversions/samplerate-ledfx.svg)](https://pypi.python.org/pypi/samplerate-ledfx)[![Documentation Status](https://readthedocs.org/projects/python-samplerate/badge/?version=latest)](http://python-samplerate.readthedocs.io/en/latest/?badge=latest)
15+
16+
This is a wrapper around Erik de Castro Lopo's [libsamplerate](http://www.mega-nerd.com/libsamplerate/) (aka Secret Rabbit Code) for high-quality sample rate conversion.
17+
18+
It implements all three [APIs](http://www.mega-nerd.com/libsamplerate/api.html) available in [libsamplerate](http://www.mega-nerd.com/libsamplerate/):
19+
20+
- **Simple API**: for resampling a large chunk of data with a single library call
21+
- **Full API**: for obtaining the resampled signal from successive chunks of data
22+
- **Callback API**: like Full API, but input samples are provided by a callback function
23+
24+
The [libsamplerate](http://www.mega-nerd.com/libsamplerate/) library is statically built together with the python bindings using [pybind11](https://github.com/pybind/pybind11/).
25+
26+
## Installation
27+
28+
> \$ pip install samplerate-ledfx
29+
30+
Binary wheels of [samplerate-ledfx](https://pypi.org/p/samplerate-ledfx) are available. A C++ 14 or above compiler is required to build the package.
31+
32+
## Usage
33+
34+
``` python
35+
import numpy as np
36+
import samplerate
37+
38+
# Synthesize data
39+
fs = 1000.
40+
t = np.arange(fs * 2) / fs
41+
input_data = np.sin(2 * np.pi * 5 * t)
42+
43+
# Simple API
44+
ratio = 1.5
45+
converter = 'sinc_best' # or 'sinc_fastest', ...
46+
output_data_simple = samplerate.resample(input_data, ratio, converter)
47+
48+
# Full API
49+
resampler = samplerate.Resampler(converter, channels=1)
50+
output_data_full = resampler.process(input_data, ratio, end_of_input=True)
51+
52+
# The result is the same for both APIs.
53+
assert np.allclose(output_data_simple, output_data_full)
54+
55+
# See `samplerate.CallbackResampler` for the Callback API, or
56+
# `examples/play_modulation.py` for an example.
57+
```
58+
59+
See `samplerate.resample`, `samplerate.Resampler`, and `samplerate.CallbackResampler` in the API documentation for details.
60+
61+
## See also
62+
63+
- [scikits.samplerate](https://pypi.python.org/pypi/scikits.samplerate) implements only the Simple API and uses [Cython](http://cython.org/) for extern calls. The resample function of scikits.samplerate and this package share the same function signature for compatiblity.
64+
- [resampy](https://github.com/bmcfee/resampy): sample rate conversion in Python + Cython.
65+
66+
## License
67+
68+
This project is licensed under the [MIT license](https://opensource.org/licenses/MIT).
69+
70+
As of version 0.1.9,
71+
[libsamplerate](http://www.mega-nerd.com/libsamplerate/) is licensed under the [2-clause BSD license](https://opensource.org/licenses/BSD-2-Clause).

0 commit comments

Comments
 (0)