Fretboard#

class fretboardgtr.fretboard.FretBoard[source]#

Bases: FretBoardLike

__init__(tuning=None, config=None, vertical=False)[source]#
Parameters:
  • tuning (List[str] | None) –

  • config (Dict | FretBoardConfig | None) –

  • vertical (bool) –

add_background()[source]#

Build and add background element.

Return type:

None

add_element(element)[source]#

Add an element to the fretboard.

Need to be either a FretBoardElement

Parameters:

element (FretBoardElement) – Fretboard element

Raises:

ValueError – If the element is not a FretboardElement

Return type:

None

add_fingering(fingering, root=None)[source]#

Add fingering starting with upper string to lower string.

Parameters:
  • fingering (List[Optional[int]]) – List of finger positions for each string.

  • root (Optional[str], optional) – The root note to use for calculating note names or intervals, by default None.

Raises:

ValueError – If the size of the fingering list is not the same as the size of the tuning list.

Return type:

None

add_fret_numbers()[source]#

Build and add fret number elements.

Return type:

None

add_frets()[source]#

Build and add fret elements.

Return type:

None

add_neck_dots()[source]#

Build and add neck dot elements.

Return type:

None

add_note(string_no, note, root=None)[source]#

Build and add notes element.

Parameters:
  • string_no (int) –

  • note (str) –

  • root (str | None) –

Return type:

None

add_note_element(note)[source]#

Add a note element to the fretboard.

Need to be either a OpenNote or a FrettedNote

Parameters:

note (Union[OpenNote, FrettedNote]) – Note element

Raises:

ValueError – If the note is not a Union[OpenNote, FrettedNote]

Return type:

None

add_notes(scale)[source]#

Add an entire scale (from NoteContainer object) to the fretboard.

Parameters:

scale (NotesContainer) – Object representing the root and the associated scale

Return type:

None

add_nut()[source]#

Build and add nut element.

Return type:

None

add_scale(scale, root=None, repeat_over_fretboard=False)[source]#

Add scale to the fretboard.

Parameters:
  • scale (List[List[Optional[int]]]) – The scale to be added.

  • root (Optional[str], optional) – The root note of the scale, by default None.

  • repeat_over_fretboard (bool, optional) – Whether to repeat the scale over the entire fretboard, by default False.

Raises:

ValueError – If the scale has a different size than the tuning.

Return type:

None

add_single_note_from_index(string_no, index, root=None)[source]#

Build and add background element.

Parameters:
  • string_no (int) –

  • index (int) –

  • root (str | None) –

Return type:

None

add_strings()[source]#

Build and add string elements.

Return type:

None

add_tuning()[source]#

Build and add tuning element.

Return type:

None

export(to, format='svg')[source]#

Export the fretboard to the desired path.

Export availables are :

svg png pdf

Custom exporters can be created by : Subclassing : func:~fretboardgtr.exporters.Exporter Regitering it with func:~fretboardgtr.exporters.register_exporter

Parameters:
  • to (Union[Path, str]) – Path to export to

  • format (Literal["svg", "png", "pdf"], optional) – Format to export in, by default “svg”

Raises:

NotImplementedError – If the desired format is not implemented

Return type:

None

get_elements()[source]#
Return type:

FretBoardElements

get_inside_bounds()[source]#

Get the size of the inner drawing.

This function could be use to add custom elements

Returns:

Upper left corner x coordinate, upper left corner y coordinate Lower right corner x coordinate, lower right corner y coordinate

Return type:

Tuple[Tuple[float, float], Tuple[float, float]]

get_size()[source]#

Get total size of the drawing.

Returns:

Width and heigth

Return type:

Tuple[float, float]

init()[source]#

Init the fretboard by adding essential elements.

This adds :

background fret_numbers neck_dots frets nut tuning strings

Return type:

None

set_config(config)[source]#
Parameters:

config (FretBoardConfig) –

Return type:

None

fretboardgtr.fretboard.build_config(config)[source]#
Parameters:

config (Dict | FretBoardConfig | None) –

Return type:

FretBoardConfig