diff --git a/pytheory/chords.py b/pytheory/chords.py index c2b5257..a825ca2 100644 --- a/pytheory/chords.py +++ b/pytheory/chords.py @@ -6,9 +6,19 @@ class Chord: l = tuple([tone.full_name for tone in self.tones]) return f"" - # @property - # def harmony(self): - # pass + @property + def harmony(self): + if len(self.tones) < 2: + return 0 # No harmony for a single tone or empty chord + + # Calculate intervals between adjacent tones + intervals = [abs(self.tones[i].pitch() - self.tones[i-1].pitch()) for i in range(1, len(self.tones))] + + # Simple harmony calculation: sum of inverse intervals + # Smaller intervals contribute more to harmony + harmony_value = sum(1 / interval for interval in intervals if interval != 0) + + return harmony_value class NamedChord: def __init__(self, *, name, system):