scamp.playback_adjustments.ParamPlaybackAdjustment

class scamp.playback_adjustments.ParamPlaybackAdjustment(multiply: Union[Real, Envelope, Sequence] = 1, add: Union[Real, Envelope, Sequence] = 0)[source]

Bases: SavesToJSON

Represents a multiply/add playback adjustment to a single parameter. (The multiply happens first, then the add.)

Parameters:
  • multiply – how much to multiply by

  • add – how much to add

Variables:
  • multiply – how much to multiply by

  • add – how much to add

Methods

add(value)

Class method for a simple additive adjustment.

adjust_value(param_value[, ...])

Apply this adjustment to a given parameter value

from_string(string)

Construct a ParamPlaybackAdjustment from an appropriately formatted string.

scale(value)

Class method for a simple scaling adjustment.

set_to(value)

Class method for an adjustment that resets the value of the parameter, ignoring its original value

uses_envelope()

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) ParamPlaybackAdjustment[source]

Construct a ParamPlaybackAdjustment from an appropriately formatted string.

Parameters:

string – written using either “*”, “+”/”-”, both “*” and “+”/”-” or equals followed by numbers. For example, “* 0.5” multiplies by 0.5, “= 7” sets equal to 87, “* 1.1 - 3” multiplies by 1.1 and then subtracts 3. Note that “/” for division is not understood (instead multiply by the inverse), and that where a multiplication and an addition/subtraction are used together, the multiplication must come first.

Returns:

a ParamPlaybackAdjustment

classmethod set_to(value) ParamPlaybackAdjustment[source]

Class method for an adjustment that resets the value of the parameter, ignoring its original value

Parameters:

value – the value to set the parameter to

classmethod scale(value) ParamPlaybackAdjustment[source]

Class method for a simple scaling adjustment.

Parameters:

value – the factor to scale by

classmethod add(value) ParamPlaybackAdjustment[source]

Class method for a simple additive adjustment.

Parameters:

value – how much to add

adjust_value(param_value, normalize_envelope_to_length=None)[source]

Apply this adjustment to a given parameter value

Parameters:
  • param_value – the parameter value to adjust

  • normalize_envelope_to_length – if given, and the add or multiply is an Envelope object, normalize the length of that envelope object to this.

Returns:

the adjusted value of the parameter

uses_envelope()[source]
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