Quantcast
Channel: Airtime Support Discussions on Sourcefabric Forum
Viewing all articles
Browse latest Browse all 1390

How to Crossfade

$
0
0
Hello,

This is a small tutorial on how to crossfade with liquidsoap. I have muddled around for almost a week before figuring this out. Perhaps this will help someone in the future. Tested on Airtime 2.1.3

Add the following lines to your /usr/lib/airtime/pypo/bin/liquidsoap_scripts/ls_script.liq just under the line "%include "ls_lib.liq""

def my_fade (~start_next=3.,~fade_in=3.,~fade_out=3.,~width=1.,~conservative=true,s)
mf_high = 20.

mf_medium = 32.

mf_margin = 4.

fade.out = fade.out(duration=fade_out)
fade.in = fade.in(duration=fade_in)

add = fun (from,to) ->
add(normalize=false,

[ to,from ])


log = log(label="my_fade")
def transition (a, b, ma, mb, sa, sb)

if


(a + mf_high >= 0. and b + mf_high >= 0.) or


(a + mf_medium >= 0. and b + mf_medium >= 0. and abs(a - b) <= mf_margin)


then


log("No transition, just sequencing.")


sequence([sa, sb])



elsif


a + mf_medium <= 0. and b + mf_medium >= 0. and abs(a - b) <= mf_margin


then


log("Using transition 1: crossed.")


add(fade.out(sa),fade.in(sb))

elsif

b >= a + mf_margin and a <= mf_high


then


log("Using transition 2: crossed, fade-out.")


add(fade.out(sa),sb)

elsif

a >= b + mf_margin and b <= mf_high


then


log("Using transition 3: crossed, fade-in.")


add(sa,fade.in(sb))

else

log("Using transition 4: crossed, fade-in, fade-out.")


add(fade.out(sa),fade.in(sb))


end


end

smart_cross(transition,width=width,duration=start_next,conservative=conservative,s)

end


now look for the line  "queue = map_metadata(append_title, queue)"
and add this line under it:

queue = my_fade(queue)

Thats it. Restart your server or the playout service with

sudo service airtime-playout restart

Crossfading should now work based on the values of: ~start_next=3.,~fade_in=3.,~fade_out=3.,~width=1
You may edit these values to suit your needs. The script uses a smart crossfade by checking the relative volumes of the current track and the next track and applies an effect accordingly.

I have not written this script. It was taken from the dolebrai script which I found on the liquidsoap site.

Viewing all articles
Browse latest Browse all 1390

Trending Articles