Liquidsoap
Encyclopedia
Liquidsoap is an audio programming language
Audio programming language
An audio programming language is a programming language specifically optimized for sound and music production or sound synthesis. Some of the languages below are optimized more for music composition, and some are optimized more for synthesis...

 developed initially to produce audio and video source streams
Data stream
In telecommunications and computing, a data stream is a sequence of digitally encoded coherent signals used to transmit or receive information that is in the process of being transmitted....

 sent to an Icecast
Icecast
Icecast is a streaming media project released as free software maintained by the Xiph.org Foundation. It also refers specifically to the server program which is part of the project. Icecast was created in December 1998/January 1999 by Jack Moffitt and Barath Raghavan to provide an open source...

 server
Server (computing)
In the context of client-server architecture, a server is a computer program running to serve the requests of other programs, the "clients". Thus, the "server" performs some computational task on behalf of "clients"...

. 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
Sound card
A sound card is an internal computer expansion card that facilitates the input and output of audio signals to and from a computer under control of computer programs. The term sound card is also applied to external audio interfaces that use software to generate sound, as opposed to using hardware...

 or to output multimedia data to local files using various formats
Codec
A codec is a device or computer program capable of encoding or decoding a digital data stream or signal. The word codec is a portmanteau of "compressor-decompressor" or, more commonly, "coder-decoder"...

. 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
GNU General Public License
The GNU General Public License is the most widely used free software license, originally written by Richard Stallman for the GNU Project....

 (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

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
    Type inference
    Type inference refers to the automatic deduction of the type of an expression in a programming language. If some, but not all, type annotations are already present it is referred to as type reconstruction....

    : 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

In the Liquidsoap language, audio and video streams
Data stream
In telecommunications and computing, a data stream is a sequence of digitally encoded coherent signals used to transmit or receive information that is in the process of being transmitted....

 are represented by variables
Variable (programming)
In computer programming, a variable is a symbolic name given to some known or unknown quantity or information, for the purpose of allowing the name to be used independently of the information it represents...

. 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
Metadata
The term metadata is an ambiguous term which is used for two fundamentally different concepts . Although the expression "data about data" is often used, it does not apply to both in the same way. Structural metadata, the design and specification of data structures, cannot be about data, because at...

 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
JACK Audio Connection Kit
JACK is a professional sound server daemon that provides real-time, low latency connections for both audio and MIDI data between applications that implement its API...

, 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

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:
  1. A function to apply to each metadata

def f(m) =
(.. Some operations on m ..)
end
  1. Redefine s and apply f
  2. to every metadata

s = on_metadata(f, s)

Dynamic

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.
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK