savonet / liquidsoap

Liquidsoap is a statically typed scripting general-purpose language with dedicated operators and backend for all thing media, streaming, file generation, automation, HTTP backend and more.
http://liquidsoap.info
GNU General Public License v2.0
1.41k stars 130 forks source link

Fades don't appear to be working v1.4.4 #1553

Open thespicer21 opened 3 years ago

thespicer21 commented 3 years ago

Hey guys,

My .liq is below, I'm trying to add both fade in and out on live connections. I think I may have the fades formatted for the older version of ls as they are being ignored. Can somebody point me in the right direction for making them compatible with v1.4.4 please?

#!/home/debian/.opam/4.08.0/bin/liquidsoap/

# Log dir
set("log.file.path","/tmp/radio.log")

# Define The Mountpoints
ices = mksafe(input.http("http://127.0.0.1:8000/ices"))
live = input.http("http://127.0.0.1:8000/live")

# Playout Priority
radio = fallback(track_sensitive=false, [live,ices])

# Stream Processing                                                                                                                                           $
live = fade.out(duration=4.,live)
live = fade.in(duration=1.,live)

# Output
output.icecast(
  %mp3(bitrate=192),
  host="127.0.0.1",
  port=8000,
  password="kLDsty8sUs2c",
  description="test",
  url="https://test.com",
  mount="test",
  name="test",
  radio
)

# Dummy output for server http (stop overruns)                                                                                                                $
output.dummy(fallible=true, ices)
martinkirch commented 3 years ago

Hello,

Be careful, you just published a clear password.

fade.out would not help here, because it fades out only when detecting the end of a track, but that's unlikely to happen from a stream. I guess you can re-use transition function (for fallback) I proposed in https://github.com/savonet/liquidsoap/issues/1548#issuecomment-806164551

xorinzor commented 3 years ago

You might perhaps be able to use something like this (untested). Assuming the input stream updates their metadata. However if they update their metadata before or after the transition took place, it will also offset your fade effect.

s = ref(live)

def call_fade()
    s := fade.out(duration=4., !s)
    s := fade.in(duration=1., !s)
end

source.on_metadata(!s, (fun(m) -> call_fade))

Additionally, I'm pretty sure the fade.out and fade.in effect will take place at the same time when used like this, most likely not giving you the effect you are looking for.

Have a look at how they implemented it in the crossfade function for how you could implement a similar thing: https://github.com/savonet/liquidsoap/blob/main/libs/fades.liq#L272