Metadata-Version: 2.2
Name: pysfizz
Version: 0.1.0
Summary: Python bindings for sfizz
Keywords: audio,synthesis,sfz,sampler,music,sfizz
Author-Email: Haokun Tian <tianhaokun258@gmail.com>
License: BSD 2-Clause License
         
         Copyright (c) 2025, Haokun Tian
         
         Redistribution and use in source and binary forms, with or without
         modification, are permitted provided that the following conditions are met:
         
         1. Redistributions of source code must retain the above copyright notice, this
            list of conditions and the following disclaimer.
         
         2. Redistributions in binary form must reproduce the above copyright notice,
            this list of conditions and the following disclaimer in the documentation
            and/or other materials provided with the distribution.
         
         THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
         AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
         IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
         DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
         FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
         DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
         SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
         CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
         OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
         OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
         
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
Classifier: License :: OSI Approved :: BSD License
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
