jdxi_editor.midi.fluidsynth_library

Native FluidSynth library lookup

pyfluidsynth (import fluidsynth) is only the Python interface: it loads the native FluidSynth library when imported. On Windows it finds libfluidsynth-3.dll only through PATH or C:\tools\fluidsynth\bin, so call prepare_fluidsynth_library() before importing it. That adds the first folder that has the DLL, searched in this order:

  1. FLUIDSYNTH_DIR (environment variable): the folder holding the DLL, or a FluidSynth install whose bin folder holds it

  2. fluidsynth/bin in the application bundle (the Windows build ships it) or the repository checkout (it is committed there)

  3. the folder of the executable (frozen builds)

  4. C:\tools\fluidsynth\bin, %ProgramFiles%\FluidSynth\bin and a Chocolatey install (choco install fluidsynth)

On macOS and Linux the system loader finds Homebrew or distribution packages, so nothing is done there.

Example

>>> prepare_fluidsynth_library()
>>> import fluidsynth

Attributes

FLUIDSYNTH_DIR_ENV

DLL_PATTERN

_REPOSITORY_ROOT

_dll_directory_handles

_prepared_dir

Functions

candidate_dirs() → list[pathlib.Path]

Folders that may hold libfluidsynth-*.dll, most specific first.

find_library_dir([dirs]) → Optional[pathlib.Path]

The first folder that contains libfluidsynth-*.dll, or None.

prepare_fluidsynth_library([platform]) → Optional[pathlib.Path]

Make the native FluidSynth library findable before import fluidsynth.

missing_library_message([platform]) → str

How to install the native library, for this platform.

import_error_message(error[, platform]) → str

A status line for a failed import fluidsynth.

Module Contents

jdxi_editor.midi.fluidsynth_library.FLUIDSYNTH_DIR_ENV = 'FLUIDSYNTH_DIR'[source]
jdxi_editor.midi.fluidsynth_library.DLL_PATTERN = 'libfluidsynth*.dll'[source]
jdxi_editor.midi.fluidsynth_library._REPOSITORY_ROOT[source]
jdxi_editor.midi.fluidsynth_library._dll_directory_handles: list = [][source]
jdxi_editor.midi.fluidsynth_library._prepared_dir: pathlib.Path | None = None[source]
jdxi_editor.midi.fluidsynth_library.candidate_dirs() → list[pathlib.Path][source]

Folders that may hold libfluidsynth-*.dll, most specific first.

jdxi_editor.midi.fluidsynth_library.find_library_dir(dirs: Iterable[pathlib.Path] | None = None) → pathlib.Path | None[source]

The first folder that contains libfluidsynth-*.dll, or None.

jdxi_editor.midi.fluidsynth_library.prepare_fluidsynth_library(platform: str = sys.platform) → pathlib.Path | None[source]

Make the native FluidSynth library findable before import fluidsynth.

Returns:

the folder added to the DLL search (Windows), else None

jdxi_editor.midi.fluidsynth_library.missing_library_message(platform: str = sys.platform) → str[source]

How to install the native library, for this platform.

jdxi_editor.midi.fluidsynth_library.import_error_message(error: str, platform: str = sys.platform) → str[source]

A status line for a failed import fluidsynth.