Utilities¶
- class Synthesizer(sf_path: str | pathlib.Path, sample_rate: int = 44100, quality: int = 0)¶
Bases:
object
Prestosynth-powered renderer that turns scores into audio buffers using SF2/SF3 soundfonts. Reuse a single synthesizer per soundfont to avoid repeated disk I/O.
- Parameters:
sf_path – Filesystem path to an SF2/SF3 soundfont (either
strorpathlib.Path).sample_rate – Output sample rate in Hz.
quality – Prestosynth render quality hint (
0= default).
Examples
from symusic import Score, Synthesizer score = Score.from_file("example.mid") synth = Synthesizer("MuseScore_General.sf3", sample_rate=48000) buffer = synth.render(score, stereo=True) Synthesizer.dump_wav("example.wav", buffer, 48000, use_int16=True)
- render(self, score: symusic.core.ScoreTick, stereo: bool = True) Eigen::Array<float, -1, -1, 0, -1, -1>¶
- render(self, score: symusic.core.ScoreQuarter, stereo: bool = True) Eigen::Array<float, -1, -1, 0, -1, -1>
- render(self, score: symusic.core.ScoreSecond, stereo: bool = True) Eigen::Array<float, -1, -1, 0, -1, -1>
Render a
symusic.Scoreinto a float32 waveform.- Parameters:
score – Tick/quarter/second score to render.
stereo – When
Truetwo channels are emitted; otherwise mono.