scamp.note_properties.NoteProperties
- class scamp.note_properties.NoteProperties(*args, **kwargs)[source]
Bases:
SimpleNamespace
,SavesToJSON
,NoteProperty
Class that holds information about any and all playback or notational details for a note or chord aside from its pitch, volume and duration. See The Note Properties Argument for more information.
- Parameters:
args – Any number of things that are interpretable as note properties via
NoteProperties.interpret()
, which are merged together into a single object.kwargs – individual note properties can be given as keyword arguments, e.g. articulation=staccato
Methods
apply_playback_adjustments
(pitch, volume, length)Applies both explicit and (if flag is set) derived playback_adjustments to the given pitch, volume, and length
chord_mergeable_with
(other_properties)Determines whether this NoteProperties is compatible with another for chord merger purposes.
get_midi_cc_start_values
([digits_to_round_to])get_spelling_policy
([which_note])incorporate
(other_properties)Incorporates a different NoteProperties or dictionary into this one.
interpret
(properties_object)Interprets a properties_object of unknown type into a
NoteProperties
.Inherited Methods
Returns a copy of this object by serializing to and from JSON.
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
- PROPERTY_TYPES = ({'key': 'articulations', 'regex': '^articulations?$', 'default': [], 'regularization_function': None, 'merger_function': <function NoteProperties.<lambda>>, 'chord_merger_critical': True}, {'key': 'notations', 'regex': '^notations?$', 'default': [], 'regularization_function': None, 'merger_function': <function NoteProperties.<lambda>>, 'chord_merger_critical': True}, {'key': 'spanners', 'regex': '^spanners?$', 'default': [], 'regularization_function': None, 'custom_type': <class 'scamp.spanners.Spanner'>, 'merger_function': <function NoteProperties.<lambda>>, 'chord_merger_critical': True}, {'key': 'noteheads', 'regex': '^noteheads?$', 'default': ['normal'], 'is_default_function': <function NoteProperties.<lambda>>, 'regularization_function': None, 'merger_function': <function NoteProperties.<lambda>>, 'chord_merger_critical': False}, {'key': 'dynamics', 'regex': '^dynamics?$', 'default': [], 'regularization_function': None, 'merger_function': <function NoteProperties.<lambda>>, 'chord_merger_critical': True}, {'key': 'texts', 'regex': '^texts?$', 'default': [], 'regularization_function': <function NoteProperties.<lambda>>, 'custom_type': <class 'scamp.text.StaffText'>, 'merger_function': <function NoteProperties.<lambda>>, 'chord_merger_critical': True}, {'key': 'playback_adjustments', 'regex': '^(playback_)?adjustments?$', 'default': [], 'regularization_function': <function NoteProperties.<lambda>>, 'custom_type': <class 'scamp.playback_adjustments.NotePlaybackAdjustment'>, 'merger_function': <function NoteProperties.<lambda>>, 'chord_merger_critical': True}, {'key': 'spelling_policies', 'regex': '^(spelling|spelling_policy|spelling_policies|key)$', 'default': [], 'is_default_function': <function NoteProperties.<lambda>>, 'regularization_function': <function NoteProperties.<lambda>>, 'custom_type': <class 'scamp.spelling.SpellingPolicy'>, 'merger_function': <function NoteProperties.<lambda>>, 'chord_merger_critical': False}, {'key': 'voice', 'regex': '^voice$', 'default': None, 'regularization_function': None, 'merger_function': <function NoteProperties.<lambda>>, 'chord_merger_critical': True}, {'key': 'extra_playback_parameters', 'regex': '^extra_playback_parameters$', 'default': {}, 'regularization_function': None, 'merger_function': <function NoteProperties.<lambda>>, 'chord_merger_critical': True}, {'key': 'starts_tie', 'regex': '^starts_tie$', 'default': False, 'regularization_function': None, 'merger_function': <function NoteProperties.<lambda>>, 'chord_merger_critical': True}, {'key': 'ends_tie', 'regex': '^ends_tie$', 'default': False, 'regularization_function': None, 'merger_function': <function NoteProperties.<lambda>>, 'chord_merger_critical': True}, {'key': 'manual_split_point', 'regex': '^manual_split_point$', 'default': False, 'regularization_function': None, 'merger_function': <function NoteProperties.<lambda>>, 'chord_merger_critical': True})
- PROPERTY_TYPES_AS_DICT = {'articulations': {'chord_merger_critical': True, 'default': [], 'key': 'articulations', 'merger_function': <function NoteProperties.<lambda>>, 'regex': '^articulations?$', 'regularization_function': None}, 'dynamics': {'chord_merger_critical': True, 'default': [], 'key': 'dynamics', 'merger_function': <function NoteProperties.<lambda>>, 'regex': '^dynamics?$', 'regularization_function': None}, 'ends_tie': {'chord_merger_critical': True, 'default': False, 'key': 'ends_tie', 'merger_function': <function NoteProperties.<lambda>>, 'regex': '^ends_tie$', 'regularization_function': None}, 'extra_playback_parameters': {'chord_merger_critical': True, 'default': {}, 'key': 'extra_playback_parameters', 'merger_function': <function NoteProperties.<lambda>>, 'regex': '^extra_playback_parameters$', 'regularization_function': None}, 'manual_split_point': {'chord_merger_critical': True, 'default': False, 'key': 'manual_split_point', 'merger_function': <function NoteProperties.<lambda>>, 'regex': '^manual_split_point$', 'regularization_function': None}, 'notations': {'chord_merger_critical': True, 'default': [], 'key': 'notations', 'merger_function': <function NoteProperties.<lambda>>, 'regex': '^notations?$', 'regularization_function': None}, 'noteheads': {'chord_merger_critical': False, 'default': ['normal'], 'is_default_function': <function NoteProperties.<lambda>>, 'key': 'noteheads', 'merger_function': <function NoteProperties.<lambda>>, 'regex': '^noteheads?$', 'regularization_function': None}, 'playback_adjustments': {'chord_merger_critical': True, 'custom_type': <class 'scamp.playback_adjustments.NotePlaybackAdjustment'>, 'default': [], 'key': 'playback_adjustments', 'merger_function': <function NoteProperties.<lambda>>, 'regex': '^(playback_)?adjustments?$', 'regularization_function': <function NoteProperties.<lambda>>}, 'spanners': {'chord_merger_critical': True, 'custom_type': <class 'scamp.spanners.Spanner'>, 'default': [], 'key': 'spanners', 'merger_function': <function NoteProperties.<lambda>>, 'regex': '^spanners?$', 'regularization_function': None}, 'spelling_policies': {'chord_merger_critical': False, 'custom_type': <class 'scamp.spelling.SpellingPolicy'>, 'default': [], 'is_default_function': <function NoteProperties.<lambda>>, 'key': 'spelling_policies', 'merger_function': <function NoteProperties.<lambda>>, 'regex': '^(spelling|spelling_policy|spelling_policies|key)$', 'regularization_function': <function NoteProperties.<lambda>>}, 'starts_tie': {'chord_merger_critical': True, 'default': False, 'key': 'starts_tie', 'merger_function': <function NoteProperties.<lambda>>, 'regex': '^starts_tie$', 'regularization_function': None}, 'texts': {'chord_merger_critical': True, 'custom_type': <class 'scamp.text.StaffText'>, 'default': [], 'key': 'texts', 'merger_function': <function NoteProperties.<lambda>>, 'regex': '^texts?$', 'regularization_function': <function NoteProperties.<lambda>>}, 'voice': {'chord_merger_critical': True, 'default': None, 'key': 'voice', 'merger_function': <function NoteProperties.<lambda>>, 'regex': '^voice$', 'regularization_function': None}}
- classmethod interpret(properties_object) NoteProperties [source]
Interprets a properties_object of unknown type into a
NoteProperties
.- Parameters:
properties_object – a
NoteProperties
object, dict-like object, parseable properties string, custom NoteProperties object or list of any of the above that get merged together. See The Note Properties Argument for more info.- Returns:
a new
NoteProperties
. Note that if aNoteProperties
is passed in, the function will simply return the exact same object (not a duplicate)
- incorporate(other_properties: Optional[Union[SimpleNamespace, MutableMapping]]) NoteProperties [source]
Incorporates a different NoteProperties or dictionary into this one.
- Parameters:
other_properties – A NoteProperties, or a dictionary-like object with similar structure
- Returns:
self, for chaining purposes
- chord_mergeable_with(other_properties: NoteProperties) bool [source]
Determines whether this NoteProperties is compatible with another for chord merger purposes.
- Parameters:
other_properties – the NoteProperties object of another note
- Returns:
whether the note with this NoteProperties is compatible with the note with the other NoteProperties as far as combining them both into a chord is concerned.
- apply_playback_adjustments(pitch, volume, length, include_notation_derived=True)[source]
Applies both explicit and (if flag is set) derived playback_adjustments to the given pitch, volume, and length
- Parameters:
pitch – unadjusted pitch
volume – unadjusted volume
length – unadjusted length
include_notation_derived – if true, include adjustments based on notations like staccato, by searching the playback_settings.adjustments dictionary
- Returns:
adjusted pitch, volume, length, as well as a boolean stating whether anything changed
- 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