From 55b76cf5a5c2930bb185caf427db464fee45579f Mon Sep 17 00:00:00 2001 From: Nils Date: Thu, 8 Sep 2022 19:23:58 +0200 Subject: [PATCH] limit internal pitches to 0 to 127. They can be reached through the GUI and need protection logic --- engine/pattern.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/engine/pattern.py b/engine/pattern.py index 3bb5621..c34152b 100644 --- a/engine/pattern.py +++ b/engine/pattern.py @@ -395,6 +395,10 @@ class Pattern(object): velocity = noteDict["velocity"] pitch = self._cachedTransposedScale[noteDict["pitch"] + scaleTransposition] + halftoneTransposition + if pitch > 127: + pitch = 127 + elif pitch < 0: + pitch = 0 exportPattern += cbox.Pattern.serialize_event(startTick, 0x90 + self.parentTrack.midiChannel, pitch, velocity) # note on exportPattern += cbox.Pattern.serialize_event(endTick-1, 0x80 + self.parentTrack.midiChannel, pitch, velocity) # note off #-1 ticks to create a small logical gap. Does not affect next note on.