scamp.playback_adjustments.NotePlaybackAdjustment

class scamp.playback_adjustments.NotePlaybackAdjustment(pitch_adjustment: Optional[ParamPlaybackAdjustment] = None, volume_adjustment: Optional[ParamPlaybackAdjustment] = None, length_adjustment: Optional[ParamPlaybackAdjustment] = None, scale_envelopes_to_length=False)[source]

Bases: SavesToJSON, NoteProperty

Represents an adjustment to the pitch, volume and/or length of the playback of a single note

Parameters:
  • pitch_adjustment – The desired adjustment for the note’s pitch. (None indicates no adjustment)

  • volume_adjustment – The desired adjustment for the note’s volume. (None indicates no adjustment)

  • length_adjustment – The desired adjustment for the note’s length. (None indicates no adjustment)

Variables:
  • pitch_adjustment – The desired adjustment for the note’s pitch. (None indicates no adjustment)

  • volume_adjustment – The desired adjustment for the note’s volume. (None indicates no adjustment)

  • length_adjustment – The desired adjustment for the note’s length. (None indicates no adjustment)

Methods

add_to_params([pitch, volume, length])

Constructs a NotePlaybackAdjustment that adds to the parameters

adjust_parameters(pitch, volume, length)

Carry out the adjustments represented by this object on the pitch, volume and length given.

from_string(string)

Construct a NotePlaybackAdjustment from a string using a particular grammar.

scale_params([pitch, volume, length])

Constructs a NotePlaybackAdjustment that scales the parameters

set_params([pitch, volume, length])

Constructs a NotePlaybackAdjustment that directly resets the parameters

Inherited Methods

duplicate()

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

json_dumps()

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.

classmethod from_string(string: str) NotePlaybackAdjustment[source]

Construct a NotePlaybackAdjustment from a string using a particular grammar.

Parameters:

string – should take the form of, e.g. “volume * 0.5 pitch = 69 length * 2 - 1”. This would cause the volume to be halved, the pitch to be set to 69, and the length to be doubled plus 1. Note that “/” for division is not understood and that where a multiplication and an addition/subtraction are used together, the multiplication must come first. The parameters can be separated by commas or semicolons optionally, for visual clarity.

Returns:

a shiny new NotePlaybackAdjustment

classmethod scale_params(pitch=1, volume=1, length=1) NotePlaybackAdjustment[source]

Constructs a NotePlaybackAdjustment that scales the parameters

Parameters:
  • pitch – pitch scale factor

  • volume – volume scale factor

  • length – length scale factor

Returns:

a shiny new NotePlaybackAdjustment

classmethod add_to_params(pitch=None, volume=None, length=None) NotePlaybackAdjustment[source]

Constructs a NotePlaybackAdjustment that adds to the parameters

Parameters:
  • pitch – pitch addition

  • volume – volume addition

  • length – length addition

Returns:

a shiny new NotePlaybackAdjustment

classmethod set_params(pitch=None, volume=None, length=None) NotePlaybackAdjustment[source]

Constructs a NotePlaybackAdjustment that directly resets the parameters

Parameters:
  • pitch – new pitch setting

  • volume – new volume setting

  • length – new length setting

Returns:

a shiny new NotePlaybackAdjustment

adjust_parameters(pitch, volume, length)[source]

Carry out the adjustments represented by this object on the pitch, volume and length given.

Parameters:
  • pitch – pitch to adjust

  • volume – volume to adjust

  • length – length to adjust

Returns:

tuple of (adjusted_pitch, adjusted_volume, adjusted_length)

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