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

bpm throws Error 4: Undefined variable bpm #3527

Closed
Mikulskii opened this issue Nov 13, 2023 · 4 comments
Closed

bpm throws Error 4: Undefined variable bpm #3527

Mikulskii opened this issue Nov 13, 2023 · 4 comments

Comments

@Mikulskii
Copy link

Took an example from The Liquidsoap Book, but it doesn't work:

s = mksafe(playlist("..."))
s = bpm(s)
thread.run(every=1., {print("BPM: #{s.bpm()}")})
output(s)

Output:

At bpm.liq, line 2, char 4-8:
s = bpm(s)

Error 4: Undefined variable bpm

lufs and rms are working properly. Tried on versions 2.1.2 and 2.2.2 - Windows & Ubuntu(via opam)

@Mikulskii Mikulskii changed the title bpm throws Error 4: Undefined variable bpm bpm throws Error 4: Undefined variable bpm Nov 13, 2023
@rrolla
Copy link
Contributor

rrolla commented Nov 13, 2023

Hey @Mikulskii looks like s object is modified if you call it directly on real source

try like this

musicSource = mksafe(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=5.0, (fun() -> begin detectBpm() {} end))
end

def onMetadataHandler(metadata)
    startDetectBpm()
end

musicSource.on_metadata(onMetadataHandler)

And look whats happened on track change, maybe for you also always return 0
see #2871

@Mikulskii
Copy link
Author

Hey @rrolla !
Strangely, I get the same error

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

Error 4: Undefined variable bpm

@vitoyucepi
Copy link
Collaborator

Hi @Mikulskii,
Have you installed liquidsoap via opam in windows and ubuntu?
Can you list all installed opam packages with opam list?
I think the bpm function depends on soundtouch.

@Mikulskii
Copy link
Author

Hi @vitoyucepi! Ah, that's the thing.
I installed soundtouch and the case moved forward. Thanks!
opam is only on Ubuntu.

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

3 participants