Synthesis

muspy.write_audio(path: Union[str, pathlib.Path], music: Music, soundfont_path: Union[str, pathlib.Path, None] = None, rate: int = 44100, audio_format: Optional[str] = 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.
  • soundfont_path (str or Path, optional) – Path to the soundfount file. Defaults to the path to the downloaded MuseScore General soundfont.
  • rate (int) – Sample rate (in samples per sec). Defaults to 44100.
  • audio_format (str, {'wav', 'aiff', 'flac', 'oga'}, optional) – File format to write. If None, infer it from the extension.
muspy.synthesize(music: Music, soundfont_path: Union[str, pathlib.Path, None] = None, rate: int = 44100) → numpy.ndarray[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) – Sample rate (in samples per sec). Defaults to 44100.
Returns:

Synthesized waveform.

Return type:

ndarray, dtype=int16, shape=(?, 2)