Synthesis
- muspy.write_audio(path, music, audio_format=None, soundfont_path=None, rate=44100, gain=None)[source]
Write a Music object to an audio file.
Supported formats include WAV, AIFF, FLAC and OGA.
- Parameters
path (str or Path) – Path to write the audio file.
music (
muspy.Music
) – Music object to write.audio_format (str, {'wav', 'aiff', 'flac', 'oga'}, optional) – File format to write. Defaults to infer from the extension.
soundfont_path (str or Path, optional) – Path to the soundfount file. Defaults to the path to the downloaded MuseScore General soundfont.
rate (int, default: 44100) – Sample rate (in samples per sec).
gain (float, optional) – Master gain (-g option) for Fluidsynth. Defaults to 1/n, where n is the number of tracks. This can be used to prevent distortions caused by clipping.
- muspy.synthesize(music, soundfont_path=None, rate=44100, gain=None)[source]
Synthesize a Music object to raw audio.
- Parameters
music (
muspy.Music
) – Music object to write.soundfont_path (str or Path, optional) – Path to the soundfount file. Defaults to the path to the downloaded MuseScore General soundfont.
rate (int, default: 44100) – Sample rate (in samples per sec).
gain (float, optional) – Master gain (-g option) for Fluidsynth. Defaults to 1/n, where n is the number of tracks. This can be used to prevent distortions caused by clipping.
- Returns
Synthesized waveform.
- Return type
ndarray, dtype=int16, shape=(?, 2)