KeySignature Class
The muspy.KeySignature
class is a container for key signatures.
Attributes |
Description |
Type |
Default |
---|---|---|---|
time |
Start time |
int |
|
root |
Root note as a number |
int |
|
mode |
Mode (e.g., “major”) |
str |
|
root_str |
Root note as a string |
int |
- class muspy.KeySignature(time, root=None, mode=None, fifths=None, root_str=None)[source]
A container for key signatures.
- time
Start time of the key signature, in time steps.
- Type
- root
Root (tonic) of the key signature.
- Type
int, optional
- mode
Mode of the key signature.
- Type
str, optional
- fifths
Number of sharps or flats. Positive numbers for sharps and negative numbers for flats.
- Type
int, optional
- root_str
Root of the key signature as a string.
- Type
str, optional
Note
A key signature can be specified either by its root (root) or the number of sharps or flats (fifths) along with its mode.
- adjust_time(func, attr=None, recursive=True)
Adjust the timing of time-stamped objects.
- Parameters
- Returns
- Return type
Object itself.
- copy()
Return a shallow copy of the object.
This is equivalent to
copy.copy(self)()
.- Returns
- Return type
Shallow copy of the object.
- deepcopy()
Return a deep copy of the object.
This is equivalent to
copy.deepcopy(self)()
- Returns
- Return type
Deep copy of the object.
- fix_type(attr=None, recursive=True)
Fix the types of attributes.
- 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
- Returns
- 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
- Returns
Whether the attribute has a valid type and value.
- Return type
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
- Returns
Whether the attribute is of a valid type.
- Return type
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
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
- 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
- Returns
- 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
- Returns
- 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.