Skip to content

Commit

Permalink
musicxml: fix syllabic attribute generation
Browse files Browse the repository at this point in the history
  • Loading branch information
SoulMelody committed Oct 15, 2024
1 parent e48ec31 commit 33472f0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
8 changes: 1 addition & 7 deletions libresvip/plugins/musicxml/musicxml_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,7 @@ def generate_note_node(self, note: MXmlMeasureContent) -> Optional[MusicXMLNote]
note_node.lyric.append(
Lyric(
syllabic=[getattr(Syllabic, note.note_type.name)],
text=[TextElementData(value=note.note.lyric)]
if note.note_type
in [
MXmlMeasureContent.NoteType.BEGIN,
MXmlMeasureContent.NoteType.SINGLE,
]
else [],
text=[TextElementData(value=note.note.lyric)],
)
)
return note_node
Expand Down
8 changes: 6 additions & 2 deletions libresvip/plugins/musicxml/musicxml_parser.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import dataclasses
from typing import Optional

from libresvip.core.constants import DEFAULT_CHINESE_LYRIC, TICKS_IN_BEAT
from libresvip.core.constants import DEFAULT_PHONEME, TICKS_IN_BEAT
from libresvip.model.base import (
Note,
Project,
Expand Down Expand Up @@ -135,7 +135,11 @@ def parse_track(
key = note2midi(f"{step.value}{octave}") + alter

lyric_nodes = note_node.lyric
lyric = lyric_nodes[0].text[0].value if len(lyric_nodes) else DEFAULT_CHINESE_LYRIC
lyric = (
lyric_nodes[0].text[0].value
if len(lyric_nodes) and len(lyric_nodes[0].text)
else DEFAULT_PHONEME
)

if not is_inside_note:
note = Note(
Expand Down

0 comments on commit 33472f0

Please sign in to comment.