titus-ong / chordparser Goto Github PK
View Code? Open in Web Editor NEWA Python 3 package that provides a musical framework to analyse chords
License: MIT License
A Python 3 package that provides a musical framework to analyse chords
License: MIT License
Currently, the chord notation format (Chord.notation) is fixed, and some people may prefer other representations (e.g. C+7 instead of Caug7). Can consider creating a new format class that stores the desired format, and all the classes reference that class when building notation.
Search for special chords e.g. borrowed, secondary chords and list them
e.g. borrowed = [(IV, minor, (0, 0))]: a borrowed 4th chord from the parallel minor in line 0 and chord number 0.
Quality currently has the extension as just a string. Define it with a type (e.g. major, minor or diminished) based on the seventh, and create a method that can return the extension's number as an int.
A few of the attributes of the musical classes are objects that need parsing everytime they are accessed (e.g. quality attribute of a Chord). Create new classes for them so they can be easily understood.
EDIT: As description is vague, this issue is STRICTLY for the quality attribute of a Chord. Other classes should be put in a new issue.
Currently, ChordAnalyser only accepts scales for its input, which is inconsistent with ChordRomanConverter which can accept keys. Allow ChordAnalyser to accepts keys as well in its analysing methods.
Quite a lot of useful parsing of chords rely on understanding the base chord (e.g. diminished minor ninth as a diminished chord fundamentally). Create a base chord function in ChordEditor that accepts a chord, strips it of sus, add, ext, (possibly bass - might want to keep inversions), changes the quality to the base quality, and returns the base chord.
Create a secondary chord notation class that has repr as {chord1}/{chord2}, and has methods that can provide the two chords and the base scale. For current state, see ChordAnalyser's analyse_secondary function.
Currently, the roman notation covers the root, any inversions (up to 7th chords) and the chord quality. I am not sure if there are other aspects of Roman numeral notation that I have missed out regarding sus, added notes, or inversions for 9th/11th etc. chords. Need to research and include these in Roman class.
Some parts of the code has static typing, but the more Pythonic way would be to allow for duck typing. Refactoring the code will be needed to remove the static typed parts.
The quality and quality editor is currently abstracted into a helper class when creating a Chord. Do the same for added notes.
Lots of the classes use common dictionary lists to convert from symbols to integers, words to short form etc. Collate and put these in a helper class for all the classes to access centrally.
Create a separate class to create roman numerals from chords, and create chords from roman numerals + scale/key. This makes it easier to convert from chords to roman numerals and back by only storing the key the song is in.
Some methods are too impure as functions to be reusable (e.g. regex parsing in Chord class). Need to refactor code to make each method separate and clear in responsibility. Also look for opportunities to write new methods to avoid repeating code.
EDIT: To make this issue more specific, this issue will ONLY deal with the regex parsing of the Chord class.
Use the transpose function to transpose the chords in the working example.
Show example of converting chords to roman numerals and back (preferably do this after #1).
With readthedocs now, the documentation section of the notebook should be moved to /docs, leaving only the working example. With the changes in classes and methods in v0.3.x, the code has to be updated as well.
What a great library, thank you! I used it in a project for university and it helped me a lot :)
Something I noticed: in ChordRomanConverter, the scale is hardcoded to 'major', which resulted in some errors in my analysis. I changed it as follows:
from this:
if isinstance(scale_key, Scale):
scale_root = scale_key.key.root
else:
scale_root = scale_key.root
scale = self._SE.create_scale(scale_root, "major")
to this:
if isinstance(scale_key, Scale):
scale_root = scale_key.key.root
scale = self._SE.create_scale(scale_root, scale_key.key.mode)
else:
scale_root = scale_key.root
scale = self._SE.create_scale(scale_root, scale_key.mode)
Happy to hear your thoughts!
Add method to convert from roman notation to a Chord in the ChordRomanConverter class.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.