Metadata-Version: 2.4
Name: pysfizz
Version: 0.1.2
Summary: Python bindings for sfizz
Keywords: audio,synthesis,sfz,sampler,music,sfizz
Author-Email: Haokun Tian <tianhaokun258@gmail.com>
License-Expression: BSD-2-Clause
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Multimedia :: Sound/Audio :: Sound Synthesis
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Project-URL: Source, https://github.com/tiianhk/pysfizz
Project-URL: Tracker, https://github.com/tiianhk/pysfizz/issues
Requires-Python: >=3.9
Requires-Dist: numpy
Description-Content-Type: text/markdown

# pysfizz
Python bindings for [sfizz](https://github.com/sfztools/sfizz), a sample-based synthesizer for the [SFZ](https://sfzformat.com) virtual instrument format.

## Installation
### From PyPI
Prebuilt wheels are available for Python 3.9–3.13 on Linux, macOS, and Windows.
```bash
pip install pysfizz
```
### From source (development only)

**Requires:** Git, CMake 3.15+, C++17 compatible compiler, Python 3.9+ with development headers
```bash
git clone https://github.com/tiianhk/pysfizz.git
cd pysfizz
git submodule update --init --recursive
pip install .
```

## Example
```python
import pysfizz
import soundfile as sf

# load an instrument
synth = pysfizz.Synth(sample_rate=48000, block_size=1024)
synth.load_sfz_file("path/to/your/sfz/file.sfz")

# print the list of MIDI notes that have SFZ regions
print(synth.playable_keys)

# single note offline systhesis
pitch = 60       # MIDI note number, integer in [0, 127]
vel = 127        # MIDI velocity, integer in [0, 127]
note_dur = 1     # seconds, key pressed at t=0 and released after this duration
render_dur = 2   # seconds, total rendered duration
audio = synth.render_note(pitch, vel, note_dur, render_dur) # np.ndarray of shape (2, num_samples)
sf.write("output.wav", audio.T, synth.get_sample_rate())
```

## Resources
[SFZ instruments](https://sfzinstruments.github.io)

## License and dependencies

`pysfizz` is under the [BSD 2-Clause License](./LICENSE).

It includes the following dependencies as Git submodules under the `external/` directory:
- [sfizz](https://github.com/sfztools/sfizz) — BSD 2-Clause License  
- [nanobind](https://github.com/wjakob/nanobind) — BSD 3-Clause License
