CPJKU / madmom

Python audio and music signal processing library
https://madmom.readthedocs.io
Other
1.35k stars 206 forks source link

ParallelProcessor usage #515

Closed keithchan9999 closed 1 year ago

keithchan9999 commented 1 year ago

Expected behaviour

Please describe how you expected madmom to behave.

Actual behaviour

I am trying to run both a beat processor and a tempo processor which wraps under a parallel processor. But I got an error like this:

File "mad.py", line 158, in main madmom.processors.process_online(parallel_processor, kwargs) File "C:\Users\kido9\miniconda3\envs\mad\lib\site-packages\madmom\processors.py", line 885, in process_online _process((processor, frame, outfile, process_args)) File "C:\Users\kido9\miniconda3\envs\mad\lib\site-packages\madmom\processors.py", line 289, in _process return process_tuple[0](*process_tuple[1:-1], *process_tuple[-1]) File "C:\Users\kido9\miniconda3\envs\mad\lib\site-packages\madmom\processors.py", line 120, in call return self.process(args, kwargs) TypeError: process() takes 2 positional arguments but 3 were given

Tried to troubleshoot but unfortunately I ain't any expert on that.

Steps needed to reproduce the behaviour

kwargs = dict(
        fps = 100,
        correct = True,
        infile = None,
        outfile = None,
        max_bpm = 150,
        min_bpm = 60,
        num_frames = 1,
        online = True,
        stream_input_device = dev_index,
        #nn_files = [BEATS_LSTM[0], BEATS_LSTM[1], BEATS_LSTM[2], BEATS_LSTM[3], BEATS_LSTM[4]]
        #verbose = 1
    )

    in_processor = madmom.features.beats.RNNBeatProcessor(**kwargs)
    beat_processor = madmom.features.beats.DBNBeatTrackingProcessor(**kwargs)
    out_processor = [beat_processor, beat_callback]
    processor = madmom.processors.IOProcessor(in_processor, out_processor)

    tempo_processor = madmom.features.tempo.TempoEstimationProcessor(**kwargs)
    out2_processor = [tempo_processor, tempo_callback]
    processor2 = madmom.processors.IOProcessor(in_processor, out2_processor)

    parallel_processor = madmom.processors.ParallelProcessor([processor, processor2], num_threads=2)
    madmom.processors.process_online(parallel_processor, **kwargs)

Information about installed software

Please provide some information about installed software.

import madmom
import numpy as np
import scipy

madmom.__version__
np.__version__
scipy.__version__
superbock commented 1 year ago

madmom does not have such a sophisticated process management, so you need to do this by yourself, i.e. wrap the beat tempo sub-pipelines in a parallel processor and use in_processor to feed it.

in_processor = madmom.features.beats.RNNBeatProcessor(**kwargs)

beat_tracker = madmom.features.beats.DBNBeatTrackingProcessor(**kwargs)
beat_processor = madmom.processors.IOProcessor(beat_tracker, beat_callback)

tempo_estimator = madmom.features.tempo.TempoEstimationProcessor(**kwargs)
tempo_processor = madmom.processors.IOProcessor(tempo_estimator, tempo_callback)

parallel_processor = madmom.processors.ParallelProcessor([beat_processor, tempo_processor], num_threads=2)

pipeline = madmom.processors.SequentialProcessor(in_processor, parallel_processor)
madmom.processors.process_online(pipeline, **kwargs)

However, you have to make sure the your beat_callback and tempo_callback accept two arguments (data, output).

HTH,