jams.nsconvert.convert

jams.nsconvert.convert(annotation, target_namespace)[source]

Convert a given annotation to the target namespace.

Parameters:
annotation : jams.Annotation

An annotation object

target_namespace : str

The target namespace

Returns:
mapped_annotation : jams.Annotation

if annotation already belongs to target_namespace, then it is returned directly.

otherwise, annotation is copied and automatically converted to the target namespace.

Raises:
SchemaError

if the input annotation fails to validate

NamespaceError

if no conversion is possible

Examples

Convert frequency measurements in Hz to MIDI

>>> ann_midi = jams.convert(ann_hz, 'note_midi')

And back to Hz

>>> ann_hz2 = jams.convert(ann_midi, 'note_hz')