ThatChord
ThatChord copied to clipboard
Make ThatChord into an actual package and make it object-oriented
There are a number of improvements to the code which would make it more easily maintainable and executable.
- [ ] Swap out ungodly lists of function arguments for
**kwargs, since the parameters are very similar for most functions - [ ] Make a "chord" or "ThatChord" class that has an object instantiated at the beginning of a request, then keeps all important metadata (e.g. choice of settings) internal to the object
- [ ] Make the main subprocesses (INTERPRET -> FIND -> OUTPUT) into submodules e.g. ThatChord.interpret, ThatChord.find, ThatChord.view/ThatChord.save which take a chord object as argument and modify it in place
- [ ] Tuck .py files away in folders, leaving only main scripts like thatchord.py in the home directory
- [ ] Add ThatChord to PyPI
- [ ] Offer to import similar projects as extensions (e.g. fretboard on PyPI)
- [ ] Revamp settings system (edit settings from command line? make settings subclass?)
- [ ] Revamp errors (the current system is garbage)
- [ ] Standardise vocabulary between "request", "chord", "diagram", "fingering" etc
I think what I roughly have in mind is something that could do this:
>>> import thatchord as tc
>>> workspace = tc.new_workspace() # create environment with default settings
>>> # the workspace should contain all the info necessary to run the algorithms:
>>> workspace._INSTRUMENT_SETTINGS # view tuning settings
{'tuning': [0, 1, 2, 3], 'frets': 15, ...}
>>> workspace._RANKING_FUNCTION
<function rank at 0x...>
>>> workspace._OUTPUT_SETTINGS
{'format': 'png', 'height': 5, ...}
>>> ch = workspace.new_request("C/E")
>>> ch
<chord request: C major with notes C,E,G and bass note E>
>>> tc.find.find(ch, 3) # find 3 best chords
>>> # perhaps rather than outputting anything, the result is then stored in ch
>>> ch.solutions
[[0, 0, 0, 3], [5, 4, 3, 3], [0, 4, 0, 3]]
>>> tc.view.generate_drawing(ch, format="txt", index=2) # can overrule settings from workspace._OUTPUT_SETTINGS
' C\n\n =======\n | | | |\n | | | |\n | | | O\n | O | |\n | | | |'
>>> tc.view.print(ch) # or maybe ch.print()?
C
=======
| | | |
| | | |
| | | O
| O | |
| | | |
>>> tc.view.splash(ch) # or maybe ch.splash()?
>>> tc.view.save(ch, "/Users/me/outputs/beautiful.txt") # or maybe ch.save()?
>>> ###############
>>> workspace2 = tc.new_workspace(instrument_preset='guitar') # can set up different environments like this
>>> workspace3 = tc.new_worspace(tuning="D A D G B E", frets=22, handedness="left") # custom setups
>>> ch = workspace3.new_request("Em")
>>> # etc