From 772fa84b4fb82dcbbfdf2ea0dc2cadfbaeb4897b Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 25 Mar 2026 11:10:07 -0400 Subject: [PATCH] Fix drum pattern repeats: offset hit positions for each cycle Hits were piling up at the same positions instead of being spread across repeats. Now each repeat offsets by pattern.beats. Co-Authored-By: Claude Opus 4.6 (1M context) --- pytheory/rhythm.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pytheory/rhythm.py b/pytheory/rhythm.py index cbb809c..7e1851f 100644 --- a/pytheory/rhythm.py +++ b/pytheory/rhythm.py @@ -167,8 +167,11 @@ class Pattern: A Score containing drum hits as MIDI percussion notes. """ score = Score(self.time_signature_str, bpm=bpm) - for _ in range(repeats): - score._drum_hits.extend(self.hits) + for r in range(repeats): + offset = r * self.beats + for hit in self.hits: + score._drum_hits.append( + _Hit(hit.sound, hit.position + offset, hit.velocity)) score._drum_pattern_beats += self.beats return score