andreamust / harte-library

Extension of the music21 library for working with music chords encoded according to the Harte Notation.
MIT License
5 stars 2 forks source link

`Harte('C#:min(b7)/b1')` contains C## instead of C #29

Closed rubencart closed 7 months ago

rubencart commented 7 months ago
c2 = Harte('C#:min(b7)/b1')
c2.pitches
Out[6]: 
(<music21.pitch.Pitch C##3>,
 <music21.pitch.Pitch C#4>,
 <music21.pitch.Pitch E4>,
 <music21.pitch.Pitch G#4>,
 <music21.pitch.Pitch B4>)
c2.prettify()
Out[7]: 'C#:min7(b1)/b1'
c2.unwrap_shorthand()
Out[8]: ['b1', 'b3', '5', 'b7']

I might be wrong, and I don't know this chord, but I don't see where the C##3 comes from? Shouldn't the /b1 in the bass become C4 as first pitch? The chord occurs in biab-internet-corpus_1004.jams in the ChoCo dataset.

rubencart commented 7 months ago

Think this error might be related. In biab-internet-corpus_1015.jams. bb1 is supposed to mean two semitones down from the root, but the library seems to interpret 1 as an interval of 1 (semitones?) up from the root?

Harte('D#:(3,5,b7)/bb1')

Traceback (most recent call last):
  File "/cw/liir_code/NoCsBack/rubenc/miniconda3/envs/harmonyenv/lib/python3.12/site-packages/IPython/core/interactiveshell.py", line 3553, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-1-3f6292ada5aa>", line 1, in <module>
    Harte('D#:(3,5,b7)/bb1')
  File "/cw/liir_code/NoCsBack/rubenc/miniconda3/envs/harmonyenv/lib/python3.12/site-packages/harte/harte.py", line 95, in __init__
    HarteInterval(x, octave=4).transposeNote(m21_root)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/cw/liir_code/NoCsBack/rubenc/miniconda3/envs/harmonyenv/lib/python3.12/site-packages/harte/interval.py", line 34, in __init__
    super().__init__(self._converted_interval, **keywords)
  File "/cw/liir_code/NoCsBack/rubenc/miniconda3/envs/harmonyenv/lib/python3.12/site-packages/music21/interval.py", line 3054, in __init__
    diatonicNew, chromaticNew, inferred = _stringToDiatonicChromatic(name)
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/cw/liir_code/NoCsBack/rubenc/miniconda3/envs/harmonyenv/lib/python3.12/site-packages/music21/interval.py", line 2597, in _stringToDiatonicChromatic
    gInterval = GenericInterval(genericNumber)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/cw/liir_code/NoCsBack/rubenc/miniconda3/envs/harmonyenv/lib/python3.12/site-packages/music21/interval.py", line 892, in __init__
    self.value = convertGeneric(value)
    ^^^^^^^^^^
  File "/cw/liir_code/NoCsBack/rubenc/miniconda3/envs/harmonyenv/lib/python3.12/site-packages/music21/interval.py", line 945, in value
    raise IntervalException('The Zeroth is not an interval')
music21.interval.IntervalException: The Zeroth is not an interval
andreamust commented 7 months ago

This unexpected behaviour was caused by a bug in the convert_interval function, that was solved in 858d28350fd7676d40a894fc050fb5d6c9fd6930. Furthermore, for preventing this type of bugs in the future, pytests for intervals were implemented in 33ec15949dce8d8bfc0c1fb4a51edb7e88f1c6fc.

Finally, the latter error was fixed in d3f771b7164e09c945315716587a854b8610eefc.

All these fixes will be pushed in the next release of the library (0.4.5).

andreamust commented 7 months ago

Published in https://github.com/andreamust/harte-library/releases/tag/v0.4.5

rubencart commented 7 months ago

Nice thanks!