scamp.note_properties.NoteProperties

class scamp.note_properties.NoteProperties(**kwargs)[source]

Bases: collections.UserDict, expenvelope.json_serializer.SavesToJSON, scamp.utilities.NoteProperty

A dictionary-style class that stores a variety of playback and notation options affecting a single note.

Parameters

kwargs – key value pairs that make up this dictionary. Recognized dictionary keys are “articulation(s)”, “notehead(s)”, “notation(s)”, “text(s)”, “playback_adjustment(s)”, “key”/”spelling_policy”, “voice”, and “param_*” (for specifying arbitrary extra parameters).

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

ends_tie()

Whether or not this note ends a tie.

from_list(properties_list)

Interprets a lists of properties as a NoteProperties.

from_string(properties_string)

Interprets an appropriately formatted string as a NoteProperties.

from_unknown_format(properties)

Interprets a number of data formats as a NoteProperties

incorporate(other_dict)

Incorporates a different NoteProperties or dictionary into this one.

iterate_extra_parameters_and_values()

Iterates through additional parameters and their values.

mergeable_with(other_properties_dict)

Determines whether this NoteProperties is compatible with another for chord merger purposes.

starts_tie()

Whether or not this note starts a tie.

Inherited Methods

clear()

copy()

duplicate()

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

fromkeys(iterable[, value])

get(k[,d])

items()

json_dumps()

Dump this object as a JSON string.

json_loads(s)

Load this object from a JSON string.

keys()

load_from_json(file_path)

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

pop(k[,d])

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem()

as a 2-tuple; but raise KeyError if D is empty.

save_to_json(file_path)

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

setdefault(k[,d])

update([E, ]**F)

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values()

Attributes

articulations

List of articulations associated with this NoteProperties.

notations

List of notations associated with this NoteProperties.

noteheads

List of noteheads associated with this NoteProperties.

playback_adjustments

List of playback adjustments associated with this NoteProperties.

spelling_policy

Spelling policy associated with this NoteProperties.

temp

Temporary properties; these are not saved to JSON when this is exported.

texts

List of texts associated with this NoteProperties.

voice

Voice this note should appear in.

classmethod from_unknown_format(properties)scamp.note_properties.NoteProperties[source]

Interprets a number of data formats as a NoteProperties

Parameters

properties

Can be of several formats:

Returns

a newly constructed NoteProperties dictionary

classmethod from_string(properties_string)scamp.note_properties.NoteProperties[source]

Interprets an appropriately formatted string as a NoteProperties.

Parameters

properties_string – Should be formatted something like this: “articulations: staccato/tenuto, harmonic, #, volume * 0.7”. The comma separates different properties, and the forward slash separates multiple entries for the same property (with the exception of with the text property, since a slash could be part of the text). Properties can either be given with explicit key/value pairs (separated by colon), or a value can simply be given and the type of property will be inferred. In the above example, it is inferred that “harmonic” is a notehead, that the “#” is a desired spelling, and that “volume * 0.7” is a string to be parsed as a NotePlaybackAdjustment using its from_string() method.

classmethod from_list(properties_list: Sequence)scamp.note_properties.NoteProperties[source]

Interprets a lists of properties as a NoteProperties.

Parameters

properties_list

A list of properties, each of which is one of:

  • a :class:~scamp.playback_adjustments.NotePlaybackAdjustment`, SpellingPolicy, or

    scamp.text.StaffText

  • a string featuring a key/value pair separated by a colon.

    See play_note() for a description of the possible properties.

  • a string featuring just a value, from which the key is inferred. (E.g. “staccato”, which is interpreted

    as “articulation: staccato”)

property articulations

List of articulations associated with this NoteProperties.

property noteheads

List of noteheads associated with this NoteProperties.

property notations

List of notations associated with this NoteProperties.

property texts

List of texts associated with this NoteProperties.

property playback_adjustments

List of playback adjustments associated with this NoteProperties.

property spelling_policy

Spelling policy associated with this NoteProperties.

property voice

Voice this note should appear in.

iterate_extra_parameters_and_values() → Iterator[Tuple[str, Union[numbers.Real, expenvelope.envelope.Envelope]]][source]

Iterates through additional parameters and their values.

starts_tie() → bool[source]

Whether or not this note starts a tie.

ends_tie() → bool[source]

Whether or not this note ends a tie.

property temp

Temporary properties; these are not saved to JSON when this is exported.

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

clear() → None. Remove all items from D.
copy()
duplicate() → T

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

classmethod fromkeys(iterable, value=None)
get(k[, d]) → D[k] if k in D, else d. d defaults to None.
items() → a set-like object providing a view on D’s items
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

keys() → a set-like object providing a view on D’s keys
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

mergeable_with(other_properties_dict: scamp.note_properties.NoteProperties) → bool[source]

Determines whether this NoteProperties is compatible with another for chord merger purposes.

pop(k[, d]) → v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem() → (k, v), remove and return some (key, value) pair

as a 2-tuple; but raise KeyError if D is empty.

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

setdefault(k[, d]) → D.get(k,d), also set D[k]=d if k not in D
update([E, ]**F) → None. Update D from mapping/iterable E and F.

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values() → an object providing a view on D’s values
incorporate(other_dict: Optional[MutableMapping])scamp.note_properties.NoteProperties[source]

Incorporates a different NoteProperties or dictionary into this one.

Parameters

other_dict – A NoteProperties, or a dictionary-like object with similar structure

Returns

self, for chaining purposes