audiblelight.augmentation.Augmentation#

class audiblelight.augmentation.Augmentation(sample_rate=44100)#

Bases: object

Base class for all augmentation objects to inherit from.

Augmentation objects need to inherit from this base class so that their parameters can be sampled from a distribution every time they are called. This distribution can either be user-defined or set according to a default. The user can also pass a numeric override for a parameter, in which case it will always be used.

Parameters:

sample_rate (custom_types.Numeric) – the sample rate for the effect to use.

Properties:

fx (Callable): the callable function applied to the audio. params (dict): the arguments passed to fx. Will be serialised inside to_json.

__init__(sample_rate=44100)#
Parameters:

sample_rate (int | float | complex | integer | floating | None)

Methods

__init__([sample_rate])

from_dict(input_dict)

Initialise an augmentation from a dictionary.

process(input_array)

Calls the underlying FX (or a list of FX)

sample_value(override, default_dist)

Samples a value according to the following method:

to_dict()

Returns the parameters used by this augmentation

Attributes

name

Returns the name of this augmentation

__eq__(other)#

Compare two Augmentation objects for equality.

Internally, we convert both objects to a dictionary, and then use the deepdiff package to compare them, with some additional logic to account e.g. for significant digits and values that will always be different (e.g., creation time).

Parameters:

other (Any) – the object to compare the current Augmentation object against

Returns:

True if the Augmentation objects are equivalent, False otherwise

Return type:

bool

__iter__()#

Yields an iterator of Event objects from the current scene

Return type:

Iterator[Callable]

__len__()#

Returns the number of FX in this augmentation

Return type:

int

__repr__()#

Dumps a prettified representation of the parameters used in the FX object

Return type:

str

__str__()#

Returns a string representation of the augmentation

Return type:

str

classmethod from_dict(input_dict)#

Initialise an augmentation from a dictionary.

Note that the returned object will not be of the Augmentation type, but one of its child classes. So, attempting to initialise a dictionary where “name” == “LowpassFilter” will instead return a LowpassFilter object, not an Augmentation object.

Parameters:

input_dict (dict[str, Any]) – Dictionary that will be used to instantiate the object.

Returns:

Augmentation child class instance.

Return type:

Type[Augmentation]

property name: str#

Returns the name of this augmentation

process(input_array)#

Calls the underlying FX (or a list of FX)

Parameters:

input_array (np.ndarray) – input audio array

Returns:

processed audio array

Return type:

np.ndarray

static sample_value(override, default_dist)#
Samples a value according to the following method:
  • If override is not provided, a value will be sampled from the default_dist distribution.

  • If the override is numeric, it will be used.

  • If the override is a distribution, it will be sampled from the default_dist distribution.

  • Otherwise, an error will be raised

Parameters:
  • override (int | float | complex | integer | floating | DistributionLike | None)

  • default_dist (DistributionLike)

Return type:

int | float | complex | integer | floating

to_dict()#

Returns the parameters used by this augmentation

Return type:

dict