#!/usr/bin/env python3from madmom.models import BEATS_LSTMfrom madmom.features.beats import DBNBeatTrackingProcessor, RNNBeatProcessorfrom madmom.audio.signal import Stream
stream = Stream( sample_rate = 44100, num_channels = 1, frame_size = 2048, fps = 100)
rnn = RNNBeatProcessor( online = True, nn_files = [BEATS_LSTM[0]])
dbn = DBNBeatTrackingProcessor( min_bpm = 100, max_bpm = 180, fps = 100, online = True)dbn.reset()
for frame in stream: activations = rnn.process(frame) beats = dbn.process(activations, reset=False) if len(beats) > 0: print(beats)
from madmom.features.beats import DBNBeatTrackingProcessor, RNNBeatProcessor
from madmom.models import BEATS_LSTMfrom madmom.processors import IOProcessor, process_online
kwargs = dict( fps = 100, correct = True, infile = None, outfile = None, max_bpm = 170, min_bpm = 100, nn_files = [BEATS_LSTM[0]], num_frames = 1, online = True, #verbose = 1)
def beat_callback(beats, output=None): if len(beats) > 0: # Do something with the beat (for now, just print the array to stdout) print(beats)
in_processor = RNNBeatProcessor(**kwargs)beat_processor = DBNBeatTrackingProcessor(**kwargs)out_processor = [beat_processor, beat_callback]processor = IOProcessor(in_processor, out_processor)process_online(processor, **kwargs)
One issue - there is a noticeable delay (maybe 100 - 200ms?) between when I hear the beat of the music and when I see the beat printed to my screen. For my project that is OK, because I am sending these beats to a digital phase locked loop (DPLL) and I can subtract that delay from each of the beat times before sending it off to the DPLL process.
However, Sebastian is there anything else I can do to optimize this or reduce that delay? Normally I would try lowering the sample rate, and changing the fft window size and hop size accordingly, however I believe the neural nets were trained on a 44100 sample rate, so I am thinking I should not change it?
On Sunday, 1 September 2019 16:16:25 UTC+2, Ian Charnas wrote:One issue - there is a noticeable delay (maybe 100 - 200ms?) between when I hear the beat of the music and when I see the beat printed to my screen. For my project that is OK, because I am sending these beats to a digital phase locked loop (DPLL) and I can subtract that delay from each of the beat times before sending it off to the DPLL process.That surprises me a bit, since the whole system should be able to detect the beats within 1 (or maybe 2) frame(s). This should be negligible but more or less unavoidable. I am pretty sure about this, but you can try it for yourself by calling your Processor frame by frame with an offline signal you have annotations for. Of course this depends on the type of music you're processing, but for percussive music this is generally true.
The beat detection algorithm is VERY good! Much better than the other ones I tried before I found madmom. Well done!
One small suggestion - in signal.py where you open the pyaudio stream, it would be nice if I could specify which input device to use. When you call pa.open, could you pass in a "input_device_index" parameter, and allow me to pass that in as a kwarg when I call process_online? The parameter can default to None, since that is the default for the pyaudio function.
Excellent software! Thank you for your work.
--
You received this message because you are subscribed to the Google Groups "madmom-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to madmom-users...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/madmom-users/c30a13ff-4ce1-4645-a19f-f69e97fe6bad%40googlegroups.com.
Also, I did a fresh "git clone https://github.com/CPJKU/madmom.git" and made the changes we talked about for setting the input device index. I then did a "git diff" to produce a patch, and I'm attaching that to this email. I don't know how to do a pull request - do I need to have write permission to the github repo for that?
Sorry, outdated link, new PR is here: https://github.com/CPJKU/madmom/pull/451
--
You received this message because you are subscribed to the Google Groups "madmom-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to madmom-users...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/madmom-users/4a23cfa9-7eee-40ac-8af3-f541d2f85139%40googlegroups.com.
I am happy to help test this, however I don't understand how to download the branch with the changes in it.I tried "git clone https://github.com/CPJKU/madmom/pull/451" but that didn't seem to work.
--
You received this message because you are subscribed to the Google Groups "madmom-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to madmom-users...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/madmom-users/9d1d0514-15d4-4b83-96e1-7168dca339d2%40googlegroups.com.
Thanks Sebastian, I gave that a try but I got an error running DBNBeatTracker:
[...]
It looks like it can't find the models module, and when I do an "ls /home/pi/.local/lib/python3.7/site-packages/madmom/" I get the following, which does not include models.
--
You received this message because you are subscribed to the Google Groups "madmom-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to madmom-users...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/madmom-users/65acc3f3-d72e-47be-8720-b7cbc1b12b0a%40googlegroups.com.
But I got this error:
ImportError: cannot import name 'BEATS_LSTM' from 'madmom.models' (unknown location)So then I checked to see what was in the models directory:ls madmom/modelsBut there were no files in there at all.Did I do something wrong?
--
You received this message because you are subscribed to the Google Groups "madmom-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to madmom-users...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/madmom-users/9d34ce65-8771-4339-9676-3ba96e19300f%40googlegroups.com.
If anyone is reading this forum in the future and wants to know how they can figure out the device index, try running this python codeimport pyaudiop = pyaudio.PyAudio()
num_devices = p.get_device_count()for i in range(num_devices): print(p.get_device_info_by_index(i))
--
You received this message because you are subscribed to the Google Groups "madmom-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to madmom-users...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/madmom-users/3f4ae332-d518-4bc1-8837-f89c01793e7e%40googlegroups.com.