Liquidsoap dev : Language reference

Liquidsoap scripting language reference

Categories

The Source / ... categories contain all functions that return sources. The Input functions are those which build elementary sources (playing files, synthesizing sound, etc.). The Output functions are those which take a source and register it for being streamed to the outside (file, soundcard, audio server, etc.). The Visualization functions are experimental ones that let you visualize in real-time some aspects of the audio stream. The Sound Processing functions are those which basically work on the source as a continuous audio stream. They would typically be mixers of streams, audio effects or analysis. Finally, Track Processing functions are basically all others, often having a behaviour that depends on or affects the extra information that liquidsoap puts in streams: track limits and metadata.

Source / Conversions

audio_to_stereo
(?id:string,source(audio=*+1,video=0,midi=0))->
source(audio=2,video=0,midi=0)

Convert any kind of audio source into a stereo source.

drop_audio
(?id:string,source(audio='#a,video='#b,midi='#c))->
source(audio=0,video='#b,midi='#c)

Drop all audio channels of a stream.

drop_midi
(?id:string,source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi=0)

Drop all midi channels of a stream.

drop_video
(?id:string,source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video=0,midi='#c)

Drop all video channels of a stream.

id
(?id:string,source('a))->source('a)

Does not do anything, simply forwards its input stream.

mean
(?id:string,source(audio='#a,video='#b,midi='#c))->
source(audio=1,video='#b,midi='#c)

Produce mono audio by taking the mean of all audio channels.

mux_audio
(?id:string,audio:source(audio='#a,video=0,midi=0),
 source(audio=0,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c)

Mux an audio stream into an audio-free stream.

mux_mono
(?id:string,mono:source(audio=1,video=0,midi=0),
 source(audio='#a,video='#b,midi='#c))->
source(audio='#a+1,video='#b,midi='#c)

Mux a mono audio stream into another stream.

mux_stereo
(?id:string,stereo:source(audio=2,video=0,midi=0),
 source(audio='#a,video='#b,midi='#c))->
source(audio='#a+2,video='#b,midi='#c)

Mux a stereo audio stream into another stream.

mux_video
(?id:string,video:source(audio=0,video='#a,midi=0),
 source(audio='#b,video=0,midi='#c))->
source(audio='#b,video='#a,midi='#c)

Add video channnels to a stream.

stereo.left
(source(audio=2,video=0,midi=0))->
source(audio=1,video=0,midi=0)

Extract the left channel of a stereo source

stereo.right
(source(audio=2,video=0,midi=0))->
source(audio=1,video=0,midi=0)

Extract the right channel of a stereo source

swap
(?id:string,source(audio=2,video=0,midi=0))->
source(audio=2,video=0,midi=0)

Swap two channels of a stereo source.

Source / Input

blank
(?id:string,?duration:float)->source('a)

Produce silence and blank images.

empty
(?id:string)->source(audio='a,video='b,midi='c)

A source that does not produce anything. No silence, no track at all.

fail
(?id:string)->source('b)

Creates a source that fails to produce anything.

in
(?id:string,?start:bool,?on_start:(()->unit),
 ?on_stop:(()->unit),?fallible:bool)->
active_source(audio='#a+1,video=0,midi=0)

Create a source from the first available input driver in pulseaudio, portaudio, oss, alsa, blank.

input.external
(?id:string,?buffer:float,?channels:int,?max:float,
 ?restart:bool,?restart_on_error:bool,?samplerate:int,
 string)->source(audio='#a+1,video=0,midi=0)

Stream data from an external application.

input.external.avi
(?id:string,?buffer:float,?max:float,?restart:bool,
 ?restart_on_error:bool,string)->
source(audio='#a,video='#b,midi=0)

WARNING: This is only EXPERIMENTAL!

Stream data from an external application.

input.external.rawvideo
(?id:string,?buffer:float,?max:float,?restart:bool,
 ?restart_on_error:bool,string)->
source(audio=0,video=1,midi=0)

WARNING: This is only EXPERIMENTAL!

Stream data from an external application.

input.ffmpeg.video
(?id:string,?restart:bool,?restart_on_error:bool,
 ?buffer:float,?max:float,?format:string,string)->
source(audio='#a,video='#b,midi=0)

No documentation available.

input.harbor
(?id:string,?auth:((string,string)->bool),?buffer:float,
 ?debug:bool,?dumpfile:string,?icy:bool,
 ?icy_metadata_charset:string,?logfile:string,?max:float,
 ?metadata_charset:string,
 ?on_connect:(([(string*string)])->unit),
 ?on_disconnect:(()->unit),?password:string,?port:int,
 ?replay_metadata:bool,?timeout:float,?user:string,
 string)->source('a)

Retrieves the given http stream from the harbor.

input.harbor.ssl
(?id:string,?auth:((string,string)->bool),?buffer:float,
 ?debug:bool,?dumpfile:string,?icy:bool,
 ?icy_metadata_charset:string,?logfile:string,?max:float,
 ?metadata_charset:string,
 ?on_connect:(([(string*string)])->unit),
 ?on_disconnect:(()->unit),?password:string,?port:int,
 ?replay_metadata:bool,?timeout:float,?user:string,
 string)->source('a)

Retrieves the given https stream from the harbor.

input.http
(?id:string,?autostart:bool,?bind_address:string,
 ?buffer:float,?debug:bool,?force_mime:string,
 ?logfile:string,?max:float,?new_track_on_metadata:bool,
 ?on_connect:(([(string*string)])->unit),
 ?on_disconnect:(()->unit),?playlist_mode:string,
 ?poll_delay:float,?timeout:float,?user_agent:string,
 string)->source('a)

Forwards the given http stream. The relay can be paused/resumed using the start/stop telnet commands.

input.https
(?id:string,?autostart:bool,?bind_address:string,
 ?buffer:float,?debug:bool,?force_mime:string,
 ?logfile:string,?max:float,?new_track_on_metadata:bool,
 ?on_connect:(([(string*string)])->unit),
 ?on_disconnect:(()->unit),?playlist_mode:string,
 ?poll_delay:float,?timeout:float,?user_agent:string,
 string)->source('a)

Forwards the given https stream. The relay can be paused/resumed using the start/stop telnet commands.

input.keyboard.sdl
(?id:string,?velocity:float)->
source(audio='#a,video=0,midi='#b+1)

WARNING: This is only EXPERIMENTAL!

Play notes from the keyboard.

input.mencoder.video
(?id:string,?restart:bool,?restart_on_error:bool,
 ?buffer:float,?max:float,string)->
source(audio=0,video=1,midi=0)

No documentation available.

input.mplayer
(?id:string,?restart:bool,?restart_on_error:bool,
 ?buffer:float,?max:float,string)->
source(audio='#a+1,video=0,midi=0)

Stream data from mplayer

input.oss
(?id:string,?clock_safe:bool,?device:string,
 ?fallible:bool,?on_start:(()->unit),?on_stop:(()->unit),
 ?start:bool)->active_source(audio='#a+1,video=0,midi=0)

Stream from an OSS input device.

input.udp
(?id:string,?buffer:float,host:string,port:int,string)->
active_source('a)

WARNING: This is only EXPERIMENTAL!

Input encoded data from UDP, without any control whatsoever.

noise
(?id:string,?duration:float)->
source(audio='a,video='b,midi=0)

Generate (audio and/or video) white noise.

playlist
(?id:string,?check_next:((request('a))->bool),
 ?conservative:bool,?default_duration:float,
 ?length:float,?mime_type:string,?mode:string,
 ?on_track:((last:bool,int)->bool),?prefix:string,
 ?reload:int,?reload_mode:string,?timeout:float,string)->
source('a)

Loop on a playlist of URIs.

playlist.once
(?id:string,?random:bool,?on_done:(()->unit),
 ?reload_mode:string,string)->source('a)

Custom playlist source written using the script language. It will read directory or playlist, play all files and stop.

playlist.reloadable
(?id:string,?random:bool,?on_done:(()->unit),
 ?filter:(([(string*string)])->bool),string)->
(((?uri:string)->unit)*source('a))

Custom playlist source written using the script language. Will read directory or playlist, play all files and stop. Returns a pair (reload,source) where reload is a function of type (?uri:string)->unit used to reload the source and source is the actual source. The reload function can optionally be called with a new playlist URI. Otherwise, it reloads the previous URI.

playlist.safe
(?id:string,?mime_type:string,?mode:string,
 ?on_track:((last:bool,int)->bool),?prefix:string,
 ?reload:int,?reload_mode:string,string)->source('a)

Loop on a playlist of local files, and never fail. In order to do so, it has to check every file at the loading, so the streamer startup may take a few seconds. To avoid this, use a standard playlist, and put only a few local files in a default safe_playlist in order to ensure the liveness of the streamer.

request.dynamic
(?id:string,?conservative:bool,?default_duration:float,
 ?length:float,?timeout:float,(()->request('a)))->
source('a)

Play request dynamically created by a given function.

request.equeue
(?id:string,?conservative:bool,?default_duration:float,
 ?length:float,?timeout:float)->source('a)

Receive URIs from users, and play them. Insertion and deletion possible at any position.

request.queue
(?id:string,?conservative:bool,?default_duration:float,
 ?interactive:bool,?length:float,?queue:[request('a)],
 ?timeout:float)->source('a)

Receive URIs from users, and play them.

saw
(?id:string,?amplitude:float,?duration:float,?float)->
source(audio='#a+1,video=0,midi=0)

Generate a saw wave.

sine
(?id:string,?amplitude:float,?duration:float,?float)->
source(audio='#a+1,video=0,midi=0)

Generate a sine wave.

single
(?id:string,?conservative:bool,?default_duration:float,
 ?length:float,?timeout:float,string)->source('a)

Loop on a request. It never fails if the request is static, meaning that it can be fetched once. Typically, http, ftp, say requests are static, and time is not.

square
(?id:string,?amplitude:float,?duration:float,?float)->
source(audio='#a+1,video=0,midi=0)

Generate a square wave.

Source / Liquidsoap

buffer
(?id:string,?buffer:float,?fallible:bool,?max:float,
 ?on_start:(()->unit),?on_stop:(()->unit),?start:bool,
 source('a))->source('a)

Create a buffer between two different clocks.

buffer.adaptative
(?id:string,?averaging:float,?buffer:float,
 ?fallible:bool,?limit:float,?max:float,
 ?on_start:(()->unit),?on_stop:(()->unit),?reset:bool,
 ?start:bool,source(audio='#a+1,video=0,midi=0))->
source(audio='#a+1,video=0,midi=0)

WARNING: This is only EXPERIMENTAL!

Create a buffer between two different clocks. The speed of the output is adapted so that no buffer underrun or overrun occurs. This wonderful behavior has a cost: the pitch of the sound might be changed a little.

Source / MIDI Processing

midi.chord
(?id:string,?metadata:string,
 source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c+1)

Generate a chord.

midi.merge_all
(?id:string,?track_out:int,
 source(audio='#a,video='#b,midi='#c+1))->
source(audio='#a,video='#b,midi='#c+1)

Merge all MIDI tracks in one.

midi.remove
(?id:string,[int],source(audio='#a,video='#b,midi='#c+1))->
source(audio='#a,video='#b,midi='#c+1)

Remove MIDI tracks.

Source / Output

out
(source(audio='#a+1,video='#b,midi='#c))->
active_source(audio='#a+1,video='#b,midi='#c)

Output a stream using the 'output.prefered' operator. The input source does not need to be infallible, blank will just be played during failures.

output.dummy
(?id:string,?fallible:bool,?on_start:(()->unit),
 ?on_stop:(()->unit),?start:bool,source('a))->
active_source('a)

Dummy output for debugging purposes.

output.external
(?id:string,?fallible:bool,?flush:bool,
 ?on_start:(()->unit),?on_stop:(()->unit),
 ?reopen_delay:float,?reopen_on_metadata:bool,
 ?reopen_when:(()->bool),?start:bool,format('a),string,
 source('a))->active_source('a)

Send the stream to a process' standard input.

output.file
(?id:string,?append:bool,?dir_perm:int,?fallible:bool,
 ?flush:bool,?on_close:((string)->unit),
 ?on_start:(()->unit),?on_stop:(()->unit),?perm:int,
 ?reopen_delay:float,?reopen_on_metadata:bool,
 ?reopen_when:(()->bool),?start:bool,format('a),string,
 source('a))->active_source('a)

Output the source stream to a file.

output.graphics
(?id:string,?fallible:bool,?on_start:(()->unit),
 ?on_stop:(()->unit),?start:bool,
 source(audio=0,video=1,midi=0))->
active_source(audio=0,video=1,midi=0)

Display video stream using the Graphics library.

output.harbor
(?id:string,?auth:((string,string)->bool),?buffer:int,
 ?burst:int,?chunk:int,?dumpfile:string,?encoding:string,
 ?fallible:bool,?format:string,
 ?headers:[(string*string)],?metaint:int,mount:string,
 ?on_connect:((headers:[(string*string)],uri:string,
               protocol:string,string)->unit),
 ?on_disconnect:((string)->unit),?on_start:(()->unit),
 ?on_stop:(()->unit),?password:string,?port:int,
 ?start:bool,?timeout:float,?url:string,?user:string,
 format('a),source('a))->active_source('a)

Encode and output the stream using the harbor server.

output.harbor.ssl
(?id:string,?auth:((string,string)->bool),?buffer:int,
 ?burst:int,?chunk:int,?dumpfile:string,?encoding:string,
 ?fallible:bool,?format:string,
 ?headers:[(string*string)],?metaint:int,mount:string,
 ?on_connect:((headers:[(string*string)],uri:string,
               protocol:string,string)->unit),
 ?on_disconnect:((string)->unit),?on_start:(()->unit),
 ?on_stop:(()->unit),?password:string,?port:int,
 ?start:bool,?timeout:float,?url:string,?user:string,
 format('a),source('a))->active_source('a)

Encode and output the stream using the SSL harbor server.

output.oss
(?id:string,?clock_safe:bool,?device:string,
 ?fallible:bool,?on_start:(()->unit),?on_stop:(()->unit),
 ?start:bool,source(audio='#a+1,video='#b,midi='#c))->
active_source(audio='#a+1,video='#b,midi='#c)

Output the source's stream to an OSS output device.

output.prefered
(?id:string,?fallible:bool,?on_start:(()->unit),
 ?on_stop:(()->unit),?start:bool,
 source(audio='#a+1,video='#b,midi='#c))->
active_source(audio='#a+1,video='#b,midi='#c)

Output to local audio card using the first available driver in pulseaudio, portaudio, oss, alsa, ao, dummy.

output.sdl
(?id:string,?fallible:bool,?on_start:(()->unit),
 ?on_stop:(()->unit),?start:bool,
 source(audio=0,video=1,midi=0))->
active_source(audio=0,video=1,midi=0)

Display a video using SDL.

output.udp
(?id:string,?fallible:bool,host:string,
 ?on_start:(()->unit),?on_stop:(()->unit),port:int,
 ?start:bool,format('a),source('a))->active_source('a)

WARNING: This is only EXPERIMENTAL!

Output encoded data to UDP, without any control whatsoever.

Source / Sound Processing

add
(?id:string,?normalize:bool,?weights:[int],
 [source(audio='#a,video='#b,midi=0)])->
source(audio='#a,video='#b,midi=0)

Mix sources, with optional normalization. Only relay metadata from the first source that is effectively summed.

amplify
(?id:string,?override:string,'a,
 source(audio='#b,video='#c,midi='#d))->
source(audio='#b,video='#c,midi='#d)
where 'a is either float or ()->float

Multiply the amplitude of the signal.

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

Clip sound.

comb
(?id:string,?delay:float,?feedback:'a,
 source(audio='#b,video='#c,midi='#d))->
source(audio='#b,video='#c,midi='#d)
where 'a is either float or ()->float

Comb filter.

compand
(?id:string,?mu:float,
 source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c)

Compand the signal

compress
(?id:string,?attack:'a,?gain:'b,?knee:'c,?ratio:float,
 ?release:'d,?rms_window:float,?threshold:'e,
 source(audio='#f,video='#g,midi='#h))->
source(audio='#f,video='#g,midi='#h)
where 'a, 'b, 'c, 'd, 'e is either float or ()->float

Compress the signal.

compress.exponential
(?id:string,?mu:float,
 source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c)

Exponential compressor.

cross
(?id:string,?active:bool,?conservative:bool,
 ?duration:float,?inhibit:float,?minimum:float,
 ?override:string,((source('a),source('a))->source('a)),
 source('a))->source('a)

Generic cross operator, allowing the composition of the N last seconds of a track with the beginning of the next track.

echo
(?id:string,?delay:'a,?feedback:'b,?ping_pong:bool,
 source(audio='#c,video='#d,midi='#e))->
source(audio='#c,video='#d,midi='#e)
where 'a, 'b is either float or ()->float

Add echo.

fade.final
(?id:string,?duration:float,?override_duration:string,
 ?override_type:string,?type:string,
 source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c)

Fade a stream to silence.

fade.in
(?id:string,?duration:float,?override_duration:string,
 ?override_type:string,?type:string,
 source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c)

Fade the beginning of tracks.

fade.initial
(?id:string,?duration:float,?override_duration:string,
 ?override_type:string,?type:string,
 source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c)

Fade the beginning of a stream.

fade.out
(?id:string,?duration:float,?override_duration:string,
 ?override_type:string,?type:string,
 source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c)

Fade the end of tracks.

filter
(?id:string,freq:'a,mode:string,?q:'b,?wetness:'c,
 source(audio='#d,video='#e,midi='#f))->
source(audio='#d,video='#e,midi='#f)
where 'a, 'b, 'c is either float or ()->float

Perform several kinds of filtering on the signal

filter.fir
(?id:string,beta:float,?coeffs:int,frequency:float,
 source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c)

Low-pass FIR filter.

filter.iir.butterworth.bandpass
(?id:string,frequency1:float,frequency2:float,?order:int,
 source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c)

IIR filter

filter.iir.butterworth.bandstop
(?id:string,frequency1:float,frequency2:float,?order:int,
 source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c)

IIR filter

filter.iir.butterworth.high
(?id:string,frequency:float,?order:int,
 source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c)

IIR filter

filter.iir.butterworth.low
(?id:string,frequency:float,?order:int,
 source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c)

IIR filter

filter.iir.eq.allpass
(?id:string,?bandwidth:float,frequency:float,
 source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c)

All pass biquad filter.

filter.iir.eq.bandpass
(?id:string,frequency:float,?q:float,
 source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c)

Band pass biquad filter.

filter.iir.eq.high
(?id:string,frequency:float,?q:float,
 source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c)

High pass biquad filter.

filter.iir.eq.highshelf
(?id:string,frequency:float,?slope:float,
 source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c)

High shelf biquad filter.

filter.iir.eq.low
(?id:string,frequency:float,?q:float,
 source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c)

Low pass biquad filter.

filter.iir.eq.lowshelf
(?id:string,frequency:float,?slope:float,
 source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c)

Low shelf biquad filter.

filter.iir.eq.notch
(?id:string,frequency:float,?q:float,
 source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c)

Band pass biquad filter.

filter.iir.eq.peak
(?id:string,frequency:float,?gain:float,?q:float,
 source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c)

Peak EQ biquad filter.

filter.iir.resonator.allpass
(?id:string,frequency:float,?q:float,
 source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c)

IIR filter

filter.iir.resonator.bandpass
(?id:string,frequency:float,?q:float,
 source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c)

IIR filter

filter.iir.resonator.bandstop
(?id:string,frequency:float,?q:float,
 source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c)

IIR filter

filter.rc
(?id:string,mode:string,rc:'a,?wetness:'b,
 source(audio='#c,video='#d,midi='#e))->
source(audio='#c,video='#d,midi='#e)
where 'a, 'b is either float or ()->float

First-order filter (RC filter).

flanger
(?id:string,?delay:float,?feedback:'a,?freq:'b,?phase:'c,
 source(audio='#d,video='#e,midi='#f))->
source(audio='#d,video='#e,midi='#f)
where 'a, 'b, 'c is either float or ()->float

Flanger effect.

limit
(?id:string,?attack:'a,?gain:'b,?knee:'c,?ratio:float,
 ?release:'d,?rms_window:float,?threshold:'e,
 source(audio='#f,video='#g,midi='#h))->
source(audio='#f,video='#g,midi='#h)
where 'a, 'b, 'c, 'd, 'e is either float or ()->float

Limit the signal.

mic_filter
(source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c)

Remove low frequencies often produced by microphones.

mix
(?id:string,[source(audio='#a,video='#b,midi='#c)])->
source(audio='#a,video='#b,midi='#c)

Mixing table controllable via the telnet interface.

normalize
(?id:string,?gain_max:'a,?gain_min:'b,?k_down:'c,
 ?k_up:'d,?target:'e,?threshold:'f,?window:float,
 source(audio='#g,video='#h,midi='#i))->
source(audio='#g,video='#h,midi='#i)
where 'a, 'b, 'c, 'd, 'e, 'f is either float or ()->float

Normalize the signal. Dynamic normalization of the signal is sometimes the only option, and can make a listening experience much nicer. However, its dynamic aspect implies some limitations which can go as far as creating saturation in some extreme cases. If possible, consider using some track-based normalization techniques such as those based on replay gain. See the documentation for more details.

nrj
(source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c)

Compress and normalize, producing a more uniform and “full” sound.

pipe
(?id:string,?buffer:float,?max:float,process:string,
 ?restart:bool,?restart_on_error:bool,
 source(audio='#a+1,video=0,midi=0))->
source(audio='#b+1,video=0,midi=0)

Process audio signal through a given process stdin/stdout.

sky
(source(audio='#a,video='#b,midi=0))->
source(audio='#a,video='#b,midi=0)

Multiband-compression.

smart_cross
(?id:string,?active:bool,?conservative:bool,
 ?duration:float,?minimum:float,?width:float,
 ((float,float,[(string*string)],[(string*string)],
   source(audio='#a+1,video=0,midi=0),
   source(audio='#a+1,video=0,midi=0))->
  source(audio='#a+1,video=0,midi=0)),
 source(audio='#a+1,video=0,midi=0))->
source(audio='#a+1,video=0,midi=0)

Cross operator, allowing the composition of the N last seconds of a track with the beginning of the next track, using a transition function depending on the relative power of the signal before and after the end of track.

stereo.ms.decode
(?id:string,?width:float,source(audio=2,video=0,midi=0))->
source(audio=2,video=0,midi=0)

Decode mid+side stereo (M/S) to left+right stereo.

stereo.ms.encode
(?id:string,source(audio=2,video=0,midi=0))->
source(audio=2,video=0,midi=0)

Encode left+right stereo to mid+side stereo (M/S).

stereo.pan
(?id:string,?field:'a,?pan:'b,
 source(audio=2,video=0,midi=0))->
source(audio=2,video=0,midi=0)
where 'a, 'b is either float or ()->float

Pan a stereo sound.

stretch
(?id:string,?active:bool,ratio:'a,
 source(audio='#b+1,video=0,midi=0))->
source(audio='#c+1,video=0,midi=0)
where 'a is either float or ()->float

Slow down or accelerate an audio stream by stretching (sounds lower) or squeezing it (sounds higher).

Source / Sound Synthesis

synth.all.saw
(?id:string,?attack:float,?decay:float,?envelope:bool,
 ?release:float,?sustain:float,
 source(audio='#a+1,video='#b,midi='#c+16))->
source(audio='#a+1,video='#b,midi='#c+16)

Saw synthesizer. It creates one synthesizer for each channel.

synth.all.sine
(?id:string,?attack:float,?decay:float,?envelope:bool,
 ?release:float,?sustain:float,
 source(audio='#a+1,video='#b,midi='#c+16))->
source(audio='#a+1,video='#b,midi='#c+16)

Sine synthesizer. It creates one synthesizer for each channel.

synth.all.square
(?id:string,?attack:float,?decay:float,?envelope:bool,
 ?release:float,?sustain:float,
 source(audio='#a+1,video='#b,midi='#c+16))->
source(audio='#a+1,video='#b,midi='#c+16)

Square synthesizer. It creates one synthesizer for each channel.

synth.saw
(?id:string,?attack:float,?channel:int,?decay:float,
 ?envelope:bool,?release:float,?sustain:float,
 ?volume:float,source(audio='#a+1,video='#b,midi='#c+1))->
source(audio='#a+1,video='#b,midi='#c+1)

Saw synthesizer.

synth.sine
(?id:string,?attack:float,?channel:int,?decay:float,
 ?envelope:bool,?release:float,?sustain:float,
 ?volume:float,source(audio='#a+1,video='#b,midi='#c+1))->
source(audio='#a+1,video='#b,midi='#c+1)

Sine synthesizer.

synth.square
(?id:string,?attack:float,?channel:int,?decay:float,
 ?envelope:bool,?release:float,?sustain:float,
 ?volume:float,source(audio='#a+1,video='#b,midi='#c+1))->
source(audio='#a+1,video='#b,midi='#c+1)

Square synthesizer.

Source / Track Processing

append
(?id:string,?insert_missing:bool,?merge:bool,source('a),
 (([(string*string)])->source('a)))->source('a)

Append an extra track to every track. Set the metadata 'liq_append' to 'false' to inhibit appending on one track.

at
((()->bool),source('a))->source('a)

Restrict a source to play only when a predicate is true.

crossfade
(?id:string,?conservative:bool,?start_next:float,
 ?fade_in:float,?fade_out:float,
 source(audio='#a,video='#b,midi=0))->
source(audio='#a,video='#b,midi=0)

Simple crossfade.

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)

Start track after a cue in point and stop it at cue out point. The cue points are given as metadata, in seconds from the begining of tracks.

delay
(?id:string,?initial:bool,float,source('a))->source('a)

Prevents the child from being ready again too fast after a end of track

drop_metadata
(source('a))->source('a)

Removes all metadata coming from a source.

eat_blank
(?id:string,?at_beginning:bool,?max_blank:float,
 ?min_noise:float,?start_blank:bool,?threshold:float,
 ?track_sensitive:bool,
 source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c)

Eat blanks, i.e., drop the contents of the stream until it is not blank anymore.

fallback
(?id:string,?replay_metadata:bool,?track_sensitive:'a,
 ?transitions:[(source('b),source('b))->source('b)],
 [source('b)])->source('b)
where 'a is either bool or ()->bool

At the beginning of each track, select the first ready child.

fallback.skip
(input:source('a),source('a))->source('a)

Special track insensitive fallback that always skips current song before switching.

insert_metadata
(?id:string,source('a))->
((([(string*string)])->unit)*source('a))

Dynamically insert metadata in a stream. Returns a pair (f,s) where s is a new source and f is a function of type (metadata)->unit, used to insert metadata in s.

map_metadata
(?id:string,?insert_missing:bool,?strip:bool,
 ?update:bool,(([(string*string)])->[(string*string)]),
 source('a))->source('a)

Rewrite metadata on the fly using a function.

merge_tracks
(?id:string,source('a))->source('a)

Merge consecutive tracks from the input source.

mksafe
(?id:string,source('a))->source('a)

Turn a source into an infaillible source by adding blank when the source is not available.

notify_metadata
(?urgency:string,?icon:string,?time:int,
 ?display:(([(string*string)])->string),?title:string,
 source('a))->source('a)

Use notify to display metadata info.

on_blank
(?id:string,?max_blank:float,?min_noise:float,
 ?on_noise:(()->unit),?start_blank:bool,?threshold:float,
 ?track_sensitive:bool,(()->unit),
 source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c)

Calls a given handler when detecting a blank.

on_end
(?id:string,?delay:float,
 ((float,[(string*string)])->unit),source('a))->
source('a)

Call a given handler when there is less than a given amount of time remaining before then end of track.

on_metadata
(?id:string,(([(string*string)])->unit),source('a))->
source('a)

Call a given handler on metadata packets.

on_offset
(?id:string,?force:bool,?offset:float,?override:string,
 ((float,[(string*string)])->unit),source('a))->
source('a)

Call a given handler when position in track is equal or more than a given amount of time.

on_track
(?id:string,(([(string*string)])->unit),source('a))->
source('a)

Call a given handler on new tracks.

once
(source('a))->source('a)

Creates a source that plays only one track of the input source.

osd_metadata
(?color:string,?position:string,?font:string,
 ?display:(([(string*string)])->string),source('a))->
source('a)

Use X On Screen Display to display metadata info.

overlap_sources
(?id:string,?normalize:bool,?start_next:string,
 ?weights:[int],[source(audio='#a,video='#b,midi=0)])->
source(audio='#a,video='#b,midi=0)

Rotate between overlapping sources. Next track starts according to 'liq_start_next' offset metadata.

playlist.merge
(?id:string,?random:bool,string)->source('a)

Play the whole playlist as one track.

prepend
(?id:string,?merge:bool,
 source(audio='#a,video='#b,midi='#c),
 (([(string*string)])->
  source(audio='#a,video='#b,midi='#c)))->
source(audio='#a,video='#b,midi='#c)

Prepend an extra track before every track. Set the metadata 'liq_prepend' to 'false' to inhibit prepending on one track.

random
(?id:string,?replay_metadata:bool,?track_sensitive:'a,
 ?transitions:[(source('b),source('b))->source('b)],
 ?weights:[int],[source('b)])->source('b)
where 'a is either bool or ()->bool

At the beginning of every track, select a random ready child.

rotate
(?id:string,?replay_metadata:bool,?track_sensitive:'a,
 ?transitions:[(source('b),source('b))->source('b)],
 ?weights:[int],[source('b)])->source('b)
where 'a is either bool or ()->bool

Rotate between the sources.

rotate.merge
(?id:string,?track_sensitive:bool,
 ?transitions:[(source('a),source('a))->source('a)],
 ?weights:[int],[source('a)])->source('a)

Same operator as rotate but merges tracks from each sources. For instance, rotate.merge([intro,main,outro]) creates a source that plays a sequence [intro,main,outro] as single track and loops back.

say_metadata
(source(?A),?pattern:string)->source(?A)

Append speech-synthesized tracks reading the metadata.

sequence
(?id:string,?merge:bool,[source('a)])->source('a)

Play only one track of every successive source, except for the last one which is played as much as available. Sources are released after being used, allowing them to shutdown cleanly and free their resources.

server.insert_metadata
(?id:string,source('a))->source('a)

Register a server/telnet command to update a source's metadata. Returns a new source, which will receive the updated metadata. The command has the following format: insert key1=“val1”,key2=“val2”,...

skip_blank
(?id:string,?threshold:float,?max_blank:float,
 ?min_noise:float,?track_sensitive:bool,
 source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c)

Skip track when detecting a blank.

smart_crossfade
(?start_next:float,?fade_in:float,?fade_out:float,
 ?default:((source(audio='#a+1,video=0,midi=0),
            source(audio='#a+1,video=0,midi=0))->
           source(audio='#a+1,video=0,midi=0)),
 ?high:float,?medium:float,?margin:float,?width:float,
 ?conservative:bool,source(audio='#a+1,video=0,midi=0))->
source(audio='#a+1,video=0,midi=0)

Crossfade between tracks, taking the respective volume levels into account in the choice of the transition.

smooth_add
(?delay:float,?p:float,
 normal:source(audio='#a,video='#b,midi=0),
 special:source(audio='#a,video='#b,midi=0))->
source(audio='#a,video='#b,midi=0)

Mixes two streams, with faded transitions between the state when only the normal stream is available and when the special stream gets added on top of it.

source.dynamic
(?id:string,(()->[source('a)]))->source('a)

WARNING: This is only EXPERIMENTAL!

Dynamically change the underlying source.

store_metadata
(?id:string,?size:int,source('a))->source('a)

Keep track of the last N metadata packets in the stream, and make the history available via a server command.

strip_blank
(?id:string,?max_blank:float,?min_noise:float,
 ?start_blank:bool,?threshold:float,
 ?track_sensitive:bool,
 source(audio='#a,video='#b,midi='#c))->
active_source(audio='#a,video='#b,midi='#c)

Make the source unavailable when it is streaming blank.

switch
(?id:string,?replay_metadata:bool,?single:[bool],
 ?track_sensitive:'a,
 ?transitions:[(source('b),source('b))->source('b)],
 [((()->bool)*source('b))])->source('b)
where 'a is either bool or ()->bool

At the beginning of a track, select the first source whose predicate is true.

Source / Video Processing

video.add_image
(?id:string,?width:int,?height:int,?x:int,?y:int,file:'a,
 source(audio='#b,video='#c,midi=0))->
source(audio='#b,video='#c,midi=0)

Add a static image on the first video channel.

video.add_text
(?id:string,?color:int,?cycle:bool,?font:string,
 ?metadata:string,?size:int,?speed:int,?x:int,?y:int,'a,
 source(audio='#b,video='#c+1,midi='#d))->
source(audio='#b,video='#c+1,midi='#d)
where 'a is either string or ()->string

Add a scrolling line of text on video frames.

video.add_text.gd
(?id:string,?color:int,?cycle:bool,?font:string,
 ?metadata:string,?size:int,?speed:int,?x:int,?y:int,'a,
 source(audio='#b,video='#c+1,midi='#d))->
source(audio='#b,video='#c+1,midi='#d)
where 'a is either string or ()->string

Display a text (using the SDL library).

video.add_text.sdl
(?id:string,?color:int,?cycle:bool,?font:string,
 ?metadata:string,?size:int,?speed:int,?x:int,?y:int,'a,
 source(audio='#b,video='#c+1,midi='#d))->
source(audio='#b,video='#c+1,midi='#d)
where 'a is either string or ()->string

Display a text (using the SDL library).

video.fade.final
(?id:string,?duration:float,?transition:string,
 ?type:string,source(audio='#a,video='#b+1,midi='#c))->
source(audio='#a,video='#b+1,midi='#c)

Fade a stream to black.

video.fade.in
(?id:string,?duration:float,?override:string,
 ?transition:string,?type:string,
 source(audio='#a,video='#b+1,midi='#c))->
source(audio='#a,video='#b+1,midi='#c)

Fade the beginning of tracks. Metadata 'liq_video_fade_in' can be used to set the duration for a specific track (float in seconds).

video.fade.initial
(?id:string,?duration:float,?transition:string,
 ?type:string,source(audio='#a,video='#b+1,midi='#c))->
source(audio='#a,video='#b+1,midi='#c)

Fade the beginning of a stream.

video.fade.out
(?id:string,?duration:float,?override:string,
 ?transition:string,?type:string,
 source(audio='#a,video='#b+1,midi='#c))->
source(audio='#a,video='#b+1,midi='#c)

Fade the end of tracks. Metadata 'liq_video_fade_out' can be used to set the duration for a specific track (float in seconds).

video.fill
(?id:string,?color:int,
 source(audio='#a,video='#b+1,midi='#c))->
source(audio='#a,video='#b+1,midi='#c)

Fill frame with a color.

video.greyscale
(?id:string,source(audio='#a,video='#b+1,midi='#c))->
source(audio='#a,video='#b+1,midi='#c)

Convert video to greyscale.

video.invert
(?id:string,source(audio='#a,video='#b+1,midi='#c))->
source(audio='#a,video='#b+1,midi='#c)

Invert video.

video.lomo
(?id:string,source(audio='#a,video='#b+1,midi='#c))->
source(audio='#a,video='#b+1,midi='#c)

Emulate the “Lomo effect”.

video.opacity
(?id:string,float,source(audio='#a,video='#b+1,midi='#c))->
source(audio='#a,video='#b+1,midi='#c)

Scale opacity of video.

video.opacity.blur
(?id:string,source(audio='#a,video='#b+1,midi='#c))->
source(audio='#a,video='#b+1,midi='#c)

Blur opacity of video.

video.rotate
(?id:string,?angle:'a,?speed:'b,
 source(audio='#c,video='#d+1,midi='#e))->
source(audio='#c,video='#d+1,midi='#e)
where 'a, 'b is either float or ()->float

Rotate video.

video.scale
(?id:string,?scale:float,?x:int,?xscale:float,?y:int,
 ?yscale:float,source(audio='#a,video='#b+1,midi='#c))->
source(audio='#a,video='#b+1,midi='#c)

Scale and translate video.

video.sepia
(?id:string,source(audio='#a,video='#b+1,midi='#c))->
source(audio='#a,video='#b+1,midi='#c)

Convert video to sepia.

video.tile
(?id:string,?normalize:bool,?proportional:bool,
 ?weights:[int],[source(audio='#a,video='#b+1,midi='#c)])->
source(audio='#a,video='#b+1,midi='#c)

Tile sources (same as add but produces tiles of videos).

video.transparent
(?id:string,?color:int,?precision:float,
 source(audio='#a,video='#b+1,midi='#c))->
source(audio='#a,video='#b+1,midi='#c)

Set a color to be transparent.

Source / Visualization

peak
(?id:string,?duration:'a,
 source(audio='#b,video='#c,midi='#d))->
((()->float)*source(audio='#b,video='#c,midi='#d))
where 'a is either float or ()->float

Get current peak volume of the source. Returns a pair (f,s) where s is a new source and f is a function of type () -> float and returns the current peak volume of the source.

peak.stereo
(?id:string,?duration:'a,
 source(audio='#b+2,video='#c,midi='#d))->
((()->(float*float))*
 source(audio='#b+2,video='#c,midi='#d))
where 'a is either float or ()->float

Get current peak volume of the source. Returns a pair (f,s) where s is a new source and f is a function of type () -> float and returns the current peak volume of the source.

rms
(?id:string,?duration:'a,
 source(audio='#b,video='#c,midi='#d))->
((()->float)*source(audio='#b,video='#c,midi='#d))
where 'a is either float or ()->float

Get current RMS volume of the source. Returns a pair (f,s) where s is a new source and f is a function of type () -> float and returns the current RMS volume of the source.

rms.stereo
(?id:string,?duration:'a,
 source(audio='#b+2,video='#c,midi='#d))->
((()->(float*float))*
 source(audio='#b+2,video='#c,midi='#d))
where 'a is either float or ()->float

Get current RMS volume of the source. Returns a pair (f,s) where s is a new source and f is a function of type () -> float and returns the current RMS volume of the source.

server.rms
(?id:string,source(audio='#a,video='#b,midi='#c))->
source(audio='#a,video='#b,midi='#c)

Register a command that outputs the RMS of the returned source.

video.volume
(?id:string,source(audio='#a+1,video=0,midi=0))->
source(audio='#a+1,video=1,midi=0)

Graphical visualization of the sound.

visu.volume
(?id:string,source(audio='#a+1,video=0,midi=0))->
source(audio='#a+1,video=0,midi=0)

Graphical visualization of the volume.

vumeter
(?id:string,?scroll:bool,
 source(audio='#a+1,video='#b,midi='#c))->
source(audio='#a+1,video='#b,midi='#c)

VU meter (display the audio volume).

Bool

!=
('a,'a)->bool where 'a is an orderable type

Comparison of comparable values.

<
('a,'a)->bool where 'a is an orderable type

Comparison of comparable values.

<=
('a,'a)->bool where 'a is an orderable type

Comparison of comparable values.

==
('a,'a)->bool where 'a is an orderable type

Comparison of comparable values.

>
('a,'a)->bool where 'a is an orderable type

Comparison of comparable values.

>=
('a,'a)->bool where 'a is an orderable type

Comparison of comparable values.

and
(bool,bool)->bool

Return the conjunction of its arguments

not
(bool)->bool

Returns the negation of its argument.

or
(bool,bool)->bool

Return the disjunction of its arguments

random.bool
()->bool

Generate a random value.

Control

add_timeout
(?fast:bool,float,(()->float))->unit

Call a function in N seconds. If the result of the function is positive or null, the task will be scheduled again after this amount of time (in seconds).

ignore
('a)->unit

Convert anything to unit, preventing warnings.

Interaction

add_skip_command
(source('a))->unit

Add a skip function to a source when it does not have one by default.

http.delete
(?headers:[(string*string)],?timeout:float,string)->
((((string*int)*string)*[(string*string)])*string)

Perform a full Http DELETE request and return (status,headers),data.

http.get
(?headers:[(string*string)],?timeout:float,string)->
((((string*int)*string)*[(string*string)])*string)

Perform a full Http GET request and return (status,headers),data.

http.head
(?headers:[(string*string)],?timeout:float,string)->
((((string*int)*string)*[(string*string)])*string)

Perform a full Http HEAD request and return (status,headers),data.

http.post
(?data:string,?headers:[(string*string)],?timeout:float,
 string)->
((((string*int)*string)*[(string*string)])*string)

Perform a full Http POST request and return (status,headers),data.

http.put
(?data:string,?headers:[(string*string)],?timeout:float,
 string)->
((((string*int)*string)*[(string*string)])*string)

Perform a full Http PUT request and return (status,headers),data.

http_codes
[(string*string)]

List of HTTP response codes and statuses.

http_response
(?protocol:string,?code:int,?headers:[(string*string)],
 ?data:string)->string

Create a HTTP response string

https.delete
(?headers:[(string*string)],?timeout:float,string)->
((((string*int)*string)*[(string*string)])*string)

Perform a full https DELETE request and return (status,headers),data.

https.get
(?headers:[(string*string)],?timeout:float,string)->
((((string*int)*string)*[(string*string)])*string)

Perform a full https GET request and return (status,headers),data.

https.head
(?headers:[(string*string)],?timeout:float,string)->
((((string*int)*string)*[(string*string)])*string)

Perform a full https HEAD request and return (status,headers),data.

https.post
(?data:string,?headers:[(string*string)],?timeout:float,
 string)->
((((string*int)*string)*[(string*string)])*string)

Perform a full https POST request and return (status,headers),data.

https.put
(?data:string,?headers:[(string*string)],?timeout:float,
 string)->
((((string*int)*string)*[(string*string)])*string)

Perform a full https PUT request and return (status,headers),data.

interactive.bool
(string,bool)->()->bool

Read a boolean from an interactive input.

interactive.float
(string,float)->()->float

Read a float from an interactive input.

interactive.string
(string,string)->()->string

Read a string from an interactive input.

print
(?newline:bool,'a)->unit

Print on standard output.

server.broadcast
(('a*('b*(()->'c))))->'c

Restart all server clients waiting on the given condition

server.condition
()->((((()->string))->string)*((()->unit)*(()->unit)))

Create a pair of functions (wait,(signal,broadcast)) used to suspend and resume server command execution. Used to write interactive server commands through server.wait, server.signal, server.broadcast and server.write.

server.read
(((string)->string),string)->string

Read a string from the client up-to a marker. Marker can be any string of regular expression. Should be used via the syntactic sugar: server.read <marker> : <varname> then <after> end

server.readchars
(((string)->string),int)->string

Read a string of fixed length from the client up-to a marker. Should be used via the syntactic sugar: server.readchars <len> : <varname> then <after> end

server.readline
(((string)->string))->string

Read a line from the client. Should be used via the syntactic sugar: server.readline <varname> then <after> end

server.register
(?namespace:string,?description:string,?usage:string,
 string,((string)->string))->unit

Register a command. You can then execute this function through the server, either telnet or socket.

server.signal
(('a*((()->'b)*'c)))->'b

Restart one server client waiting on the given condition

server.wait
(((((()->string))->string)*'a),(()->string))->string

Wait on a server condition. Used to write interactive server command. Should be used via the syntactic sugar: server.wait <condition> then <after> end

server.write
((()->string),string)->string

Execute a partial write while executing a server command. Should be used via the syntactic sugar: server.write <string> then <after> end

Liquidsoap

add_decoder
(name:string,description:string,?mimes:[string],
 test:((string)->int),string)->unit

Register an external decoder. The encoder should output in WAV format to his standard output (stdout) and read data from its standard input (stdin).

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

Register an external file metadata decoder.

add_oblivious_decoder
(name:string,description:string,test:((string)->int),
 ?buffer:float,((string)->string))->unit

Register an external file decoder. The encoder should output in WAV format to his standard output (stdout) and read data from the file it receives. The estimated remaining duration for this decoder will be unknown until the buffer last seconds of the file. If possible, it is recommended to decode from stdin and use add_decoder.

add_playlist_parser
(format:string,strict:bool,
 ((?pwd:string,string)->[([(string*string)]*string)]))->
unit

Register a new playlist parser.

add_protocol
(?temporary:bool,?static:bool,?syntax:string,?doc:string,
 string,
 ((rlog:((string)->unit),maxtime:float,string)->[string]))->
unit

Register a new protocol.

clock
(?sync:bool,?id:string,source('a))->source('a)

Assign a new clock to the given source (and to other time-dependent sources) and return the source. It is a conveniency wrapper around clock.assign_new(), allowing more concise scripts in some cases.

clock.assign_new
(?id:string,?sync:bool,[source('a)])->unit

Create a new clock and assign it to a list of sources.

clock.unify
([source('a)])->unit

Enforce that a list of sources all belong to the same clock.

configure.default_font
string

Liquidsoap's default font file.

configure.libdir
string

Liquidsoap's library directory.

configure.logdir
string

Liquidsoap's logging directory.

configure.rundir
string

Liquidsoap's PID file directory.

enable_external_faad_decoder
()->unit

Enable or disable external FAAD (AAC/AAC+/M4A) decoders. Does not work on Win32. Please note that built-in support for faad is available in liquidsoap if compiled and should be preferred over the external decoder.

enable_external_ffmpeg_decoder
()->unit

Enable ffmpeg decoder.

enable_external_flac_decoder
()->unit

Enable external FLAC decoders. Please note that built-in support for FLAC is available in liquidsoap if compiled and should be preferred over the external decoder.

enable_external_mpc_decoder
()->unit

Enable external Musepack decoder.

enable_replaygain_metadata
(?extract_replaygain:string)->unit

Enable replay gain metadata resolver. This resolver will process any file decoded by liquidsoap and add a replay_gain metadata when this value could be computed. For a finer-grained replay gain processing, use the replay_gain protocol.

file.duration
(string)->float

Compute the duration in seconds of audio data contained in a file. The computation may be expensive. Returns -1. if computation failed, typically if the file was not recognized as valid audio.

file.mime
(string)->string

Get the MIME type of a file, according to libmagic.

garbage_collect
()->unit

Trigger full major garbage collection.

get
(default:'a,string)->'a
where 'a is unit, bool, int, float, string or [string]

Get a setting's value.

get_clock_status
()->[(string*int)]

Get the current time for all allocated clocks.

harbor.http.register
(port:int,method:string,string,
 ((protocol:string,data:string,headers:[(string*string)],
   string)->string))->unit

Register a HTTP handler on the harbor. The given function receives as argument the full requested uri (e.g. “foo?var=bar”), http protocol version, possible input data and the list of HTTP headers and returns the answer sent to the client, including HTTP headers. Registered uri can be regular expressions (e.g. “.+\.php”) and can override default metadata handlers.

harbor.http.remove
(method:string,port:int,string)->unit

Remove a registered HTTP handler on the harbor.

harbor.https.register
(port:int,method:string,string,
 ((protocol:string,data:string,headers:[(string*string)],
   string)->string))->unit

Register a HTTPS handler on the harbor. The given function receives as argument the full requested uri (e.g. “foo?var=bar”), http protocol version, possible input data and the list of HTTP headers and returns the answer sent to the client, including HTTP headers. Registered uri can be regular expressions (e.g. “.+\.php”) and can override default metadata handlers.

harbor.https.remove
(method:string,port:int,string)->unit

Remove a registered HTTPS handler on the harbor.

liquidsoap.version
string

Liquidsoap version string.

log
(?label:string,?level:int,string)->unit

Log a message.

log_clocks
(?delay:float,?interval:float,string)->unit

Create a log of clock times for all the clocks initially present. The log is in a simple format which you can directly use with gnuplot.

metadata.export
([(string*string)])->[(string*string)]

Filter-out internal metadata.

mutexify
('a)->'a

Protect functions with a mutex to avoid concurrent calls, return original value otherwise.

playlist.parse
(string)->[([(string*string)]*string)]

Try to parse a local playlist. Return a list of (metadata,URI) items, where metadata is a list of (key,value) bindings.

process_uri
(extname:'a,?uri:string,string)->string

Create a process: uri, replacing : with $(colon)

register
(name:string,?descr:string,?on_change:(('a)->unit),
 string,'a)->unit
where 'a is unit, bool, int, float, string or [string]

Register a new setting.

register_flow
(?server:string,?user:string,?password:string,
 ?email:string,radio:string,website:string,
 description:string,genre:string,
 streams:[(string*string)],source('a))->source('a)

Register a radio on Liquidsoap Flows.

request.create
(?indicators:[string],?persistent:bool,string)->
request('a)

Create a request. Creation may fail if there is no available RID, which cannot be detected currently: in that case one will obtain a request that will fail to be resolved.

request.create.raw
(?indicators:[string],?persistent:bool,string)->
request(audio=0,video=0,midi=0)

Create a raw request, i.e. for files that should not be decoded for streaming. Creation may fail if there is no available RID, which cannot be detected currently: in that case one will obtain a request that will fail to be resolved.

request.destroy
(?force:bool,request('a))->unit

Destroying a request causes any temporary associated file to be deleted, and releases its RID. Persistent requests resist to destroying, unless forced.

request.filename
(request('a))->string

Return a valid local filename if the request is ready, and the empty string otherwise.

request.log
(request('a))->string

Get log data associated to a request.

request.metadata
(request('a))->[(string*string)]

Get the metadata associated to a request.

request.ready
(request('a))->bool

Check if a request is ready, i.e. is associated to a valid local file. Unless the initial URI was such a file, a request has to be resolved before being ready.

request.resolve
(?timeout:float,request('a))->bool

Resolve a request, i.e. attempt to get a valid local file. The operation can take some time. Return true if the resolving was successful, false otherwise (timeout or invalid URI).

server.execute
(string,?string)->[string]

Execute a liquidsoap server command.

set
(string,'a)->unit
where 'a is unit, bool, int, float, string or [string]

Change some setting. Use liquidsoap --conf-descr and liquidsoap --conf-descr-key KEY on the command-line to get some information about available settings.

source.fallible
(source('a))->bool

Indicate if a source may fail, i.e. may not be ready to stream.

source.id
(source('a))->string

Get one source's identifier.

source.init
([source(audio=*,video=*,midi=*)])->
[source(audio=*,video=*,midi=*)]

Simultaneously initialize sources, return the sublist of sources that failed to initialized.

source.is_ready
(source('a))->bool

Indicate if a source is ready to stream, or currently streaming.

source.remaining
(source('a))->float

Estimation of remaining time in the current track.

source.seek
(source('a),float)->float

Seek forward, in seconds. Returns the amount of time effectively seeked.

source.shutdown
(source('a))->unit

Desactivate a source.

source.skip
(source('a))->unit

Skip to the next track.

List

_[_]
(string,[(string*string)])->string

l[k] returns the first v such that (k,v) is in the list l (or “” if no such v exists).

list.add
('a,['a])->['a]

Add an element at the top of a list.

list.append
(['a],['a])->['a]

Catenate two lists.

list.assoc
(default:'a,'b,[('b*'a)])->'a

Generalized l[k] with default value.

list.filter
((('a)->bool),['a])->['a]

Filter a list according to a filtering function.

list.filter_assoc
('a,[('a*'b)])->[('a*'b)] where 'a is an orderable type

list.filter_assoc(key,l) returns all the elements of the form (key, value) from l.

list.fold
((('a,'b)->'a),'a,['b])->'a

Fold a function on every element of a list: list.fold(f,x1,[e1,..,en]) is f(...f(f(x1,e1),e2)...,en).

list.hd
(default:'a,['a])->'a

Return the head (first element) of a list, or 'default' if the list is empty.

list.iter
((('a)->unit),['a])->unit

Call a function on every element of a list.

list.length
(['a])->int

Get the length of a list, i.e. its number of elements.

list.map
((('a)->'b),['a])->['b]

Map a function on every element of a list.

list.mapi
(((int,'a)->'b),['a])->['b]

Map a function on every element of a list, along with its index.

list.mem
('a,['a])->bool where 'a is an orderable type

Check if an element belongs to a list.

list.mem_assoc
('a,[('a*'b)])->bool where 'a is an orderable type

list.mem_assoc(key,l) returns true if l contains a pair (key,value)

list.nth
(default:'a,['a],int)->'a

Get the n-th element of a list (the first element is at position 0), or'default' if element does not exist.

list.randomize
(['a])->['a]

Shuffle the content of a list.

list.remove
('a,['a])->['a]

Remove a value from a list.

list.remove_assoc
('a,[('a*'c)])->[('a*'c)]

Remove the first pair from an associative list.

list.rev
(['a])->['a]

Revert list order.

list.sort
((('a,'a)->int),['a])->['a]

Sort a list according to a comparison function.

list.tl
(['a])->['a]

Return the list without its first element.

Math

*
('a,'a)->'a where 'a is a number type

Multiplication of numbers.

+
('a,'a)->'a where 'a is a number type

Addition of numbers.

-
('a,'a)->'a where 'a is a number type

Substraction of numbers.

/
('a,'a)->'a where 'a is a number type

Division of numbers.

abs
('a)->'a where 'a is a number type

Absolute value.

bool_of_float
(float)->bool

Convert a float to a bool.

bool_of_int
(int)->bool

Convert an int to a bool.

dB_of_lin
(float)->float

Convert linear scale into decibels.

float_of_int
(int)->float

Convert an int to a float.

int_of_float
(float)->int

Convert a float to a int.

lin_of_dB
(float)->float

Convert decibels into linear scale.

mod
(int,int)->int

Integer remainder. If y is not zero, x == (x / y) * y + x mod y, and abs(x mod y) <= abs(y)-1.

pow
('a,'a)->'a where 'a is a number type

Exponentiation of numbers.

random.float
(?min:float,?max:float)->float

Generate a random value.

random.int
(?min:float,?max:float)->int

Generate a random value.

~-
('a)->'a where 'a is a number type

Returns the opposite of its argument.

Pair

fst
(('a*'b))->'a

Get the first component of a pair.

snd
(('a*'b))->'b

Get the second component of a pair.

String

%
(string,[(string*string)])->string

pattern % [...,(k,v),...] changes in the pattern occurences of: - $(k) into v; - $(if $(k2),"a","b") into “a” if k2 is found in the list, “b” otherwise.

^
(string,string)->string

Concatenate strings.

base64.decode
(string)->string

Decode a Base64 encoded string.

base64.encode
(string)->string

Encode a string in Base64.

bool_of_string
(?default:bool,string)->bool

Convert a string to a bool.

float_of_string
(?default:float,string)->float

Convert a string to a float.

int_of_string
(?default:int,string)->int

Convert a string to a int.

json_of
(?compact:bool,'a)->string

Convert a value to a json string.

of_json
(default:'a,string)->'a

Parse a json string into a liquidsoap value.

quote
(string)->string

Escape shell metacharacters.

string.capitalize
(?capitalize:bool,?space_sensitive:bool,string)->string

Return a string with the first character set to upper case (capitalize), or to lower case (uncapitalize).

string.case
(?lower:bool,string)->string

Convert a string to lower or upper case.

string.concat
(?separator:string,[string])->string

Concatenate strings.

string.escape
(?special_chars:[string],?escape_char:((string)->string),
 string)->string

Escape special charaters in a string. String is parsed char by char. See string.utf8.escape for an UTF8-aware parsing function.

string.extract
(pattern:string,string)->[(string*string)]

Extract substrings from a string. Perl compatible regular expressions are recognized. Hence, special characters should be escaped. Returns a list of (index,value). If the list does not have a pair associated to some index, it means that the corresponding pattern was not found.

string.length
(string)->int

Get the length of a string.

string.match
(pattern:string,string)->bool

Match a string with an expression. Perl compatible regular expressions are recognized. Hence, special characters should be escaped.

string.recode
(?in_enc:string,?out_enc:string,string)->string

Convert a string. Effective only if Camomile is enabled.

string.replace
(pattern:string,((string)->string),string)->string

Replace substrings in a string. Will replace all substrings matched in the pattern by the string returned by the replace function.

string.split
(separator:string,string)->[string]

Split a string at 'separator'. Perl compatible regular expressions are recognized. Hence, special characters should be escaped.

string.sub
(string,start:int,length:int)->string

Get a substring of a string. Returns “” if no such substring exists.

string.trim
(string)->string

Return a string without leading and trailing whitespace.

string.utf8.escape
(?special_chars:[string],?escape_char:((string)->string),
 string)->string

Escape special charaters in an UTF8 string.

string_of
('a)->string

Return the representation of a value.

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

Standard function for displaying metadata. Shows artist and title, using “Unknown” when a field is empty.

url.decode
(?plus:bool,string)->string

Decode an encoded url (e.g. “%20” becomes “ ”).

url.encode
(?plus:bool,string)->string

Encode an url (e.g. “ ” becomes “%20”).

url.split
(string)->(string*[(string*string)])

Split an url of the form foo?arg=bar&arg2=bar2 into (“foo”,[(“arg”,“bar”),(“arg2”,“bar2”)]).

url.split_args
(string)->[(string*string)]

Split the arguments of an url of the form arg=bar&arg2=bar2 into [(“arg”,“bar”),(“arg2”,“bar2”)].

System

argv
(?default:string,int)->string

Get command-line parameters.

basename
(string)->string

Get the base name of a path.

dirname
(string)->string

Get the directory name of a path.

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

Return the process environment.

exe_ext
string

Executable file extension.

exec_at
(?freq:float,pred:(()->bool),(()->unit))->unit

Execute a given action when a predicate is true. This will be run in background.

exit
(int)->unit

Immediately stop the application. This should only be used in extreme cases or to specify an exit value. The recommended way of stopping Liquidsoap is to use shutdown.

file.contents
(string)->string

Read the whole contents of a file.

file.exists
(string)->bool

Returns true if the file or directory exists.

file.extension
(?dir_sep:string,string)->string

Returns a file's extension.

file.is_directory
(string)->bool

Returns true if the file exists and is a directory.

file.mime_default
(string)->string

Alias of file.mime (because it is available)

file.temp
(string,string)->string

Return a fresh temporary filename in the temporary directory.

file.watch
(string,(()->unit))->()->unit

Call a function when a file is modified. Returns unwatch function.

get_mime
(string)->string

Generic mime test. First try to use file.mime if it exist. Otherwise try to get the value using the file binary. Returns “” (empty string) if no value can be found.

get_process_lines
(?timeout:float,?env:[(string*string)],?inherit_env:bool,
 string)->[string]

Perform a shell call and return the list of its output lines.

get_process_output
(?timeout:float,?env:[(string*string)],?inherit_env:bool,
 string)->string

Perform a shell call and return its output.

getenv
(string)->string

Get the value associated to a variable in the process environment. Return “” if variable is not set.

getopt
(?default:string,string)->string

Parse command line options: getopt("-o") returns “1” if “-o” was passed without any parameter, “0” otherwise. getopt(default="X","-o") returns “Y” if “-o Y” was passed, “X” otherwise. The result is removed from the list of arguments, affecting subsequent calls to argv() and getopt().

getpid
()->int

Get the process' pid.

gettimeofday
()->float

Return the current time since 00:00:00 GMT, Jan. 1, 1970, in seconds.

gmtime
(float,
 ((sec:int,min:int,hour:int,mday:int,mon:int,year:int,
   wday:int,yday:int,isdst:bool)->'a))->'a

Convert a time in seconds into a date in the UTC time zone and execute passed callback with the result. Fields meaning same as POSIX's tm struct. Warning: “year” is: year - 1900, i.e. 117 for 2017!

is_directory
(string)->bool

Returns true if the directory exists.

localtime
(float,
 ((sec:int,min:int,hour:int,mday:int,mon:int,year:int,
   wday:int,yday:int,isdst:bool)->'a))->'a

Convert a time in seconds into a date in the local time zone and execute passed callback with the result. Fields meaning same as POSIX's tm struct. Warning: “year” is: year - 1900, i.e. 117 for 2017!

on_shutdown
((()->unit))->unit

Register a function to be called when Liquidsoap shuts down.

on_start
((()->unit))->unit

Register a function to be called when Liquidsoap starts.

os.type
string

Type of OS running liquidsoap.

path.concat
(string,string)->string

Concatenate two paths, using the appropriate directory separator.

read
(?hide:bool)->string

Read some value from standard input (console).

reopen.stderr
(string)->unit

Reopen standard error on the given file

reopen.stdin
(string)->unit

Reopen standard input on the given file

reopen.stdout
(string)->unit

Reopen standard output on the given file

restart
()->unit

Restart the application.

run_process
(?env:[(string*string)],?inherit_env:bool,?timeout:float,
 string)->((string*string)*(string*string))

Run a process in a shell environment. Returns: ((stdout,stderr),status) where status is one of: ("exit","<code>"), ("killed","<signal number>"), ("stopped","<signal number>"), ("exception","<exception description>"), ("timeout","<run time>").

setenv
(string,string)->unit

Set the value associated to a variable in the process environment.

shutdown
()->unit

Shutdown the application.

source.is_up
(source('a))->bool

Check whether a source is up.

source.on_shutdown
(source('a),(()->unit))->unit

Register a function to be called when source shuts down.

system
(string)->unit

Shell command call. Set verbose to true to log process' output and errors.

test_process
(?timeout:float,?env:[(string*string)],?inherit_env:bool,
 string)->bool

Return true if process exited with 0 code.

time
()->float

Return the current time since 00:00:00 GMT, Jan. 1, 1970, in seconds.

which
(string)->string

which(“progname”) searches for an executable named “progname” using directories from the PATH environment variable and returns “” if it could not find one.