After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 751457 - bpmdetect: it's just crazy
bpmdetect: it's just crazy
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
1.4.5
Other Mac OS
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-06-24 19:31 UTC by Kyrylo V. Polezhaiev
Modified: 2018-11-03 13:36 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Kyrylo V. Polezhaiev 2015-06-24 19:31:49 UTC
It's provides BPM few times per second, very different.

Here what I have for Iron Maiden's song named Night Wing, which is kinda slow and relaxing.

0:01:44.153469388: bpm-change
	bpm: 87.161568
0:01:44.231836735: bpm-change
	bpm: 102.273079
0:01:44.310204082: bpm-change
	bpm: 87.605453
0:01:44.336326531: bpm-change
	bpm: 102.275314
0:01:44.362448980: bpm-change
	bpm: 119.003883
0:01:44.388571429: bpm-change
	bpm: 93.015221
0:01:44.414693878: bpm-change
	bpm: 106.442261
0:01:44.545306122: bpm-change
	bpm: 134.060410
0:01:44.571428571: bpm-change
	bpm: 135.934280
0:01:44.597551020: bpm-change
	bpm: 106.241516
0:01:44.675918367: bpm-change
	bpm: 130.866714
0:01:45.381224490: bpm-change
	bpm: 109.939919
0:01:45.407346939: bpm-change
	bpm: 107.384407
0:01:45.433469388: bpm-change
	bpm: 92.727814
0:01:45.459591837: bpm-change
	bpm: 136.055618
0:01:45.485714286: bpm-change
	bpm: 106.717567
0:01:45.537959184: bpm-change
	bpm: 136.059326
0:01:45.564081633: bpm-change
	bpm: 106.626236
0:01:45.590204082: bpm-change
	bpm: 135.762405
0:01:45.616326531: bpm-change
	bpm: 106.626465
0:01:45.720816327: bpm-change
	bpm: 136.527771
0:01:45.929795918: bpm-change
	bpm: 106.718384
0:01:45.955918367: bpm-change
	bpm: 136.221283
0:01:46.086530612: bpm-change
	bpm: 148.490067
0:01:46.112653061: bpm-change
	bpm: 136.525070
0:01:46.295510204: bpm-change
	bpm: 31.038805
0:01:46.373877551: bpm-change
	bpm: 62.254467
0:01:46.400000000: bpm-change
	bpm: 131.138596
0:01:46.530612245: bpm-change
	bpm: 33.087658
0:01:46.556734694: bpm-change
	bpm: 98.822479
0:01:46.687346939: bpm-change
	bpm: 33.087734
0:01:46.844081633: bpm-change
	bpm: 99.065544
0:01:46.896326531: bpm-change
	bpm: 49.928188
0:01:46.974693878: bpm-change
	bpm: 99.073532
0:01:47.209795918: bpm-change
	bpm: 114.543060
0:01:47.314285714: bpm-change
	bpm: 120.766243
0:01:47.497142857: bpm-change
	bpm: 159.715683
0:01:47.601632653: bpm-change
	bpm: 169.155441
0:01:47.706122449: bpm-change
	bpm: 130.444199
0:01:47.732244898: bpm-change
	bpm: 147.756073
0:01:47.758367347: bpm-change
	bpm: 135.897797
0:01:47.784489796: bpm-change
	bpm: 159.716187
0:01:47.810612245: bpm-change
	bpm: 135.908035
0:01:47.862857143: bpm-change
	bpm: 106.815742
0:01:48.124081633: bpm-change
	bpm: 135.895920
0:01:48.150204082: bpm-change
	bpm: 106.814934
0:01:48.254693878: bpm-change
	bpm: 120.892731
0:01:48.280816327: bpm-change
	bpm: 106.909233
0:01:48.359183673: bpm-change
	bpm: 135.605347
0:01:48.385306122: bpm-change
	bpm: 120.882492
0:01:48.411428571: bpm-change
	bpm: 181.669678
0:01:48.489795918: bpm-change
	bpm: 120.764008
0:01:48.568163265: bpm-change
	bpm: 180.309387
0:01:48.672653061: bpm-change
	bpm: 120.759743
0:01:48.698775510: bpm-change
	bpm: 180.854233
