antscloud / fretboardgtr

Python package for creating fretboard and chord diagram image in svg format
GNU Affero General Public License v3.0
112 stars 17 forks source link

Allow fingering with multiple notes per string #19

Open EricDuminil opened 1 year ago

EricDuminil commented 1 year ago

As mentioned in the README's todo-list:

fingering on scale like this fingering = [[5,8],[5,7],[5,7],[5,7],[5,8],[5,8]] to draw pentatonic for example.

Here's an example code:

from fretboardgtr import ChordGtr

first_position = [[5, 8], [5, 7], [5, 7], [5, 7], [5, 8], [5, 8]]

F = ChordGtr(fingering=first_position, root="A")
F.pathname('output/a_minor_pentatonic_first_position.png')
F.draw()
F.save()

And the desired output: a_minor_pentatonic_first_position

The current master fails with TypeError: '>' not supported between instances of 'list' and 'int'.

Just as an example, this feature has been implemented in https://github.com/EricDuminil/fretboardgtr/tree/experimental/multiple_fingering

It's just a proof-of-concept, and not yet an official Pull Request.

Once you're done with the refactoring branch, and if you're interested, I'd be happy to integrate https://github.com/EricDuminil/fretboardgtr/blob/experimental/multiple_fingering/fretboardgtr/fingering.py

antscloud commented 1 year ago

It will be a great feature to add :+1: , thank you a lot for the effort and the time spent !

We maybe need to add another function name to this feature as the fingering also handle the "no" or "mute" string (the X in the diagram). Also if we want in the future to add the barre chords with a new element like for example a rounded rectangle the function may do too much things. What do you think ?

The refactoring is mostly done. There may still be small changes because there is some duplication of code that I couldn't remove (I may have use a wrong abstraction) between the vertical and horizontal fretboard.

EricDuminil commented 1 year ago

Thanks for the feedback. Yes, muting strings already work (e.g. first_position = [None, [5, 7], [5, 7], [5, 7], [5, 8], [5, 8]]), but the naming could probably be improved.

I have no idea how the API could look like for barres. Possibly define the fingering in multiple steps?

I'll first look at the new structure from refactoring branch, and try to integrate multiple notes per string.

antscloud commented 1 year ago

It now can be done with the following example

from fretboardgtr.fretboard import FretBoard

A_MINOR_SCALE_POSITION = [[None], [5, 7], [5, 7], [5, 7], [5, 8], [5, 8]]
fretboard = FretBoard()
fretboard.add_scale(A_MINOR_SCALE_POSITION, root="A")
fretboard.export("my_fretboard.svg", format="svg")

However, I have no idea how to implement the barres as we have to define a new shape like a rectangle with rounded edges. It could be complex