Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Looks like bpm operator is broken #2871

Closed
rrolla opened this issue Jan 29, 2023 · 4 comments
Closed

Looks like bpm operator is broken #2871

rrolla opened this issue Jan 29, 2023 · 4 comments

Comments

@rrolla
Copy link
Contributor

rrolla commented Jan 29, 2023

Describe the bug
BPM operator https://www.liquidsoap.info/doc-2.1.3/reference.html#bpm always return 0., looks like with some version upgrade this is broken

To Reproduce

musicSource = playlist(id="musicSource", "/mnt/test/bpm")

musicSourceBpm = bpm(id="bpm", musicSource)

def detectBpm()
    metadata = musicSource.last_metadata() ?? []
    title = "#{metadata['artist']} - #{metadata['title']}"
    bpm = musicSourceBpm.bpm()
    bpmWithTitle = "BPM: #{string_of(int_of_float(bpm))} #{title}"
    print(bpmWithTitle)
end

def startDetectBpm()
    thread.run(delay=20.0, (fun() -> begin detectBpm() {} end))
end

def onMetadataHandler(metadata)
    startDetectBpm()
end

musicSource.on_metadata(onMetadataHandler)

returns

BPM: 0 Dj Gollum × Empyre One - Supernova (Original Mix)

Expected behavior
after calling detectBpm it should return BPM instead of 0

Version details

  • OS: Debian
  • Version 2.1.3

Also checked plugins on liquidsoap installation, looks ok:

liquidsoap --list-plugins | grep bpm
 + bpm
  Detect the BPM (number of beats per minute). The returned source has a method `bpm`, which can be called to compute it.
   + bpm
 ?bpm : float?, ?ms : int?, ?hz : float?,
   set timing. (default: 2, possible values: 0 (bpm), 1 (ms), 2 (hz))
  + bpm
 ?bpm : float?, ?ms : int?, ?hz : float?,
   set timing. (default: 2, possible values: 0 (bpm), 1 (ms), 2 (hz))
  + bpm
liquidsoap --list-plugins | grep soundtouch
 + soundtouch

Install method
Via deb package 2.1.3-debian-bullseye-1_amd64.deb

Other issue
If I call bpm directly on musicSource instead add to new variable musicSourceBpm
eg

musicSourceBpm = bpm(id="bpm", musicSource)
# instead musicSourceBpm = bpm(id="bpm", musicSource)

the metadata is stripped out from musicSource

@toots toots closed this as completed in 4e3e281 Jan 30, 2023
@toots
Copy link
Member

toots commented Jan 30, 2023

Hi,

Is the source connected to an output? You need to be actively pulling data from it to generate stats. At the very lease you should add:

output.dummy(musicSourceBpm)

I just confirmed that the operator is at least working on main and added a regression test for it. Please re-open if you still see an issue in your own version with an output added.

@rrolla
Copy link
Contributor Author

rrolla commented Jan 31, 2023

Hi,

Is the source connected to an output? You need to be actively pulling data from it to generate stats. At the very lease you should add:

output.dummy(musicSourceBpm)

I just confirmed that the operator is at least working on main and added a regression test for it. Please re-open if you still see an issue in your own version with an output added.

Hey @toots yes that source is connected to output, glad that you added tests, so you will suggest to try on Rolling Release 2.1.x?

@toots
Copy link
Member

toots commented Jan 31, 2023

Confirmed also working on 2.1.x. The reported BPM is 60., which is what the metronome source is set to.

@toots
Copy link
Member

toots commented Jan 31, 2023

Could be that the BPM algorithm is failing on your content, tho. It will for instance report 0. on a sine waveform or noise source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants