Liquidsoap

From ActiveArchives
Jump to: navigation, search

Liquidsoap is a domain-specific programming language to create radio streams. The system is itself implemented in OCAML, a function programming language with particular emphasis to dependability.

http://liquidsoap.info

Liquidsoap provides several operators for playing requests: single, playlist and playlist.safe, request.dynamic, request.queue and request.equeue. In a few cases (single with a local file, or playlist.safe) a request operator will know that it can always get a ready request instantaneously. It will then be infallible. Otherwise, it will have a queue of requests ready to be played (local files with a valid content), and will feed this queue in the background. This process is described here.
http://liquidsoap.fm/doc-svn/request_sources.html

Contents

Versions

It's important to check the documentation of the version of liquidsoap that you're actually running!

As of November 2014, Debian Stable (aka "wheezy" or version 7.7) has packages for liquidsoap 1.0.1

  • 1.0.1 Debian stable
  • 1.1.1 Debian testing
  • SVN Latest liquidsoap version / "development"

Documentation links

Hello world

You can run liquidsoap directly from the commandline:

liquidsoap 'out(single("aintmisbehavin.ogg"))'

Or put your commands in a script file:

# set("log.stdout",true)
set("log.file", false)
out(single("aintmisbehavin.ogg"))

NB: when running a script, LS wants to log in /var/log/liquidsoap and will fail when running non-root. So you need to switch of the log.file option (and optionally switch on logging to stdout.

Video

http://savonet.sourceforge.net/doc-svn/video.html

Building blocks

Source/Inputs

file sources

  • single
single("monday.wav")
  • playlist

A list of URIs to play (optionally in random order)

playlist("daysofweek.pls")

playlist supports different "modes" that allow for shuffling

mode (string – defaults to "randomize"): Play the files in the playlist either in the order (“normal” mode), or shuffle the playlist each time it is loaded, and play it in this order for a whole round (“randomize” mode), or pick a random file in the playlist each time (“random” mode).

generative sources

  • blank (silence)
  • noise
  • saw, sine, square
(amplitude, duration) frequency

duration defaults 0, which means infinite

Language

Finally getting used to the fact that there are no dictionary / hashes... just pairs and lists, of then primitive types, bool, float, int, string.

For example, [(1,"un"),(2,"deux")] has type [(int*string)].

So in the description of the on_metadata function:

([(string*string)])->unit

Means a function that takes a list of string pairs (ie a kind of associative array, but an ordered one).

So to print all the metadata...

Composition

  • sequence

hmm, strange thing is that the final element is held in a sequence (rotate is a repeating sequence that starts over)

  • rotate
out(
   rotate(
       [square(220.0,amplitude=0.02,duration=1.0),
       sine(440.0,amplitude=0.02,duration=1.0)]
   )
)
  • random
  • fallback
  • switch
At the beginning of a track, select the first source whose predicate is true.

Time Intervals

http://liquidsoap.fm/doc-svn/language.html

Time intervals can be either of the form DATE-DATE or simply DATE. Their meaning should be intuitive: 10h-10h30 is valid everyday between 10:00 and 10:30; 0m is valid during the first minute of every hour.

switch([
 ({ 20h-22h30 }, prime_time),
 ({ 1w }, monday_source),
 ({ (6w or 7w) and 0h-12h }, week_ends_mornings),
 ({ true }, default_source)
])

Seeking/Cutting/Cueing

http://savonet.sourceforge.net/doc-svn/seek.html

Part of liquidsoap 1.0.0

cue_cut

cue_cut(?id:string,?cue_in_metadata:string, ?cue_out_metadata:string,source(audio='#a,video='#b,midi='#c)) ->source(audio='#a,video='#b,midi='#c)

s = playlist(prefix="annotate:liq_cue_in=\"10.\",liq_cue_out=\"45\":","/path/to/music")
s = cue_cut(s)

What links here

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox