Skip to main content

The Harte Library

Maintenance GitHub release PyPi version PyPI license

The Harte Library is an extension of the music21 library tailored for working with music chords encoded according to the Harte Notation.

This project is a component of ChoCo, a comprehensive dataset containing over 20,000 timed chord annotations sourced from integrated and standardized scores and tracks.

The library has the following dependencies:

  • music21: the base library the harte-library extends;
  • Lark: for parsing the chords in Harte.

🛠️ Installation

The library is available on PyPi. To install, simply execute the following command:

pip install harte-library --upgrade

🔑 Key Features

The Harte Library offers several core functionalities:

  • Interoperability: Seamlessly integrate musical chords notated in Harte Notation with the music21 library.
  • Interpretability: Easily interpret chords notated in Harte format, including the unrolling of shorthand representations.
  • Simplification: Streamline and standardize chords in Harte notation using the prettify_harte functionality.

🚀 Usage

🎵 Interval Module

The Harte Library extends the Interval Module of music21 to ensure interoperability between intervals expressed according to Harte notation and the interval class of music21.

The HarteInterval class accepts an interval expressed in Harte Notation as input and allows all the properties and methods of the music21 Interval module to be used:

from harte.interval import HarteInterval

interval = HarteInterval('b6')

int_name = interval.name
int_is_consonant = interval.isConsonant()

🎸 Chord Module

The primary functionality of the Harte Library extends the Chord Module of music21.

This is achieved through the Harte class, which accepts a chord expressed in Harte Notation as input, enabling the utilization of all properties and methods available in the Chord module of music21:

from harte.harte import Harte

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

bass = chord.bass()  # E
root = chord.root()  # C#
name = chord.fullName  # Chord {C-sharp in octave 4 | E in octave 3 | E-sharp in octave 4 | G-sharp in octave 4 | A in octave 4 | B-sharp in octave 4} Quarter

Additionally, the library introduces new methods tailored specifically for Harte notation, including:

  • get_degrees(): Retrieves the intervals of the chord, excluding those represented by shorthand.
  • get_midi_pitches(): Obtains the MIDI pitches of the chord as an ordered list.
  • get_root(): Retrieves the root of the chord as a string.
  • get_bass(): Calculates the interval between the root note and the bass note.
  • contains_shorthand(): Determines whether the chord contains a shorthand representation, returning True if present, False otherwise.
  • get_shorthand(): Retrieves the shorthand representation of the chord, if available.
  • unwrap_shorthand(): Unwraps the shorthand notation, returning a list containing all intervals in the chord, including those represented by shorthand.
  • prettify(): Decomposes the chord into its constituent components and recomposes it by selecting the most concise shorthand representation, if applicable.
from harte.harte import Harte

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

pretty_harte = chord.prettify()  # D:minmaj7(9)

🤝 Contributing

We welcome contributions from the community to enhance the Harte Library. Whether you want to report a bug, suggest a new feature, or contribute code, your help is greatly appreciated!

🐞 Reporting Issues

If you encounter any bugs, have feature requests, or have suggestions for improvements, please open an issue with detailed information about the problem or suggestion.

License

MIT License

Copyright (c) 2022 Andrea Poltronieri

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Metadata

Release files for harte-library 0.4.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for harte-library 0.4.5
File Size Uploaded
harte_library-0.4.5.tar.gz 13.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for harte-library 0.4.5
File Interpreter ABI Platform
harte_library-0.4.5-py3-none-any.whl Python 3 none any Details

Total release size: 27.3 kB

Release files / harte_library-0.4.5.tar.gz

Download URL harte_library-0.4.5.tar.gz
Size 13.5 kB
Tags Source
SHA-256 checksum
How to use checksums
0ba0d5fe485e5d2cde50ac28d8c6139cf4eec44bd793862f27d5630e8a241faa
BLAKE2b-256 checksum
How to use checksums
25ae2c48ef2330bf5fda1dfa8787d67bf2b64f6fe3c0826c4e8fa168a7635518
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.19

Release files / harte_library-0.4.5-py3-none-any.whl

Download URL harte_library-0.4.5-py3-none-any.whl
Size 13.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
880f8db3ee130cdd511bb9eb6fa87eb04454556b30ca3e6bf602388ca7c60548
BLAKE2b-256 checksum
How to use checksums
2821a04b71d8fecb12f5e25ec2fd08a83c36a542ef6d1e51e9179bf4a8c92dac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.19

Release history Release notifications | RSS feed

This release

0.4.5 This release

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.1

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page