Liquidsoap

From Wikipedia, the free encyclopedia
Jump to: navigation, search
Liquidsoap
Liquidsoap logo
Developer(s) The Savonet Team
Initial release 2003
Stable release 1.1.1 / May 8, 2013; 13 months ago (2013-05-08)
Development status Active
Written in OCaml
Operating system Unix, Linux, Microsoft Windows and Mac OS X.
Type Streaming media
License GPL
Website http://liquidsoap.fm/

Liquidsoap is an audio programming language developed initially to produce audio and video source streams sent to an Icecast server. The difference with other available tools is that Liquidsoap interprets a dedicated script language, which makes it very versatile and adaptable to a lot of various usages.

The recent releases of Liquidsoap also include the possibility to interact with the local sound card or to output multimedia data to local files using various formats. Thus, Liquidsoap is not only a source client for Icecast, but a general purpose specialized audio language dedicated to the automation of audio and video processing and streaming.

Liquidsoap is released under the GNU General Public License (GPL), is part of the Savonet project, and is developed in OCaml. The Savonet project also provides OCaml modules used for the various features supported by Liquidsoap.

Design[edit]

Describing an audio stream can be very complex: several inputs (files, stream relaying, sound card input) that can be combined in various ways (audio processing, mixing, track scheduling, fall-backs) and finally be output in various other ways (several servers, contents and formats). To make it easy without losing expressive power, Liquidsoap uses its own little scripting language for configuration.

That language has a notion of audio stream and request, and has built-in functions for combining streams in various ways. Some of its main features are:

  • It is statically typed: your stream never crashes because you made a typo in a dark corner of the configuration.
  • Types are inferred: you don’t have to write them.
  • It is functional: you can define your own compound operations, but functions are also used to describe transitions from one stream to another.

Streams[edit]

A stream in Liquidsoap

In the Liquidsoap language, audio and video streams are represented by variables. However, a stream is an infinite object, hence streams variable in Liquidsoap cannot be directly manipulated. Instead, they are processed through operators that wrap operations around them.

Additionally, a stream is a high-order object that represents an infinite sequence of audio or video data samples but also metadata and breaks which represent tracks limits.

For example, a stream can be defined from an external audio stream the following way:

 
s = input.http("http://server.org:8000/stream")

Later, if the user wants to apply a volume change to this stream, he uses the amplify() operator:

 
s = amplify(2.0, s)

This code redefines the source s. The new source now has an amplification process applied to it, which will take the data from the original source, apply the amplification to it and pass it to the new source.

Eventually, the stream is passed to an output, which can be either a local output, to the sound card, a JACK server, a file, etc.., or an output to a distant server such as an Icecast server:

output.icecast.vorbis(host="server.org",mount="my_radio", s)

A functional language[edit]

The Liquidsoap language is a functional language. Hence, functions can be used as variables. In particular, since streams are infinite objects, the only way to apply an operation on every element of the stream is to define a generic function that is applied to each element once it is generated.

For instance, you can define an operation on each metadata carried by the stream:

# A function to apply to each metadata
def f(m) =
  (.. Some operations on m ..)
end
 
# Redefine s and apply f
# to every metadata
s = on_metadata(f, s)

Dynamic[edit]

A graph generated by a script

When executing a script, Liquidsoap parses each operators and definitions. From these objects, it generates an oriented graph of operators whose roots are the sources and leafs the outputs.

This graph is executed on the reverse order: for each output, Liquidsoap asks for a complete frame of data. Then the output propagates this to the nodes below it, up to the roots of the graph where the source fills the frame.

During this execution, the same frame object is passed to each operators in the graph, allowing a minimal number of copies of the audio and video data, which is important to maintain a correct efficiency.

External links[edit]