

def _transform(self, jam, state):
    'Apply the transformation to audio and annotations.\n\n        The input jam is copied and modified, and returned\n        contained in a list.\n\n        Parameters\n        ----------\n        jam : jams.JAMS\n            A single jam object to modify\n\n        Returns\n        -------\n        jam_list : list\n            A length-1 list containing `jam` after transformation\n\n        See also\n        --------\n        core.load_jam_audio\n        '
    if (not hasattr(jam.sandbox, 'muda')):
        raise RuntimeError('No muda state found in jams sandbox.')
    jam_w = copy.deepcopy(jam)
    jam_w.sandbox.muda['history'].append({
        'transformer': self.__serialize__,
        'state': state,
    })
    if hasattr(self, 'audio'):
        self.audio(jam_w.sandbox.muda, state)
    if hasattr(self, 'metadata'):
        self.metadata(jam_w.file_metadata, state)
    for (query, function_name) in six.iteritems(self.dispatch):
        function = getattr(self, function_name)
        for matched_annotation in jam_w.search(namespace=query):
            function(matched_annotation, state)
    return jam_w

dataset/ETHPy150Open bmcfee/muda/muda/base.py BaseTransformer._transform/original