liquidsoap cue and crossfade metadata

big balls of mud killer
, in 09 May 2016

You can easily control cue and crossfade points per song in liquidsoap using metadata via the annotate protocol. Namely there are 4 variables you can pass as metadata, liq_fade_in, liq_fade_out, liq_cue_in, and liq_cue_out. These do what you would expect.

However, you can also use the annotate protocol even if you aren’t using a textfile playlist. If you are using request.dynamic you can pass a string containing the annotate metadata to request.create.


You have to use some operators on your source to actually get the crossfades and fades to apply however. You’ll need cue_cut and one of the crossfade operators (crossfade or smart_crossfade).

Assuming you have assigned a playlist or request.dynamic source to backup_playlist:

source = cue_cut(backup_playlist)
source = crossfade(backup_playlist)

This opens up quite a few possibilities in my mind. For example you could assign per-track fades or cue points in a database, fetch them via an API or similar in liquidsoap and use the annotate protocol with request.dynamic to have per track fades/cuepoints.

I’m using something like this in my own project right now, where I get all the information for the next track, including fade and cue points, via an external ruby script:

result = list.hd(get_process_lines("rbenv exec bundle exec ruby ./next_song.rb"))
json = of_json(default=[("error","fail")], result)
track = json["track"]
cue_in = int_of_string(json["cue_in"])
cue_out = int_of_string(json["cue_out"])
fade_in = int_of_string(json["fade_in"])
fade_out = int_of_string(json["fade_out"])
annotate_line = "annotate:liq_fade_in=#{fade_in},liq_fade_out=#{fade_out},liq_cue_in=#{cue_in},liq_cue_out=#{cue_out}:/home/liquidsoap/tracks/#{track}"

Modern Online Radio with Liquidsoap Book - Free Sample

Need more help with liquidsoap? Can’t get your script to work?

I wrote a book to help you learn Liquidsoap. The book covers all aspects of liquidsoap, from getting started, to making dynamic streams, audio processing, video, customizing metadata, authentication, and more. The book is available for purchase now here!

You can get a free sample chapter of my book! Just enter your email address to subscribe to my mailing list and I'll send you a free PDF sample of the book in return.