Giter VIP home page Giter VIP logo

harte-library's Introduction

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.

harte-library's People

Contributors

andreamust avatar n28div avatar xavriley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

n28div xavriley

harte-library's Issues

some chords from ChoCo not recognized

see PR #5 (related to Issue #3) for automated test on chord coverage.
Some chords are wrong annotations from ChoCo itself though.

Further issues will be opened and linked to this one for each fix type.

`hdim` chord not recognized

Should be probably be treated the same as hdim7 is.
Further details need to be checked to confirm.

related to Issue #6

`Harte('Bb:(4,#5,b7)')` contains `F-` instead of `F#`

Contains F- while it should contain F#. Also it would be nice if quality returned augmented (or suspended, but this appears never to be returned by music21.chord.Chord anyway).

c = Harte('Bb:(4,#5,b7)')
c.quality
Out[6]: 'other'
c.pitches
Out[7]: 
(<music21.pitch.Pitch B-4>,
 <music21.pitch.Pitch E-5>,
 <music21.pitch.Pitch F-5>,
 <music21.pitch.Pitch A-5>)

Refactor constructor

As for now, the Harte constructor takes a harte chord as input. This hinders the possibility of using the library in a different way which is not for parsing harte chord.
For example, this limits the possibility of instantiating a chord from music21.chord and port it to harte.

Cleanup harte parser

A cleanup of the harte parser utility is needed in order to get rid of the unused code.

shorthand `6` not available

Shorthand 6 has not been implemented, but usage has been found in some annotations.
Further details on which should be its intervals are required (is it the same as maj6? or a shorthand for 7(6)?)

Realted to Issue #6

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

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.

Half-diminished 7th chords

c = Harte('C:hdim7')

Gives

(<music21.pitch.Pitch C4>,
 <music21.pitch.Pitch E-4>,
 <music21.pitch.Pitch G#4>,
 <music21.pitch.Pitch B-4>)

Unless I'm mistaken, it should give

(<music21.pitch.Pitch C4>,
 <music21.pitch.Pitch E-4>,
 <music21.pitch.Pitch G-4>,
 <music21.pitch.Pitch B-4>)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.