Skip to content
Browse files

Merge branch 'master' of https://github.com/cgdolan/21M359Fall2012

  • Loading branch information...
2 parents 2fe67a1 + 431d95e commit eb581f128f8e794e87a63cfc65fd9e2b95eebe47 @mwittels mwittels committed Nov 29, 2012
Showing with 14 additions and 1 deletion.
  1. +14 −1 chord.py
View
15 chord.py
@@ -12,7 +12,8 @@ def __init__(self, pitch_classes):
raise Exception("Chord must be initialized with a list of pitch classes. Got entry of list: {0}, which is {1}".format(entry, type(entry)))
self.pitch_classes = tuple(sorted( p % 12 for p in pitch_classes ))
-
+ #We should reinitialize this to accept octaves and note names (like C#4 vs C#6, we don't want them both to be '2')
+
def transpose(self, steps):
if not isinstance(steps, int):
raise Exception("Transpose steps must be an int. Chord {0} got: {1} which is {2}".format(str(self), steps, type(steps)))
@@ -43,6 +44,18 @@ def interval_vector(self):
intervals[interval] += 1
return tuple( intervals[i + 1] for i in range(6) )
+ def zero_shifted(self):
+ sorted_pitch_classes = []
+ sorted_pitch_classes = sorted(pitch_classes)
+ if sorted_pitch_classes[0] == 0:
+ return Chord(sorted_pitch_classes)
+ else:
+ shifting_factor = sorted_pitch_classes[0]
+ for i in sorted_pitch_classes:
+ sorted_pitch_classes[i] = sorted_pitch_classes[i]-shifting_factor
+ return Chord(sorted_pitch_classes)
+
+
def __repr__(self):
return "({0})".format(",".join([str(pc) for pc in self.pitch_classes]))

0 comments on commit eb581f1

Please sign in to comment.
Something went wrong with that request. Please try again.