From d65457080445822460fd82167c30a9ed3fb0ce81 Mon Sep 17 00:00:00 2001 From: SoulMelody Date: Wed, 22 Jan 2025 14:35:56 +0800 Subject: [PATCH] svg: normalize pitch points --- libresvip/plugins/svg/coordinate_helper.py | 2 ++ libresvip/plugins/svg/svg_generator.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/libresvip/plugins/svg/coordinate_helper.py b/libresvip/plugins/svg/coordinate_helper.py index 2cf373b17..b91f19948 100644 --- a/libresvip/plugins/svg/coordinate_helper.py +++ b/libresvip/plugins/svg/coordinate_helper.py @@ -21,6 +21,8 @@ class CoordinateHelper: key_range_end: int = dataclasses.field(init=False) def calculate_range(self, track: SingingTrack) -> None: + if not len(track.edited_params.pitch.points): + track.edited_params.pitch.points.root = [Point.start_point(), Point.end_point()] self.position_range_start = min( track.note_list[0].start_pos, track.edited_params.pitch.points[1].x ) diff --git a/libresvip/plugins/svg/svg_generator.py b/libresvip/plugins/svg/svg_generator.py index 5aa630a54..db44d8039 100644 --- a/libresvip/plugins/svg/svg_generator.py +++ b/libresvip/plugins/svg/svg_generator.py @@ -33,7 +33,7 @@ def generate_project(self, project: Project) -> Drawing: ) else: first_singing_track = project.track_list[self.options.track_index] - if first_singing_track is not None: + if isinstance(first_singing_track, SingingTrack): self.coordinate_helper.calculate_range(first_singing_track) if self.options.show_grid: self.svg_factory.draw_grid(project.time_signature_list)