accompy.synthesis#

Audio synthesis backends for accompy.

Provides abstraction over different synthesis engines:

  • FluidSynth: Default, uses SoundFonts for realistic instrument sounds

  • Pyo: Real-time synthesis (future integration with hum package)

The synthesis backends are used to convert MIDI files to audio.

Functions

get_default_backend()

Get the best available synthesis backend.

Classes

SynthesizerBackend()

Abstract base for audio synthesis backends.

class accompy.synthesis.SynthesizerBackend[source]#

Bases: ABC

Abstract base for audio synthesis backends.

Subclasses implement specific synthesis engines (FluidSynth, Pyo, etc.).

abstractmethod classmethod is_available()[source]#

Check if this backend’s dependencies are installed.

Return type:

bool

Returns:

True if the backend can be used

render_to_bytes(midi_path, *, sample_rate=44100)[source]#

Render a MIDI file to PCM bytes (for streaming).

Parameters:
  • midi_path (Path) – Path to MIDI file

  • sample_rate (int) – Audio sample rate

Return type:

bytes

Returns:

Raw PCM audio bytes

Note

Default implementation not provided - subclasses should override for streaming support.

abstractmethod render_to_file(midi_path, output_path, *, sample_rate=44100)[source]#

Render a MIDI file to an audio file.

Parameters:
  • midi_path (Path) – Path to input MIDI file

  • output_path (Path) – Path for output audio file

  • sample_rate (int) – Audio sample rate in Hz

Return type:

Path

Returns:

Path to the created audio file

accompy.synthesis.get_default_backend()[source]#

Get the best available synthesis backend.

Return type:

SynthesizerBackend

Returns:

An instance of an available SynthesizerBackend

Raises:

RuntimeError – If no synthesis backend is available

Modules

fluidsynth

FluidSynth synthesis backend.