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
(self[, deep])Get the parameters for this object. transform
(self, jam)Bypass transformations. states -
get_params
(self, deep=True)¶ Get the parameters for this object. Returns as a dict.
Parameters: - deep : bool
Recurse on nested objects
Returns: - params : dict
A dictionary containing all parameters for this object
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
get_params
(self[, deep])Get the parameters for this object. transform
(self, jam)Iterative transformation generator audio states -
get_params
(self, deep=True)¶ Get the parameters for this object. Returns as a dict.
Parameters: - deep : bool
Recurse on nested objects
Returns: - params : dict
A dictionary containing all parameters for this object
-
transform
(self, jam)¶ Iterative transformation generator
Applies the deformation to an input jams object.
This generates a sequence of deformed output JAMS.
Parameters: - jam : jams.JAMS
The jam to transform
Examples
>>> for jam_out in deformer.transform(jam_in): ... process(jam_out)
-
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
get_params
(self[, deep])Get the parameters for this object. transform
(self, jam)Iterative transformation generator audio states -
get_params
(self, deep=True)¶ Get the parameters for this object. Returns as a dict.
Parameters: - deep : bool
Recurse on nested objects
Returns: - params : dict
A dictionary containing all parameters for this object
-
transform
(self, jam)¶ Iterative transformation generator
Applies the deformation to an input jams object.
This generates a sequence of deformed output JAMS.
Parameters: - jam : jams.JAMS
The jam to transform
Examples
>>> for jam_out in deformer.transform(jam_in): ... process(jam_out)
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
See also
Examples
>>> D = muda.deformers.TimeStretch(rate=2.0) >>> out_jams = list(D.transform(jam_in))
Attributes: - rate : float or list of floats, strictly positive
The rate at which to speedup the audio. - rate > 1 speeds up, - rate < 1 slows down.
Methods
get_params
(self[, deep])Get the parameters for this object. transform
(self, jam)Iterative transformation generator audio deform_tempo deform_times metadata states -
get_params
(self, deep=True)¶ Get the parameters for this object. Returns as a dict.
Parameters: - deep : bool
Recurse on nested objects
Returns: - params : dict
A dictionary containing all parameters for this object
-
transform
(self, jam)¶ Iterative transformation generator
Applies the deformation to an input jams object.
This generates a sequence of deformed output JAMS.
Parameters: - jam : jams.JAMS
The jam to transform
Examples
>>> for jam_out in deformer.transform(jam_in): ... process(jam_out)
-
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
See also
TimeStretch
LogspaceTimeStretch
numpy.random.lognormal
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
get_params
(self[, deep])Get the parameters for this object. transform
(self, jam)Iterative transformation generator audio deform_tempo deform_times metadata states -
get_params
(self, deep=True)¶ Get the parameters for this object. Returns as a dict.
Parameters: - deep : bool
Recurse on nested objects
Returns: - params : dict
A dictionary containing all parameters for this object
-
transform
(self, jam)¶ Iterative transformation generator
Applies the deformation to an input jams object.
This generates a sequence of deformed output JAMS.
Parameters: - jam : jams.JAMS
The jam to transform
Examples
>>> for jam_out in deformer.transform(jam_in): ... process(jam_out)
-
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
See also
Attributes: - n_samples : int > 0
Number of deformations to generate
- lower : float
- upper : float > lower
Minimum and maximum bounds on the stretch parameters
Methods
get_params
(self[, deep])Get the parameters for this object. transform
(self, jam)Iterative transformation generator audio deform_tempo deform_times metadata states -
get_params
(self, deep=True)¶ Get the parameters for this object. Returns as a dict.
Parameters: - deep : bool
Recurse on nested objects
Returns: - params : dict
A dictionary containing all parameters for this object
-
transform
(self, jam)¶ Iterative transformation generator
Applies the deformation to an input jams object.
This generates a sequence of deformed output JAMS.
Parameters: - jam : jams.JAMS
The jam to transform
Examples
>>> for jam_out in deformer.transform(jam_in): ... process(jam_out)
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
See also
Examples
>>> # Shift down by a quarter-tone >>> D = muda.deformers.PitchShift(n_semitones=-0.5)
Attributes: - n_semitones : float or list of float
The number of semitones to transpose the signal. Can be positive, negative, integral, or fractional.
Methods
get_params
(self[, deep])Get the parameters for this object. transform
(self, jam)Iterative transformation generator audio deform_frequency deform_midi deform_note deform_tonic states -
get_params
(self, deep=True)¶ Get the parameters for this object. Returns as a dict.
Parameters: - deep : bool
Recurse on nested objects
Returns: - params : dict
A dictionary containing all parameters for this object
-
transform
(self, jam)¶ Iterative transformation generator
Applies the deformation to an input jams object.
This generates a sequence of deformed output JAMS.
Parameters: - jam : jams.JAMS
The jam to transform
Examples
>>> for jam_out in deformer.transform(jam_in): ... process(jam_out)
-
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
See also
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
get_params
(self[, deep])Get the parameters for this object. transform
(self, jam)Iterative transformation generator audio deform_frequency deform_midi deform_note deform_tonic states -
get_params
(self, deep=True)¶ Get the parameters for this object. Returns as a dict.
Parameters: - deep : bool
Recurse on nested objects
Returns: - params : dict
A dictionary containing all parameters for this object
-
transform
(self, jam)¶ Iterative transformation generator
Applies the deformation to an input jams object.
This generates a sequence of deformed output JAMS.
Parameters: - jam : jams.JAMS
The jam to transform
Examples
>>> for jam_out in deformer.transform(jam_in): ... process(jam_out)
-
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
See also
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
get_params
(self[, deep])Get the parameters for this object. transform
(self, jam)Iterative transformation generator audio deform_frequency deform_midi deform_note deform_tonic states -
get_params
(self, deep=True)¶ Get the parameters for this object. Returns as a dict.
Parameters: - deep : bool
Recurse on nested objects
Returns: - params : dict
A dictionary containing all parameters for this object
-
transform
(self, jam)¶ Iterative transformation generator
Applies the deformation to an input jams object.
This generates a sequence of deformed output JAMS.
Parameters: - jam : jams.JAMS
The jam to transform
Examples
>>> for jam_out in deformer.transform(jam_in): ... process(jam_out)