Skip to content

Commit

Permalink
added support for N chords
Browse files Browse the repository at this point in the history
  • Loading branch information
andreamust committed Jan 20, 2023
1 parent 7fa0e72 commit 7b2b2c5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ The main functionality of the Harte Library is an extension of the *Chord Module
This is possible by means of the class __Harte__, which accepts as input a chord expressed in Harte Notation and allows all properties and methods of the Chord module of music21 to be used:

```python
from harte.harte_core import Harte
from harte.harte import Harte

chord = Harte('C#:maj7(b6)/b3')

Expand All @@ -75,7 +75,7 @@ In addition, the library implements new methods specific to Harte notation, incl
* __prettify__: breaks the chord into its components and recomposes it by choosing the most summarised shorthand, if possible.

```python
from harte.harte_core import Harte
from harte.harte import Harte

chord = Harte('D:(b3,5,7,9)')

Expand Down
9 changes: 8 additions & 1 deletion harte/harte_core.py → harte/harte.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ def __init__(self, chord: str, **keywords):
f'The input chord {chord} is not a valid Harte chord') \
from name_error

if "root" in parsed_chord:
if self.chord == 'N':
self._root = self._bass = self._degrees = self._shorthand = None
self._all_degrees = []
super().__init__(self._all_degrees)
return

elif "root" in parsed_chord:
# chord is not empty
# retrieve information from the parsed chord
self._root = parsed_chord['root']
Expand Down Expand Up @@ -270,6 +276,7 @@ def __str__(self):
# test utilities
test_chord = Harte('N')
root = test_chord.get_root()
print(test_chord.pitchNames)
print(test_chord.fullName)
print(test_chord.commonName)
print(test_chord.inversion())
Expand Down
5 changes: 3 additions & 2 deletions test/test_harte.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import pytest

from harte.harte_core import Harte
from harte.harte import Harte

# load a dict of chords frequencies extracted from ChoCo [1]
# to test coverage of a big set of chords
Expand Down Expand Up @@ -37,7 +37,8 @@ def test_coverage(chord: str):
("C:maj", ["P5", "M3"]),
("C:min", ["P5", "m3"]),
("C:dim", ["d5", "m3"]),
("C:aug", ["A5", "M3"]), ])
("C:aug", ["A5", "M3"]),
("N", [])])
def test_interval_extraction(chord: str, intervals: List[str]):
"""
Test that the annotateIntervals of music21 correctly works in extracting
Expand Down

0 comments on commit 7b2b2c5

Please sign in to comment.