scamp.spanners.Spanner

class scamp.spanners.Spanner(label: Any = 0, **formatting)[source]

Bases: ABC, SavesToJSON, NoteProperty

Base class for all spanner notations, i.e. notations that cover more than one note.

Parameters:
  • label – Each spanner can have a label that distinguishes it from other spanners of the same type. For example, consider the sequence of: start slur, start slur, stop slur, stop slur. Is this a small slur inside of a large one, or two interlocking slurs. The label clarifies. In practice, this is only really functional in musicXML export, where it is converted to a number.

  • formatting – Each spanner has various types of individually specific formatting, such as a trill accidental or bracket text. This is passed along in a dictionary, and largely follows formatting from the MusicXML standard.

Methods

get_abjad_direction()

to_abjad()

Converts this to an abjad indicator.

to_pymusicxml()

Converts this to a pymusicxml spanner type.

Inherited Methods

duplicate()

Returns a copy of this object by serializing to and from JSON.

json_dumps()

Dump this object as a JSON string.

json_loads(s)

Load this object from a JSON string.

load_from_json(file_path)

Load this object from a JSON file with the given path.

save_to_json(file_path)

Save this object to a JSON file using the given path.

Attributes

FORMATTING_SLOTS

START_MID_OR_STOP

START_MID_OR_STOP = NotImplemented
FORMATTING_SLOTS = NotImplemented
abstract to_pymusicxml()[source]

Converts this to a pymusicxml spanner type.

abstract to_abjad()[source]

Converts this to an abjad indicator.

get_abjad_direction()[source]
duplicate() T

Returns a copy of this object by serializing to and from JSON.

json_dumps() str

Dump this object as a JSON string. This uses a custom encoder that recognizes and appropriately converts any attributes that are object inheriting from SavesToJSON.

classmethod json_loads(s: str) T

Load this object from a JSON string. This uses a custom decoder that looks for a “_type” key in any object/dictionary being parsed and converts it to the class specified (assuming it a subclass of SavesToJSON).

Parameters:

s – a string representing this object in JSON format

classmethod load_from_json(file_path: str) T

Load this object from a JSON file with the given path. This uses a custom decoder that looks for a “_type” key in any object/dictionary being parsed and converts it to the class specified (assuming it a subclass of SavesToJSON).

Parameters:

file_path – path for loading the file

save_to_json(file_path: str) None

Save this object to a JSON file using the given path. This uses a custom encoder that recognizes and appropriately converts any attributes that are object inheriting from SavesToJSON.

Parameters:

file_path – path for saving the file