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

How to use bpm sound processing function? #467

Closed
rrolla opened this issue Aug 5, 2017 · 1 comment
Closed

How to use bpm sound processing function? #467

rrolla opened this issue Aug 5, 2017 · 1 comment

Comments

@rrolla
Copy link
Contributor

rrolla commented Aug 5, 2017

Hello, i read api reference http://savonet.sourceforge.net/doc-svn/reference.html#bpm

bpm(?id:string,?every:float,((float)->unit),
 source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c)

but cannot understand how to use it.

my goal is to log currentBpm in liquidsoap log.

here my script fragment

def show_bpm(currentBpm) =
  log(currentBpm)
end

# Music
songs = playlist("~/radio/music.m3u")

security = single("say:Hello, this is G-radio \
                     We are currently having some \
                     technical difficulties but we'll \
                     be back soon so stay tuned!")

s = fallback(track_sensitive = false, [songs, security])

s = bpm(every=1., show_bpm , s)

s = smart_crossfade(s)
s = amplify(1.,override="replay_gain", s)

error message, line 40 is where bpm function starts

At line 40, char 24:
  this value has type
    (string,...)->_ (inferred at line 17 char 1 - line 19 char 3)
  but it should be a subtype of
    (float,...)->_

Thanks

@toots
Copy link
Member

toots commented Aug 7, 2017

Hi @djbeater !

The typing system is getting in you way.. :-)

The BPM is a floating number, something like 2.3, etc. liquidsoap is being specific about the type of data it passes around and the log function only takes string values, something like: "2.3" etc.

You can convert float into strings in at least two ways:

  • Call string_of
  • Use the #{...} interpolation syntax.

Here's a solution with the first one:

def show_bpm(currentBpm) =
  log(string_of(currentBpm))
end

@toots toots closed this as completed Aug 7, 2017
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