Skip to content

Commit

Permalink
svp: fix for nullable simulated pitch value
Browse files Browse the repository at this point in the history
  • Loading branch information
SoulMelody committed Oct 14, 2024
1 parent e3095ca commit bba2823
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions libresvip/plugins/svp/synthv_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,14 @@ def generate_note(self, note: Note) -> SVNote:
def generate_pitch_diff(self, pos: int, pitch: int) -> float:
target_note_index = find_last_index(self.note_buffer, lambda x: x.start_pos <= pos)
target_note = self.note_buffer[target_note_index] if target_note_index >= 0 else None
pitch_diff = pitch - self.pitch_simulator.pitch_at_secs(
self.synchronizer.get_actual_secs_from_ticks(pos)
)
if (
simulated_pitch := self.pitch_simulator.pitch_at_secs(
self.synchronizer.get_actual_secs_from_ticks(pos)
)
) is not None:
pitch_diff = pitch - simulated_pitch
else:
pitch_diff = 0.0
if target_note is None:
return pitch_diff
if (
Expand Down

0 comments on commit bba2823

Please sign in to comment.