Deformation reference

Utilities

class muda.deformers.Bypass(transformer=None)[source]

Bypass transformer. Wraps an existing transformer object.

This allows pipeline stages to become optional.

The first example generated by a Bypass’s transform method is the input, followed by all examples generated by the contained transformer object.

Examples

>>> # Generate examples with and without a pitch-shift
>>> D = muda.deformers.Pitchshift(n_semitones=2.0)
>>> B = muda.deformers.Bypass(transformer=D)
>>> out_jams = list(B.transform(input_jam))

Attributes

transformer (muda.BaseTransformer) The transformer object to bypass

Methods

get_params([deep]) Get the parameters for this object.
states(jam)
transform(jam) Bypass transformations.

Audio deformers

class muda.deformers.BackgroundNoise(n_samples=1, files=None, weight_min=0.1, weight_max=0.5)[source]

Additive background noise deformations.

From each background noise signal, n_samples clips are randomly extracted and mixed with the input audio with a random mixing coefficient sampled uniformly between weight_min and weight_max.

This transformation affects the following attributes:

  • Audio

Attributes

n_samples (int > 0) The number of samples to generate with each noise source
files (str or list of str) Path to audio file(s) on disk containing background signals
weight_min (float in (0.0, 1.0))
weight_max (float in (0.0, 1.0)) The minimum and maximum weight to combine input signals y_out = (1 - weight) * y + weight * y_noise

Methods

audio(mudabox, state)
get_params([deep]) Get the parameters for this object.
states(jam)
transform(jam) Iterative transformation generator
class muda.deformers.DynamicRangeCompression(preset=None)[source]

Dynamic range compression.

For each DRC preset configuration, one deformation is generated.

This transformation affects the following attributes:

  • Audio

Examples

>>> # A single preset
>>> drc = muda.deformers.DynamicRangeCompression(preset='radio')
>>> # Multiple presets
>>> drc = muda.deformers.DynamicRangeCompression(preset=['film standard',
...                                                      'film light'])
>>> # All presets
>>> drc = muda.deformers.DynamicRangeCompression(preset=muda.deformers.PRESETS.keys())

Attributes

preset (str or list of str) One or more supported preset values: - radio - film standard - film light - music standard - music light - speech

Methods

audio(mudabox, state)
get_params([deep]) Get the parameters for this object.
states(jam)
transform(jam) Iterative transformation generator

Time-stretch deformers

class muda.deformers.TimeStretch(rate=1.2)[source]

Static time stretching by a fixed rate

This transformation affects the following attributes:

  • Annotations
    • all: time, duration
    • tempo: values
  • metadata
    • duration
  • Audio

Examples

>>> D = muda.deformers.TimeStretch(rate=2.0)
>>> out_jams = list(D.transform(jam_in))

Attributes

rate (float > 0) The rate at which to speedup the audio. - rate > 1 speeds up, - rate < 1 slows down.

Methods

audio(mudabox, state)
deform_tempo(annotation, state)
deform_times(ann, state)
get_params([deep]) Get the parameters for this object.
metadata(metadata, state)
states(jam)
transform(jam) Iterative transformation generator
class muda.deformers.RandomTimeStretch(n_samples=3, location=0.0, scale=0.1)[source]

Random time stretching

For each deformation, the rate parameter is drawn from a log-normal distribution with parameters (location, scale)

  • Annotations
    • all: time, duration
    • tempo: values
  • metadata
    • duration
  • Audio

Attributes

n_samples (int > 0) The number of samples to generate
location (float)
scale (float > 0) Parameters of a log-normal distribution from which rate parameters are sampled.

Methods

audio(mudabox, state)
deform_tempo(annotation, state)
deform_times(ann, state)
get_params([deep]) Get the parameters for this object.
metadata(metadata, state)
states(jam)
transform(jam) Iterative transformation generator
class muda.deformers.LogspaceTimeStretch(n_samples=3, lower=-0.3, upper=0.3)[source]

Logarithmically spaced time stretching.

n_samples are generated with stretching spaced logarithmically between 2.0**lower and 2`.0**upper`.

This transformation affects the following attributes:

  • Annotations
    • all: time, duration
    • tempo: values
  • metadata
    • duration
  • Audio

Attributes

n_samples (int > 0) Number of deformations to generate
lower (float)
upper (float > lower) Minimum and maximum bounds on the stretch parameters

Methods

audio(mudabox, state)
deform_tempo(annotation, state)
deform_times(ann, state)
get_params([deep]) Get the parameters for this object.
metadata(metadata, state)
states(jam)
transform(jam) Iterative transformation generator

Pitch-shift deformers

class muda.deformers.PitchShift(n_semitones=1)[source]

Static pitch shifting by (fractional) semitones

This transformation affects the following attributes:

  • Annotations
    • key_mode
    • chord, chord_harte, chord_roman
    • pitch_hz, pitch_midi, pitch_class
  • Audio

Examples

>>> # Shift down by a quarter-tone
>>> D = muda.deformers.PitchShift(n_semitones=-0.5)

Attributes

n_semitones (float) The number of semitones to transpose the signal. Can be positive, negative, integral, or fractional.

Methods

audio(mudabox, state)
deform_frequency(annotation, state)
deform_midi(annotation, state)
deform_note(annotation, state)
deform_tonic(annotation, state)
get_params([deep]) Get the parameters for this object.
states(jam)
transform(jam) Iterative transformation generator
class muda.deformers.RandomPitchShift(n_samples=3, mean=0.0, sigma=1.0)[source]

Randomized pitch shifter

Pitch is transposed by a normally distributed random variable.

This transformation affects the following attributes:

  • Annotations
    • key_mode
    • chord, chord_harte, chord_roman
    • pitch_hz, pitch_midi, pitch_class
  • Audio

Examples

>>> # 5 random shifts with unit variance and mean of 1 semitone
>>> D = muda.deformers.PitchShift(n_samples=5, mean=1.0, sigma=1)

Attributes

n_samples (int > 0) The number of samples to generate per input
mean (float)
sigma (float > 0) The parameters of the normal distribution for sampling pitch shifts

Methods

audio(mudabox, state)
deform_frequency(annotation, state)
deform_midi(annotation, state)
deform_note(annotation, state)
deform_tonic(annotation, state)
get_params([deep]) Get the parameters for this object.
states(jam)
transform(jam) Iterative transformation generator
class muda.deformers.LinearPitchShift(n_samples=3, lower=-1, upper=1)[source]

Linearly spaced pitch shift generator

This transformation affects the following attributes:

  • Annotations
    • key_mode
    • chord, chord_harte, chord_roman
    • pitch_hz, pitch_midi, pitch_class
  • Audio

Examples

>>> # 5 shifts spaced between -2 and +2 semitones
>>> D = muda.deformers.LinearPitchShift(n_samples=5, lower=-2, upper=2)

Attributes

n_samples (int > 0) The number of samples to generate per input
lower (float)
upper (float) The lower and upper bounds for the shift sampling

Methods

audio(mudabox, state)
deform_frequency(annotation, state)
deform_midi(annotation, state)
deform_note(annotation, state)
deform_tonic(annotation, state)
get_params([deep]) Get the parameters for this object.
states(jam)
transform(jam) Iterative transformation generator