0:01:48.777142857: bpm-change
	bpm: 120.761261
0:01:48.803265306: bpm-change
	bpm: 180.571365
0:01:49.221224490: bpm-change
	bpm: 181.954803
0:01:49.299591837: bpm-change
	bpm: 120.757683
0:01:49.351836735: bpm-change
	bpm: 181.138626
0:01:49.926530612: bpm-change
	bpm: 182.238922
Comment 1 Kyrylo V. Polezhaiev 2015-06-24 19:32:41 UTC
Thats for 10 seconds: from second 100 till second 110.
Comment 2 Kyrylo V. Polezhaiev 2015-06-24 20:00:33 UTC
I have similar result for video with tanks column driving on road.
I even can not distinguish those audio tracks by examining it's BPM.
Comment 3 Tim-Philipp Müller 2015-06-25 08:24:54 UTC
The soundtouch website says "The BPM detection algorithm works by detecting repeating bass or drum patterns at low frequencies of <250Hz. A lower-than-expected BPM figure may be reported for music with uneven or complex bass patterns" - is this the case here?

Would be good to compare it against some other soundtouch-using application to see whether the problem is in the library or our use of it.
Comment 4 Kyrylo V. Polezhaiev 2015-06-25 10:45:47 UTC
Now, they aren't lower-than-expected at all: it's 2-to-3 beats per second.
Comment 5 Dustin Spicuzza 2015-08-16 21:51:51 UTC
I just implemented something to use the bpmdetect plugin in python:

https://gist.github.com/virtuald/c30032a5b8cdacd1a6c0

For a given file, I get the following output:

BPM: [30.310665130615234, 101.57039642333984, 50.529014587402344, 34.0688591003418, 50.531585693359375, 30.80596160888672, 32.05588912963867, 34.01376724243164, 154.14556884765625, 34.32243347167969, 103.87847900390625, 154.23440551757812, 34.306034088134766, 154.53562927246094, 38.48063659667969, 154.63739013671875, 38.483619689941406, 154.60488891601562, 38.50436019897461, 154.60694885253906, 38.50547409057617, 154.2655792236328, 38.618038177490234, 154.63363647460938, 38.62126159667969, 154.69009399414062, 152.59304809570312, 38.71311569213867, 151.76808166503906, 51.883724212646484, 152.06051635742188, 51.83548355102539, 151.66751098632812, 38.665931701660156, 151.60060119628906, 152.7415313720703, 51.886207580566406, 153.15924072265625, 51.88606643676758, 153.16085815429688, 38.81463623046875, 36.11669921875, 62.634368896484375, 77.99734497070312, 187.94322204589844, 189.19671630859375, 38.08533477783203]

Lots of noise here. Lucky for us, the bpmdetect plugin uses an external library (soundtouch) to do the calculation, and has a utility program that outputs BPM. So, I convert the same file to wav, and then run "soundstretch output.wav -bpm" to see what I get:

Detected BPM rate 157.7

From this result, I suspect what the real problem is that the soundtouch library expects to get the whole file, whereas GStreamer is calling getBpm() every time transform_ip() is called (eg, when a new buffer comes in). Is there a way to force the bpmdetect plugin to process the entire file, as opposed to just a few buffers here and there?
Comment 6 Kyrylo V. Polezhaiev 2015-08-16 22:13:02 UTC
For our case we had to implement our own version without libSoundTouch.
Let's decide how the element should work and get rid of this dependency at all.
Comment 7 Dustin Spicuzza 2015-08-16 23:40:49 UTC
Well, my point was that the problem wasn't libsoundtouch, but rather the way that gst is using it. 

BUT. I found a legit bug.

There's something wonky about the way the plugin is mixing the channels when it does the memcpy. If I use a capsfilter to mix it down to a single channel before the bpmdetect plugin, then it returns results that match the output of 'soundstretch output.wav -bpm'.

I looked at it, and it seemed fine to me. Probably a padding problem or some mismatch between the buffer gst is sending and what libsoundtouch is expecting.

The workaround is good enough for me (though it would be good to fix this!), I've updated the gist with it.
Comment 8 GStreamer system administrator 2018-11-03 13:36:38 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/263.