diff --git a/aria/data/midi.py b/aria/data/midi.py index a1211e9..fc275b5 100644 --- a/aria/data/midi.py +++ b/aria/data/midi.py @@ -99,6 +99,8 @@ def __init__( self.ticks_per_beat = ticks_per_beat self.metadata = metadata + self.pedal_resolved = False # Default value + # Special case that temo_msg is empty, in this case we spoof the default if not self.tempo_msgs: self.tempo_msgs = [ @@ -248,6 +250,12 @@ def _resolve_overlaps(self): def resolve_pedal(self): """Resolve pedal - extend note offsets and resolve note overlaps""" + # If has been already resolved, we don't recalculate + if self.pedal_resolved == True: + return self + + assert self.pedal_resolved == False, "Internal error" + # Organize note messages by channel note_msgs_c = defaultdict(list) for msg in self.note_msgs: @@ -265,6 +273,8 @@ def resolve_pedal(self): msg["data"]["end"] = pedal_end break + self.pedal_resolved = True + return self._resolve_overlaps() # TODO: