scamp.playback_adjustments.PlaybackAdjustmentsDictionary

class scamp.playback_adjustments.PlaybackAdjustmentsDictionary(articulations: dict = None, noteheads: dict = None, notations: dict = None)[source]

Bases: collections.UserDict, expenvelope.json_serializer.SavesToJSON

Dictionary containing playback adjustments for different articulations, noteheads, and other notations. The instance of this at playback_settings.adjustments is consulted during playback. Essentially, this is just a dictionary with some validation and a couple of convenience methods to set and get adjustments for different properties.

Parameters
  • articulations – dictionary mapping articulation names to playback adjustments. For example, to have staccato notes be played at half length: {“staccato”: NotePlaybackAdjustment.scale_params(length=0.5)}

  • noteheads – dictionary mapping notehead names to playback adjustments. For example, to have harmonic noteheads be played up an octave: {“harmonic”: NotePlaybackAdjustment.add_to_params(pitch=12)}

  • notations – dictionary mapping notation names to playback adjustments.

Methods

get(notation_detail)

Get the NotePlaybackAdjustment for the given notation detail.

set(notation_detail, adjustment)

Set the given notation detail to have the given NotePlaybackAdjustment.

Inherited Methods

clear()

copy()

duplicate()

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

fromkeys(iterable[, value])

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

all_articulations

list of all recognized articulations

all_notations

list of all recognized notations

all_noteheads

list of all recognized noteheads

articulations

Dictionary mapping articulation names to corresponding playback adjustments

notations

Dictionary mapping notation names to corresponding playback adjustments

noteheads

Dictionary mapping notehead names to corresponding playback adjustments

all_articulations = ['staccato', 'staccatissimo', 'marcato', 'tenuto', 'accent']

list of all recognized articulations

all_noteheads = ['normal', 'diamond', 'harmonic', 'harmonic black', 'harmonic mixed', 'triangle', 'slash', 'cross', 'x', 'circle-x', 'xcircle', 'inverted triangle', 'square', 'arrow down', 'arrow up', 'circled', 'slashed', 'back slashed', 'cluster', 'circle dot', 'left triangle', 'rectangle', 'do', 're', 'mi', 'fa', 'fa up', 'so', 'la', 'ti', 'none', 'filled normal', 'filled diamond', 'filled harmonic', 'filled harmonic black', 'filled harmonic mixed', 'filled triangle', 'filled slash', 'filled cross', 'filled x', 'filled circle-x', 'filled xcircle', 'filled inverted triangle', 'filled square', 'filled arrow down', 'filled arrow up', 'filled circled', 'filled slashed', 'filled back slashed', 'filled cluster', 'filled circle dot', 'filled left triangle', 'filled rectangle', 'filled do', 'filled re', 'filled mi', 'filled fa', 'filled fa up', 'filled so', 'filled la', 'filled ti', 'filled none', 'open normal', 'open diamond', 'open harmonic', 'open harmonic black', 'open harmonic mixed', 'open triangle', 'open slash', 'open cross', 'open x', 'open circle-x', 'open xcircle', 'open inverted triangle', 'open square', 'open arrow down', 'open arrow up', 'open circled', 'open slashed', 'open back slashed', 'open cluster', 'open circle dot', 'open left triangle', 'open rectangle', 'open do', 'open re', 'open mi', 'open fa', 'open fa up', 'open so', 'open la', 'open ti', 'open none']

list of all recognized noteheads

all_notations = ['tremolo1', 'tremolo2', 'tremolo3', 'tremolo4', 'tremolo5', 'tremolo8', 'tremolo16', 'tremolo32', 'tremolo64', 'tremolo128']

list of all recognized notations

property articulations

Dictionary mapping articulation names to corresponding playback adjustments

property noteheads

Dictionary mapping notehead names to corresponding playback adjustments

property notations

Dictionary mapping notation names to corresponding playback adjustments

set(notation_detail: str, adjustment: Union[str, scamp.playback_adjustments.NotePlaybackAdjustment]) → None[source]

Set the given notation detail to have the given NotePlaybackAdjustment. Based on the name of the notation detail, it is automatically determined whether or not we are talking about an articulation, a notehead, or another kind of notation.

Parameters
  • notation_detail – name of the notation detail, e.g. “staccato” or “harmonic”

  • adjustment – the adjustment to make for that notation. Either a NotePlaybackAdjustment or a string to be parsed to a NotePlaybackAdjustment using NotePlaybackAdjustment.from_string

get(notation_detail: str)scamp.playback_adjustments.NotePlaybackAdjustment[source]

Get the NotePlaybackAdjustment for the given notation detail. Based on the name of the notation detail, it is automatically determined whether or not we are talking about an articulation, a notehead, or another kind of notation.

Parameters

notation_detail – name of the notation detail, e.g. “staccato” or “harmonic”

Returns

the NotePlaybackAdjustment for that detail

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)
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

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