Chord Symbol

The muspy.ChordSymbol class is a container for chord markings (commonly found in jazz music).

Attributes

Description

Type

Default

root_str

Root pitch as a string

str

name

Chord type name

str

‘Maj’

text

Text

str

is_system

Whether it is system-level

bool

False

style

Style of the text (e.g. ‘tempo’)

str

class muspy.ChordSymbol(root_str, name='Maj', text=None, is_system=False, style=None)[source]

A container for chord symbols.

root_str

Root pitch as a string, useful for distinguishing, e.g., C# and Db.

Type:

str

name

The text contained in the chord symbol element.

Type:

str, default: ‘Maj’

text

The full text contained in the chord symbol.

Type:

str, optional

is_system

Is this text system-wide (True) or just for a specific staff (False)?

Type:

bool, default: False

style

The style of the text.

Type:

str, optional

adjust_time(func, attr=None, recursive=True)

Adjust the timing of time-stamped objects.

Parameters:
  • func (callable) – The function used to compute the new timing from the old timing, i.e., new_time = func(old_time).

  • attr (str, optional) – Attribute to adjust. Defaults to adjust all attributes.

  • recursive (bool, default: True) – Whether to apply recursively.

Return type:

Object itself.

copy()

Return a shallow copy of the object.

This is equivalent to copy.copy(self)().

Return type:

Shallow copy of the object.

deepcopy()

Return a deep copy of the object.

This is equivalent to copy.deepcopy(self)()

Return type:

Deep copy of the object.

fix_type(attr=None, recursive=True)

Fix the types of attributes.

Parameters:
  • attr (str, optional) – Attribute to adjust. Defaults to adjust all attributes.

  • recursive (bool, default: True) – Whether to apply recursively.

Return type:

Object itself.

classmethod from_dict(dict_, strict=False, cast=False)

Return an instance constructed from a dictionary.

Instantiate an object whose attributes and the corresponding values are given as a dictionary.

Parameters:
  • dict (dict or mapping) – A dictionary that stores the attributes and their values as key-value pairs, e.g., {“attr1”: value1, “attr2”: value2}.

  • strict (bool, default: False) – Whether to raise errors for invalid input types.

  • cast (bool, default: False) – Whether to cast types.

Return type:

Constructed object.

is_valid(attr=None, recursive=True)

Return True if an attribute has a valid type and value.

This will recursively apply to an attribute’s attributes.

Parameters:
  • attr (str, optional) – Attribute to validate. Defaults to validate all attributes.

  • recursive (bool, default: True) – Whether to apply recursively.

Returns:

Whether the attribute has a valid type and value.

Return type:

bool

See also

muspy.Base.validate()

Raise an error if an attribute has an invalid type or value.

muspy.Base.is_valid_type()

Return True if an attribute is of a valid type.

is_valid_type(attr=None, recursive=True)

Return True if an attribute is of a valid type.

This will apply recursively to an attribute’s attributes.

Parameters:
  • attr (str, optional) – Attribute to validate. Defaults to validate all attributes.

  • recursive (bool, default: True) – Whether to apply recursively.

Returns:

Whether the attribute is of a valid type.

Return type:

bool

See also

muspy.Base.validate_type()

Raise an error if a certain attribute is of an invalid type.

muspy.Base.is_valid()

Return True if an attribute has a valid type and value.

pretty_str(skip_missing=True)

Return the attributes as a string in a YAML-like format.

Parameters:

skip_missing (bool, default: True) – Whether to skip attributes with value None or those that are empty lists.

Returns:

Stored data as a string in a YAML-like format.

Return type:

str

See also

muspy.Base.print()

Print the attributes in a YAML-like format.

print(skip_missing=True)

Print the attributes in a YAML-like format.

Parameters:

skip_missing (bool, default: True) – Whether to skip attributes with value None or those that are empty lists.

See also

muspy.Base.pretty_str()

Return the the attributes as a string in a YAML-like format.

to_ordered_dict(skip_missing=True, deepcopy=True)

Return the object as an OrderedDict.

Return an ordered dictionary that stores the attributes and their values as key-value pairs.

Parameters:
  • skip_missing (bool, default: True) – Whether to skip attributes with value None or those that are empty lists.

  • deepcopy (bool, default: True) – Whether to make deep copies of the attributes.

Returns:

A dictionary that stores the attributes and their values as key-value pairs, e.g., {“attr1”: value1, “attr2”: value2}.

Return type:

OrderedDict

validate(attr=None, recursive=True)

Raise an error if an attribute has an invalid type or value.

This will apply recursively to an attribute’s attributes.

Parameters:
  • attr (str, optional) – Attribute to validate. Defaults to validate all attributes.

  • recursive (bool, default: True) – Whether to apply recursively.

Return type:

Object itself.

See also

muspy.Base.is_valid()

Return True if an attribute has a valid type and value.

muspy.Base.validate_type()

Raise an error if an attribute is of an invalid type.

validate_type(attr=None, recursive=True)

Raise an error if an attribute is of an invalid type.

This will apply recursively to an attribute’s attributes.

Parameters:
  • attr (str, optional) – Attribute to validate. Defaults to validate all attributes.

  • recursive (bool, default: True) – Whether to apply recursively.

Return type:

Object itself.

See also

muspy.Base.is_valid_type()

Return True if an attribute is of a valid type.

muspy.Base.validate()

Raise an error if an attribute has an invalid type or value.