MUDA Core¶
Functions¶
Core functionality for muda
-
muda.core.
load_jam_audio
(jam_in, audio_file, validate=True, strict=True, fmt='auto', **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
validate : bool
strict : bool
fmt : str
Parameters to jams.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
Notes
This operation can modify the file_metadata.duration field of jam_in: If it is not currently set, it will be populated with the duration of the audio file.
-
muda.core.
save
(filename_audio, filename_jam, jam, strict=True, fmt='auto', **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
fmt : str
Output format parameter for jams.JAMS.save
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
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
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
-
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
See also
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.
-
class
muda.base.
Union
(steps=None)[source]¶ Wrapper which allows multiple BaseDeformer objects to be combined for round-robin sampling.
A given JAMS object will be transformed sequentially by each element of the union, in round-robin fashion. This is similar to Pipeline, except the deformers are independent of one another in a Union, rather than applied sequentially.
See also
Examples
>>> P = muda.deformers.PitchShift(semitones=5) >>> T = muda.deformers.TimeStretch(speed=1.25) >>> union = muda.Union(steps=[('Pitch:maj3', P), ('Speed:1.25x', T)]) >>> output_jams = list(union.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.