Skip to content

Commit

Permalink
ps_project: add compability with old version schema
Browse files Browse the repository at this point in the history
  • Loading branch information
SoulMelody committed Dec 28, 2024
1 parent f053436 commit 2e3595d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions libresvip/plugins/ps_project/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ class PocketSingerNote(PocketSingerNoteBase):
pitch_bends: list[PocketSingerPitchBend] = Field(default_factory=list, alias="pitchBends")
consonant_time_head: Optional[list[float]] = None
phone: list[str] = Field(default_factory=list)
grapheme_count: int
grapheme_index: int
grapheme_count: int = 1
grapheme_index: int = 0
language: PocketSingerLyricsLanguage = PocketSingerLyricsLanguage.CHINESE
grapheme: str
grapheme: str = Field(validation_alias="word")
pitch: int
type: Literal["phone"] = "phone"
br: bool = False
Expand Down
5 changes: 3 additions & 2 deletions libresvip/plugins/ps_project/pocket_singer_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ def parse_notes(self, ps_notes: list[PocketSingerNote]) -> tuple[list[Note], lis
pitch_points: list[Point] = []
for ps_note in ps_notes:
start_pos = int(self.synchronizer.get_actual_ticks_from_secs(ps_note.start_time))
real_pitch = ps_note.pitch - 12 if self.project.version < 3 else ps_note.pitch
note = Note(
lyric=ps_note.grapheme if ps_note.grapheme_index == 0 else "+",
key_number=ps_note.pitch,
key_number=real_pitch,
start_pos=start_pos,
length=int(self.synchronizer.get_actual_ticks_from_secs(ps_note.end_time))
- start_pos,
Expand All @@ -99,7 +100,7 @@ def parse_notes(self, ps_notes: list[PocketSingerNote]) -> tuple[list[Note], lis
self.synchronizer.get_actual_ticks_from_secs(pitch_bend.time)
+ self.first_bar_length
),
y=int((pitch_bend.pitch + ps_note.pitch) * 100),
y=int((pitch_bend.pitch + real_pitch) * 100),
)
for pitch_bend in pitch_bends
)
Expand Down

0 comments on commit 2e3595d

Please sign in to comment.