Skip to content

Commit 1205061

Browse files
authored
update readme
1 parent f4598ff commit 1205061

File tree

1 file changed

+42
-15
lines changed

1 file changed

+42
-15
lines changed

README.md

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,50 @@
1-
## Build from Source
1+
# pysfizz
2+
Python bindings for [sfizz](https://github.com/sfztools/sfizz), a sample-based synthesizer for the [SFZ](https://sfzformat.com) virtual instrument format.
23

3-
### Prerequisites
4-
- Python 3.9 or higher with development headers
5-
- CMake 3.15 or higher
6-
- C++17 compatible compiler
4+
## Installation
5+
### From PyPI
6+
Prebuilt wheels are available for Python 3.9–3.13 on Linux, macOS, and Windows.
7+
```bash
8+
pip install pysfizz
9+
```
10+
### From source (development only)
711

8-
### Build Steps
9-
1. Clone the repository & initialize submodules:
12+
**Requires:** Git, CMake 3.15+, C++17 compatible compiler, Python 3.9+ with development headers
1013
```bash
1114
git clone https://github.com/tiianhk/pysfizz.git
1215
cd pysfizz
1316
git submodule update --init --recursive
17+
pip install .
1418
```
15-
2. Build the Python module:
16-
```bash
17-
cmake -B build -DCMAKE_BUILD_TYPE=Release
18-
cmake --build build --config Release --parallel
19-
```
20-
3. Test the Python module:
21-
```bash
22-
python -c "import pysfizz; print('pysfizz imported successfully!')"
19+
20+
## Example
21+
```python
22+
import pysfizz
23+
import soundfile as sf
24+
25+
# load an instrument
26+
synth = pysfizz.Synth(sample_rate=48000, block_size=1024)
27+
synth.load_sfz_file("path/to/your/sfz/file.sfz")
28+
29+
# print the list of MIDI notes that have SFZ regions
30+
print(synth.playable_keys)
31+
32+
# single note offline systhesis
33+
pitch = 60 # MIDI note number, integer in [0, 127]
34+
vel = 127 # MIDI velocity, integer in [0, 127]
35+
note_dur = 1 # seconds, key pressed at t=0 and released after this duration
36+
render_dur = 2 # seconds, total rendered duration
37+
audio = synth.render_note(pitch, vel, note_dur, render_dur) # np.ndarray of shape (2, num_samples)
38+
sf.write("output.wav", audio.T, synth.get_sample_rate())
2339
```
40+
41+
## Resources
42+
[SFZ instruments](https://sfzinstruments.github.io)
43+
44+
## License and dependencies
45+
46+
`pysfizz` is under the [BSD 2-Clause License](./LICENSE).
47+
48+
It includes the following dependencies as Git submodules under the `external/` directory:
49+
- [sfizz](https://github.com/sfztools/sfizz) — BSD 2-Clause License
50+
- [nanobind](https://github.com/wjakob/nanobind) — BSD 3-Clause License

0 commit comments

Comments
 (0)