muspy.visualization¶
Visualization tools.
This module provides functions for visualizing a Music object.
Classes¶
- ScorePlotter
Functions¶
- show
- show_pianoroll
- show_score
-
muspy.visualization.
show
(music: Music, kind: str, **kwargs)[source]¶ Show visualization.
Parameters: - music (
muspy.Music
) – Music object to convert. - kind (str, {'piano-roll', 'score'}) – Target representation.
- music (
-
muspy.visualization.
show_score
(music: Music, figsize: Optional[Tuple[float, float]] = None, clef: str = 'treble', clef_octave: Optional[int] = 0, note_spacing: Optional[int] = None, font_path: Union[str, pathlib.Path, None] = None, font_scale: Optional[float] = None) → muspy.visualization.score.ScorePlotter[source]¶ Show score visualization.
Parameters: - music (
muspy.Music
) – Music object to show. - figsize ((float, float), optional) – Width and height in inches. Defaults to Matplotlib configuration.
- clef (str, {'treble', 'alto', 'bass'}) – Clef type. Defaults to a treble clef.
- clef_octave (int) – Clef octave. Defaults to zero.
- note_spacing (int, optional) – Spacing of notes. Defaults to 4.
- font_path (str or Path, optional) – Path to the music font. Defaults to the path to the built-in Bravura font.
- font_scale (float, optional) – Font scaling factor for finetuning. Defaults to 140, optimized for the Bravura font.
Returns: A ScorePlotter object that handles the score.
Return type: - music (
-
class
muspy.visualization.
ScorePlotter
(fig: matplotlib.figure.Figure, ax: matplotlib.axes._axes.Axes, resolution: int, note_spacing: Optional[int] = None, font_path: Union[str, pathlib.Path, None] = None, font_scale: Optional[float] = None)[source]¶ A plotter that handles the score visualization.
-
fig
¶ Figure object to plot the score on.
Type: matplotlib.figure.Figure
-
axes
¶ Axes object to plot the score on.
Type: matplotlib.axes.Axes
-
font_path
¶ Path to the music font. Defaults to the path to the downloaded Bravura font.
Type: str or Path, optional
-
font_scale
¶ Font scaling factor for finetuning. Defaults to 140, optimized for the Bravura font.
Type: float, optional
-
plot_key_signature
(root: int, mode: str)[source]¶ Plot a key signature. Only major and minor keys are supported.
-
plot_note
(time, duration, pitch) → Optional[Tuple[List[matplotlib.text.Text], List[matplotlib.patches.Arc]]][source]¶ Plot a note.
-
plot_staffs
(start: Optional[float] = None, end: Optional[float] = None) → List[matplotlib.lines.Line2D][source]¶ Plot the staffs.
-