Synthesis¶
Symusic can turn a Score into sound using SoundFont 2/3 data and the Prestosynth engine. This
section explains the moving pieces so you can audition scores, render datasets, or embed procedural
music into an application.
Components¶
SoundFont –
.sf2/.sf3file that defines instrument samples and playback rules. UseBuiltInSF2/3helpers to download curated fonts or provide your own path.Synthesizer – Python/nanobind wrapper around Prestosynth. Constructed with
sf_path,sample_rate, and an optionalqualityflag.Score – Input data. Tracks contribute
programandis_drummetadata so instruments map correctly.render()– Converts the score to seconds (if necessary), schedules each event, and returns a NumPy array shaped[channels, samples].dump_wav()– Convenience helper to write the array to disk.
Usage pattern¶
from symusic import Score, Synthesizer, BuiltInSF3, dump_wav
score = Score("piece.mid")
sf_path = BuiltInSF3.MuseScoreGeneral().path(download=True)
synth = Synthesizer(sf_path=sf_path, sample_rate=48000, quality=1)
audio = synth.render(score, stereo=True)
dump_wav("piece.wav", audio, sample_rate=48000)
Rendering always works in
secondunits internally, so conversions are automatic.Percussion tracks (
is_drum=True) trigger the GM drum kit region inside the SoundFont.qualitytoggles different interpolation / oversampling strategies inside Prestosynth.
When to reach for synthesis¶
Preview arrangements without leaving your notebook.
Generate audio datasets aligned with symbolic annotations.
Prototype differentiable or procedural music systems that need quick feedback loops.
See symusic.Synthesizer and symusic.dump_wav for all arguments and return types.