beatmachine.effects.base module

The base module contains a base effect class as well as a metaclass-based registry for simple, batteries-included deserialization of effects.

class beatmachine.effects.base.EffectABCMeta

Bases: beatmachine.effects.base.EffectRegistry, abc.ABCMeta

EffectABCMeta is a metaclass combining EffectRegistry and ABCMeta.

class beatmachine.effects.base.EffectRegistry

Bases: type

The EffectRegistry is a metaclass that serves to track all loadable effects.

effects = {'cut': <class 'beatmachine.effects.periodic.CutEveryNth'>, 'randomize': <class 'beatmachine.effects.temporal.RandomizeAllBeats'>, 'remap': <class 'beatmachine.effects.temporal.RemapBeats'>, 'remove': <class 'beatmachine.effects.periodic.RemoveEveryNth'>, 'repeat': <class 'beatmachine.effects.periodic.RepeatEveryNth'>, 'reverse': <class 'beatmachine.effects.periodic.ReverseEveryNth'>, 'silence': <class 'beatmachine.effects.periodic.SilenceEveryNth'>, 'swap': <class 'beatmachine.effects.temporal.SwapBeats'>}
static load_effect_from_dict(effect: dict) → beatmachine.effects.base.LoadableEffect

Loads an effect based on a key-value definition. This is represented as a Python dictionary but could be loaded from anywhere, i.e. JSON data.

A “type” key is required to determine which effect to load. All other values are passed directly as keyword arguments to the effect constructor.

Parameters:

effect – Effect representation to load.

Raises:
  • KeyError – if no effect with the given name was found.
  • ValueError – if the effect failed to load, likely due to an invalid/missing parameter.
Returns:

An effect based on the given definition.

class beatmachine.effects.base.LoadableEffect

Bases: abc.ABC

LoadableEffect is an abstract base for a valid effect loadable by the EffectRegistry.