-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
26 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,16 @@ | |
|
||
_Python bindings for FluidSynth_ | ||
|
||
This package contains python bindings for FluidSynth. FluidSynth is a software | ||
This package contains Python bindings for FluidSynth. FluidSynth is a software | ||
synthesizer for generating music. It works like a MIDI synthesizer. You load | ||
patches, set parameters, then send NOTEON and NOTEOFF events to play notes. | ||
Instruments are defined in SoundFonts, generally files with the extension SF2. | ||
FluidSynth can either be used to play audio itself, or you can call a function | ||
that returns chunks of audio data and output the data to the soundcard yourself. | ||
FluidSynth works on all major platforms, so pyFluidSynth should also. | ||
|
||
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/nwhitehead/pyfluidsynth/ci.yml) | ![PyPI - Version](https://img.shields.io/pypi/v/pyFluidSynth) | ![PyPI - Python Versions](https://img.shields.io/pypi/pyversions/pyFluidSynth) | | ||
|
||
|
||
## Requirements | ||
|
||
|
@@ -26,6 +28,7 @@ is a self-contained Python package that includes | |
[TinySoundFont](https://github.com/schellingb/TinySoundFont) for SoundFont | ||
playback and is permissively licensed. | ||
|
||
|
||
## Installation | ||
|
||
To use the latest official release: | ||
|
@@ -38,7 +41,7 @@ To use the latest official release: | |
To use pre-release versions of this package, clone this repository, go to the | ||
repository directory, then do: | ||
|
||
pip install . | ||
pip install --editable . | ||
|
||
|
||
## Example | ||
|
@@ -188,12 +191,12 @@ register it: | |
fs = fluidsynth.Synth() | ||
# init and start the synthesizer as described above… | ||
|
||
synthID = seq.register_fluidsynth(fs) | ||
synth_id = seq.register_fluidsynth(fs) | ||
``` | ||
You have to keep the ID and use it as a `target` for the midi events | ||
You have to keep `synth_id` and use it as a `target` for the midi events | ||
you want to schedule. Now, you can sequence actual notes: | ||
```python | ||
seq.note_on(time=500, absolute=False, channel=0, key=60, velocity=80, dest=synthID) | ||
seq.note_on(time=500, absolute=False, channel=0, key=60, velocity=80, dest=synth_id) | ||
``` | ||
If you use relative timing like above, the sequencer will | ||
schedule the event the specified time from the current position. | ||
|
@@ -202,19 +205,19 @@ absolute track positions (in ticks). So the following code snippet | |
will do the same as the one above: | ||
```python | ||
current_time = seq.get_tick() | ||
seq.note_on(current_time + 500, 0, 60, 80, dest=synthID) | ||
seq.note_on(current_time + 500, 0, 60, 80, dest=synth_id) | ||
``` | ||
You can also register your own callback functions to be called at | ||
certain ticks: | ||
```python | ||
def seq_callback(time, event, seq, data): | ||
print('callback called!') | ||
|
||
callbackID = sequencer.register_client("myCallback", seq_callback) | ||
callback_id = sequencer.register_client("myCallback", seq_callback) | ||
|
||
sequencer.timer(current_time + 2000, dest=callbackID) | ||
sequencer.timer(current_time + 2000, dest=callback_id) | ||
``` | ||
Note that event and seq are low-level objects, not actual python objects. | ||
Note that event and seq are low-level objects, not actual Python objects. | ||
|
||
You can find a complete example (inspired by [this one from the fluidsynth library](http://www.fluidsynth.org/api/index.html#Sequencer)) in the test folder. | ||
|
||
|
@@ -231,6 +234,7 @@ the functions incorrectly sometimes. | |
|
||
This project was originally created by Nathan Whitehead `[email protected]` but is the work of many. See [CONTRIBUTORS](./CONTRIBUTORS.md). | ||
|
||
|
||
## License | ||
|
||
Released under the LGPL v2.1 or any later | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,17 +7,15 @@ requires = [ "setuptools>=61.2" ] | |
name = "pyfluidsynth" | ||
version = "1.3.4" | ||
description = "Python bindings for FluidSynth, a MIDI synthesizer that uses SoundFont instruments" | ||
readme.content-type = "text/markdown" | ||
readme.file = "README.md" | ||
readme = { file = "README.md", content-type = "text/markdown" } | ||
authors = [ { name = "Nathan Whitehead", email = "[email protected]" } ] | ||
classifiers = [ | ||
"Programming Language :: Python :: 3 :: Only", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Python :: 3.12", | ||
# "Programming Language :: Python :: 3.13", | ||
"Programming Language :: Python :: 3.13", # Windows: https://github.com/nwhitehead/pyfluidsynth/issues/77 | ||
] | ||
dependencies = [ "numpy" ] | ||
|
||
|
@@ -28,7 +26,7 @@ py-modules = [ "fluidsynth" ] | |
include-package-data = false | ||
|
||
[tool.ruff] | ||
target-version = "py38" | ||
target-version = "py39" | ||
|
||
line-length = 123 | ||
lint.select = [ | ||
|
@@ -57,6 +55,7 @@ lint.select = [ | |
"PERF", # Perflint | ||
"PGH", # pygrep-hooks | ||
"PIE", # flake8-pie | ||
"PL", # Pylint | ||
"PT", # flake8-pytest-style | ||
"PYI", # flake8-pyi | ||
"RSE", # flake8-raise | ||
|
@@ -69,6 +68,7 @@ lint.select = [ | |
"TD", # flake8-todos | ||
"TID", # flake8-tidy-imports | ||
"UP", # pyupgrade | ||
"W", # pycodestyle | ||
"YTT", # flake8-2020 | ||
# "A", # flake8-builtins | ||
# "ANN", # flake8-annotations | ||
|
@@ -82,14 +82,14 @@ lint.select = [ | |
# "FURB", # refurb | ||
# "ICN", # flake8-import-conventions | ||
# "N", # pep8-naming | ||
# "PL", # Pylint | ||
# "PTH", # flake8-use-pathlib | ||
# "Q", # flake8-quotes | ||
# "RET", # flake8-return | ||
# "RUF", # Ruff-specific rules | ||
# "T20", # flake8-print | ||
# "TRY", # tryceratops | ||
# "W", # pycodestyle | ||
] | ||
lint.per-file-ignores."__init__.py" = [ "E402" ] | ||
lint.per-file-ignores."test/*" = [ "S101" ] | ||
lint.pylint.allow-magic-value-types = [ "int", "str" ] | ||
lint.pylint.max-args = 8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters