scamp.note_properties.NoteProperties
- class scamp.note_properties.NoteProperties(*args, **kwargs)[source]
Bases:
SimpleNamespace,SavesToJSON,NotePropertyClass 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.
The value each extra playback parameter starts out at, taking the start level of any parameter given as an envelope.
Those extra playback parameters that name a MIDI control change, i.e. whose key is a number from 0 to 127, keyed by that number.
get_midi_cc_start_values([digits_to_round_to])The value each MIDI control change parameter starts out at, taking the start level of any parameter given as an envelope.
get_spelling_policy([which_note])The spelling policy to use for one of the notes of a chord, falling back to the last one given if fewer policies were specified than there are notes.
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 = ({'chord_merger_critical': True, 'default': [], 'key': 'articulations', 'merger_function': <function NoteProperties.<lambda>>, 'regex': '^articulations?$', 'regularization_function': None}, {'chord_merger_critical': True, 'default': [], 'key': 'notations', 'merger_function': <function NoteProperties.<lambda>>, 'regex': '^notations?$', 'regularization_function': None}, {'chord_merger_critical': True, 'custom_type': <class 'scamp.spanners.Spanner'>, 'default': [], 'key': 'spanners', 'merger_function': <function NoteProperties.<lambda>>, 'regex': '^spanners?$', 'regularization_function': None}, {'chord_merger_critical': False, 'default': ['normal'], 'is_default_function': <function NoteProperties.<lambda>>, 'key': 'noteheads', 'merger_function': <function NoteProperties.<lambda>>, 'regex': '^noteheads?$', 'regularization_function': None}, {'chord_merger_critical': True, 'default': [], 'key': 'dynamics', 'merger_function': <function NoteProperties.<lambda>>, 'regex': '^dynamics?$', 'regularization_function': None}, {'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>>}, {'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>>}, {'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>>}, {'chord_merger_critical': True, 'default': None, 'key': 'voice', 'merger_function': <function NoteProperties.<lambda>>, 'regex': '^voice$', 'regularization_function': None}, {'chord_merger_critical': True, 'default': 0, 'key': 'octave_displacement', 'merger_function': <function NoteProperties.<lambda>>, 'regex': '^octave_displacement$', 'regularization_function': None}, {'chord_merger_critical': True, 'default': {}, 'key': 'extra_playback_parameters', 'merger_function': <function NoteProperties.<lambda>>, 'regex': '^extra_playback_parameters$', 'regularization_function': None}, {'chord_merger_critical': True, 'default': False, 'key': 'starts_tie', 'merger_function': <function NoteProperties.<lambda>>, 'regex': '^starts_tie$', 'regularization_function': None}, {'chord_merger_critical': True, 'default': False, 'key': 'ends_tie', 'merger_function': <function NoteProperties.<lambda>>, 'regex': '^ends_tie$', 'regularization_function': None}, {'chord_merger_critical': True, 'default': False, 'key': 'manual_split_point', 'merger_function': <function NoteProperties.<lambda>>, 'regex': '^manual_split_point$', 'regularization_function': None})
- 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}, 'octave_displacement': {'chord_merger_critical': True, 'default': 0, 'key': 'octave_displacement', 'merger_function': <function NoteProperties.<lambda>>, 'regex': '^octave_displacement$', '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
NotePropertiesobject, 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 aNotePropertiesis passed in, the function will simply return the exact same object (not a duplicate)
- incorporate(other_properties: SimpleNamespace | MutableMapping | None) 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
- get_spelling_policy(which_note=0)[source]
The spelling policy to use for one of the notes of a chord, falling back to the last one given if fewer policies were specified than there are notes.
- Parameters:
which_note – index of the note within the chord
- get_midi_cc_params()[source]
Those extra playback parameters that name a MIDI control change, i.e. whose key is a number from 0 to 127, keyed by that number. (Values may be numbers or
Envelopes.)
- get_midi_cc_start_values(digits_to_round_to=10)[source]
The value each MIDI control change parameter starts out at, taking the start level of any parameter given as an envelope.
- Parameters:
digits_to_round_to – how many decimal places to round the values to
- get_extra_parameter_start_values()[source]
The value each extra playback parameter starts out at, taking the start level of any parameter given as an envelope.
- 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