ABC Interface

muspy.read_abc(path, number=None, resolution=24)[source]

Return an ABC file into Music object(s) using music21 backend.

Parameters
  • path (str or Path) – Path to the ABC file to read.

  • number (int, optional) – Reference number of a specific tune to read (i.e., the ‘X:’ field). Defaults to read all tunes.

  • resolution (int, default: muspy.DEFAULT_RESOLUTION (24)) – Time steps per quarter note.

Returns

Converted Music object(s).

Return type

list of muspy.Music

muspy.write_abc(path, music, **kwargs)[source]

Write a Music object to an ABC file.

Parameters
  • path (str or Path) – Path to write the ABC file.

  • music (muspy.Music) – Music object to write.

Kwargs
  • bars_per_line (int, optional) – Maximum number of bars that a single line of .abc file can contain. Defaults to 4.

  • compact_repeats (bool, optional) – Whether or not repeated sections of notes should be shortened. May cause errors in interpretation of music depending on reader used to read resultant .abc file. Defaults to True.