Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ThatChord into an actual package and make it object-oriented #23

Open
9 tasks
tomcontileslie opened this issue Jun 4, 2021 · 0 comments
Open
9 tasks

Comments

@tomcontileslie
Copy link
Owner

tomcontileslie commented Jun 4, 2021

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant