accompy.synthesis.fluidsynth#

FluidSynth synthesis backend.

Uses FluidSynth with SoundFonts to render MIDI to high-quality audio. FluidSynth is the default and most widely-supported backend for accompy.

Functions

convert_audio(input_path, output_path)

Convert audio between formats using ffmpeg or pydub.

find_default_soundfont()

Find the default SoundFont file in standard locations.

Classes

FluidSynthBackend([soundfont_path])

FluidSynth-based synthesis.

class accompy.synthesis.fluidsynth.FluidSynthBackend(soundfont_path=None)[source]#

Bases: SynthesizerBackend

FluidSynth-based synthesis.

Uses SoundFont files (.sf2) to render MIDI with realistic instrument sounds. Supports both Python wrapper (midi2audio) and command-line FluidSynth.

Example

>>> backend = FluidSynthBackend()
>>> backend.render_to_file(midi_path, output_path)
classmethod is_available()[source]#

Check if FluidSynth is available.

Return type:

bool

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

Render MIDI file to audio using FluidSynth.

Tries Python wrapper (midi2audio) first, then falls back to command-line FluidSynth.

Parameters:
  • midi_path (Path) – Input MIDI file

  • output_path (Path) – Output audio file (.wav, .mp3, .flac)

  • sample_rate (int) – Sample rate in Hz

Return type:

Path

Returns:

Path to created audio file

accompy.synthesis.fluidsynth.convert_audio(input_path, output_path)[source]#

Convert audio between formats using ffmpeg or pydub.

Parameters:
  • input_path (Path) – Input audio file

  • output_path (Path) – Output audio file

Raises:

RuntimeError – If neither ffmpeg nor pydub is available

Return type:

None

accompy.synthesis.fluidsynth.find_default_soundfont()[source]#

Find the default SoundFont file in standard locations.

Return type:

Optional[Path]

Returns:

Path to SoundFont file, or None if not found