MUDA Core

Functions

Core functionality for muda

muda.core.load_jam_audio(jam_in, audio_file, **kwargs)[source]

Load a jam and pack it with audio.

Parameters:

jam_in : str, file descriptor, or jams.JAMS

JAMS filename, open file-descriptor, or object to load. See jams.load for acceptable formats.

audio_file : str

Audio filename to load

kwargs : additional keyword arguments

See librosa.load

Returns:

jam : jams.JAMS

A jams object with audio data in the top-level sandbox

See also

jams.load, librosa.core.load

muda.core.save(filename_audio, filename_jam, jam, strict=True, **kwargs)[source]

Save a muda jam to disk

Parameters:

filename_audio: str

The path to store the audio file

filename_jam: str

The path to store the jams object

strict: bool

Strict safety checking for jams output

kwargs

Additional parameters to soundfile.write

muda.core.jam_pack(jam, **kwargs)[source]

Pack data into a jams sandbox.

If not already present, this creates a muda field within jam.sandbox, along with history, state, and version arrays which are populated by deformation objects.

Any additional fields can be added to the muda sandbox by supplying keyword arguments.

Parameters:

jam : jams.JAMS

A JAMS object

Returns:

jam : jams.JAMS

The updated JAMS object

Examples

>>> jam = jams.JAMS()
>>> muda.jam_pack(jam, my_data=dict(foo=5, bar=None))
>>> jam.sandbox
<Sandbox: muda>
>>> jam.sandbox.muda
<Sandbox: state, version, my_data, history>
>>> jam.sandbox.muda.my_data
{'foo': 5, 'bar': None}
muda.core.serialize(transform, **kwargs)[source]

Serialize a transformation object or pipeline.

Parameters:

transform : BaseTransform or Pipeline

The transformation object to be serialized

kwargs

Additional keyword arguments to jsonpickle.encode()

Returns:

json_str : str

A JSON encoding of the transformation

See also

deserialize

Examples

>>> D = muda.deformers.TimeStretch(rate=1.5)
>>> muda.serialize(D)
'{"params": {"rate": 1.5},
  "__class__": {"py/type": "muda.deformers.time.TimeStretch"}}'
muda.core.deserialize(encoded, **kwargs)[source]

Construct a muda transformation from a JSON encoded string.

Parameters:

encoded : str

JSON encoding of the transformation or pipeline

kwargs

Additional keyword arguments to jsonpickle.decode()

Returns:

obj

The transformation

See also

serialize

Examples

>>> D = muda.deformers.TimeStretch(rate=1.5)
>>> D_serial = muda.serialize(D)
>>> D2 = muda.deserialize(D_serial)
>>> D2
TimeStretch(rate=1.5)

Classes

class muda.base.BaseTransformer[source]

The base class for all transformation objects. This class implements a single transformation (history) and some various niceties.

Methods

get_params([deep]) Get the parameters for this object.
states(jam)
transform(jam) Iterative transformation generator
get_params(deep=True)[source]

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

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.base.Pipeline(steps=None)[source]

Wrapper which allows multiple BaseDeformer objects to be chained together

A given JAMS object will be transformed sequentially by each stage of the pipeline.

The pipeline induces a graph over transformers

Examples

>>> P = muda.deformers.PitchShift(semitones=5)
>>> T = muda.deformers.TimeStretch(speed=1.25)
>>> Pipe = muda.Pipeline(steps=[('Pitch:maj3', P), ('Speed:1.25x', T)])
>>> output_jams = list(Pipe.transform(jam_in))

Attributes

steps (argument array) steps[i] is a tuple of (name, Transformer)

Methods

get_params() Get the parameters for this object.
transform(jam) Apply the sequence of transformations to a single jam object.
get_params()[source]

Get the parameters for this object. Returns as a dict.

transform(jam)[source]

Apply the sequence of transformations to a single jam object.

Parameters:

jam : jams.JAMS

The jam object to transform