codemirror-lang-liquidsoap 0.2.7 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/dist/cli.js +13 -13
  2. package/dist/index.js +15 -13
  3. package/package.json +2 -2
  4. package/src/index.ts +2 -0
  5. package/src/liquidsoap.grammar +9 -1
  6. package/src/parser.js +8 -8
  7. package/src/parser.terms.js +6 -5
  8. package/tests/liquidsoap/.github/scripts/build-posix.sh +0 -3
  9. package/tests/liquidsoap/.github/workflows/ci.yml +35 -10
  10. package/tests/liquidsoap/.pre-commit-config.yaml +1 -1
  11. package/tests/liquidsoap/CHANGES.md +1 -0
  12. package/tests/liquidsoap/CITATION.cff +17 -0
  13. package/tests/liquidsoap/doc/Makefile +17 -0
  14. package/tests/liquidsoap/doc/content/beets.md +6 -47
  15. package/tests/liquidsoap/doc/content/blank.md +5 -17
  16. package/tests/liquidsoap/doc/content/complete_case.md +1 -53
  17. package/tests/liquidsoap/doc/content/cookbook.md +23 -170
  18. package/tests/liquidsoap/doc/content/crossfade.md +1 -73
  19. package/tests/liquidsoap/doc/content/dynamic_sources.md +1 -47
  20. package/tests/liquidsoap/doc/content/external_decoders.md +6 -118
  21. package/tests/liquidsoap/doc/content/external_encoders.md +2 -4
  22. package/tests/liquidsoap/doc/content/external_streams.md +6 -20
  23. package/tests/liquidsoap/doc/content/ffmpeg_cookbook.md +9 -147
  24. package/tests/liquidsoap/doc/content/ffmpeg_filters.md +6 -93
  25. package/tests/liquidsoap/doc/content/harbor.md +4 -40
  26. package/tests/liquidsoap/doc/content/harbor_http.md +10 -118
  27. package/tests/liquidsoap/doc/content/help.md +1 -9
  28. package/tests/liquidsoap/doc/content/hls_output.md +6 -102
  29. package/tests/liquidsoap/doc/content/http_input.md +2 -4
  30. package/tests/liquidsoap/doc/content/icy_metadata.md +2 -24
  31. package/tests/liquidsoap/doc/content/in_production.md +2 -7
  32. package/tests/liquidsoap/doc/content/json.md +10 -36
  33. package/tests/liquidsoap/doc/content/language.md +1 -1
  34. package/tests/liquidsoap/doc/content/liq/Makefile +8 -0
  35. package/tests/liquidsoap/doc/content/liq/append-silence.liq +46 -0
  36. package/tests/liquidsoap/doc/content/liq/beets-amplify.liq +29 -0
  37. package/tests/liquidsoap/doc/content/liq/beets-protocol.liq +26 -0
  38. package/tests/liquidsoap/doc/content/liq/beets-source.liq +21 -0
  39. package/tests/liquidsoap/doc/content/liq/blank-detect.liq +10 -0
  40. package/tests/liquidsoap/doc/content/liq/blank-sorry.liq +11 -0
  41. package/tests/liquidsoap/doc/content/liq/check +4 -0
  42. package/tests/liquidsoap/doc/content/liq/complete-case.liq +69 -0
  43. package/tests/liquidsoap/doc/content/liq/cross.smart.liq +37 -0
  44. package/tests/liquidsoap/doc/content/liq/crossfade.liq +120 -0
  45. package/tests/liquidsoap/doc/content/liq/decoder-faad.liq +122 -0
  46. package/tests/liquidsoap/doc/content/liq/decoder-flac.liq +19 -0
  47. package/tests/liquidsoap/doc/content/liq/decoder-metaflac.liq +24 -0
  48. package/tests/liquidsoap/doc/content/liq/dump-hourly.liq +7 -0
  49. package/tests/liquidsoap/doc/content/liq/dump-hourly2.liq +4 -0
  50. package/tests/liquidsoap/doc/content/liq/dynamic-source.liq +55 -0
  51. package/tests/liquidsoap/doc/content/liq/external-output.file.liq +7 -0
  52. package/tests/liquidsoap/doc/content/liq/fallback.liq +4 -0
  53. package/tests/liquidsoap/doc/content/liq/ffmpeg-filter-dynamic-volume.liq +36 -0
  54. package/tests/liquidsoap/doc/content/liq/ffmpeg-filter-flanger-highpass.liq +10 -0
  55. package/tests/liquidsoap/doc/content/liq/ffmpeg-filter-hflip.liq +9 -0
  56. package/tests/liquidsoap/doc/content/liq/ffmpeg-filter-hflip2.liq +23 -0
  57. package/tests/liquidsoap/doc/content/liq/ffmpeg-filter-parallel-flanger-highpass.liq +36 -0
  58. package/tests/liquidsoap/doc/content/liq/ffmpeg-live-switch.liq +23 -0
  59. package/tests/liquidsoap/doc/content/liq/ffmpeg-relay-ondemand.liq +31 -0
  60. package/tests/liquidsoap/doc/content/liq/ffmpeg-relay.liq +19 -0
  61. package/tests/liquidsoap/doc/content/liq/ffmpeg-shared-encoding-rtmp.liq +43 -0
  62. package/tests/liquidsoap/doc/content/liq/ffmpeg-shared-encoding.liq +28 -0
  63. package/tests/liquidsoap/doc/content/liq/frame-size.liq +10 -0
  64. package/tests/liquidsoap/doc/content/liq/harbor-auth.liq +18 -0
  65. package/tests/liquidsoap/doc/content/liq/harbor-insert-metadata.liq +28 -0
  66. package/tests/liquidsoap/doc/content/liq/harbor-metadata.liq +14 -0
  67. package/tests/liquidsoap/doc/content/liq/harbor-redirect.liq +10 -0
  68. package/tests/liquidsoap/doc/content/liq/harbor-simple.liq +10 -0
  69. package/tests/liquidsoap/doc/content/liq/harbor-usage.liq +16 -0
  70. package/tests/liquidsoap/doc/content/liq/harbor.http.register.liq +48 -0
  71. package/tests/liquidsoap/doc/content/liq/harbor.http.response.liq +20 -0
  72. package/tests/liquidsoap/doc/content/liq/hls-metadata.liq +18 -0
  73. package/tests/liquidsoap/doc/content/liq/hls-mp4.liq +35 -0
  74. package/tests/liquidsoap/doc/content/liq/http-input.liq +6 -0
  75. package/tests/liquidsoap/doc/content/liq/icy-update.liq +31 -0
  76. package/tests/liquidsoap/doc/content/liq/input.mplayer.liq +26 -0
  77. package/tests/liquidsoap/doc/content/liq/json-ex.liq +29 -0
  78. package/tests/liquidsoap/doc/content/liq/json-stringify.liq +2 -0
  79. package/tests/liquidsoap/doc/content/liq/json1.liq +3 -0
  80. package/tests/liquidsoap/doc/content/liq/liquidsoap +4 -0
  81. package/tests/liquidsoap/doc/content/liq/live-switch.liq +23 -0
  82. package/tests/liquidsoap/doc/content/liq/medialib.liq +4 -0
  83. package/tests/liquidsoap/doc/content/liq/multitrack-add-video-track.liq +24 -0
  84. package/tests/liquidsoap/doc/content/liq/multitrack-add-video-track2.liq +10 -0
  85. package/tests/liquidsoap/doc/content/liq/multitrack-default-video-track.liq +14 -0
  86. package/tests/liquidsoap/doc/content/liq/multitrack.liq +11 -0
  87. package/tests/liquidsoap/doc/content/liq/multitrack2.liq +16 -0
  88. package/tests/liquidsoap/doc/content/liq/multitrack3.liq +10 -0
  89. package/tests/liquidsoap/doc/content/liq/output.file.hls.liq +44 -0
  90. package/tests/liquidsoap/doc/content/liq/prometheus-callback.liq +18 -0
  91. package/tests/liquidsoap/doc/content/liq/prometheus-settings.liq +3 -0
  92. package/tests/liquidsoap/doc/content/liq/radiopi.liq +467 -0
  93. package/tests/liquidsoap/doc/content/liq/re-encode.liq +14 -0
  94. package/tests/liquidsoap/doc/content/liq/regular.liq +8 -0
  95. package/tests/liquidsoap/doc/content/liq/replaygain-metadata.liq +6 -0
  96. package/tests/liquidsoap/doc/content/liq/replaygain-playlist.liq +6 -0
  97. package/tests/liquidsoap/doc/content/liq/rtmp.liq +10 -0
  98. package/tests/liquidsoap/doc/content/liq/samplerate3.liq +8 -0
  99. package/tests/liquidsoap/doc/content/liq/scheduling.liq +7 -0
  100. package/tests/liquidsoap/doc/content/liq/seek-telnet.liq +23 -0
  101. package/tests/liquidsoap/doc/content/liq/settings.liq +8 -0
  102. package/tests/liquidsoap/doc/content/liq/shoutcast.liq +5 -0
  103. package/tests/liquidsoap/doc/content/liq/space_overhead.liq +9 -0
  104. package/tests/liquidsoap/doc/content/liq/split-cue.liq +21 -0
  105. package/tests/liquidsoap/doc/content/liq/srt-receiver.liq +8 -0
  106. package/tests/liquidsoap/doc/content/liq/srt-sender.liq +4 -0
  107. package/tests/liquidsoap/doc/content/liq/transcoding.liq +18 -0
  108. package/tests/liquidsoap/doc/content/liq/video-anonymizer.liq +31 -0
  109. package/tests/liquidsoap/doc/content/liq/video-bluescreen.liq +14 -0
  110. package/tests/liquidsoap/doc/content/liq/video-in-video.liq +7 -0
  111. package/tests/liquidsoap/doc/content/liq/video-logo.liq +9 -0
  112. package/tests/liquidsoap/doc/content/liq/video-osc.liq +26 -0
  113. package/tests/liquidsoap/doc/content/liq/video-simple.liq +12 -0
  114. package/tests/liquidsoap/doc/content/liq/video-static.liq +20 -0
  115. package/tests/liquidsoap/doc/content/liq/video-text.liq +5 -0
  116. package/tests/liquidsoap/doc/content/liq/video-transition.liq +5 -0
  117. package/tests/liquidsoap/doc/content/liq/video-weather.liq +7 -0
  118. package/tests/liquidsoap/doc/content/liq/video-webcam.liq +1 -0
  119. package/tests/liquidsoap/doc/content/memory.md +2 -14
  120. package/tests/liquidsoap/doc/content/multitrack.md +6 -81
  121. package/tests/liquidsoap/doc/content/prometheus.md +8 -22
  122. package/tests/liquidsoap/doc/content/quick_start.md +1 -1
  123. package/tests/liquidsoap/doc/content/radiopi.md +1 -298
  124. package/tests/liquidsoap/doc/content/replay_gain.md +2 -7
  125. package/tests/liquidsoap/doc/content/seek.md +2 -18
  126. package/tests/liquidsoap/doc/content/shoutcast.md +1 -5
  127. package/tests/liquidsoap/doc/content/split-cue.md +1 -26
  128. package/tests/liquidsoap/doc/content/video-static.md +1 -20
  129. package/tests/liquidsoap/doc/content/video.md +23 -111
  130. package/tests/liquidsoap/doc/dune +6 -0
  131. package/tests/liquidsoap/doc/dune.inc +11350 -406
  132. package/tests/liquidsoap/doc/gen_dune.ml +81 -31
  133. package/tests/liquidsoap/doc/no-pandoc +1 -1
  134. package/tests/liquidsoap/liquidsoap +2 -1
  135. package/tests/liquidsoap/src/core/io/srt_io.ml +12 -3
  136. package/tests/liquidsoap/src/core/operators/video_effects.ml +3 -1
  137. package/tests/liquidsoap/src/core/outputs/output.ml +4 -2
  138. package/tests/liquidsoap/src/core/outputs/output.mli +2 -0
  139. package/tests/liquidsoap/src/core/visualization/video_volume.ml +7 -4
  140. package/tests/liquidsoap/src/js/index.html +2 -2
  141. package/tests/liquidsoap/src/lang/parser.mly +10 -10
  142. package/tests/liquidsoap/src/lang/term/parsed_term.ml +7 -11
  143. package/tests/liquidsoap/src/lang/term/term_reducer.ml +32 -32
  144. package/tests/liquidsoap/src/lang/utils.ml +3 -3
  145. package/tests/liquidsoap/src/libs/file.liq +15 -2
  146. package/tests/liquidsoap/src/libs/playlist.liq +3 -0
  147. package/tests/liquidsoap/src/runtime/main.ml +3 -0
  148. package/tests/liquidsoap/src/tooling/parsed_json.ml +9 -10
  149. package/tests/liquidsoap/tests/language/file.liq +4 -0
  150. package/tests/liquidsoap/tests/language/record.liq +33 -0
  151. package/tests/liquidsoap/tests/language/regexp.liq +2 -0
@@ -0,0 +1,9 @@
1
+ s = blank()
2
+ # BEGIN
3
+ s = video.add_image(
4
+ width=30,height=30,
5
+ x=10,y=10,
6
+ file="logo.jpg",
7
+ s)
8
+ # END
9
+ output.dummy(fallible=true, s)
@@ -0,0 +1,26 @@
1
+ # Set the OSC port to match TouchOSC's default port
2
+ settings.osc.port := 8000
3
+
4
+ # Input from the webcam with sound
5
+ cam = input.v4l2()
6
+ mic = input.pulseaudio()
7
+ s = source.mux.audio(audio=mic, cam)
8
+ s = mksafe(s)
9
+
10
+ # We get the angle from fader 3
11
+ angle = osc.float("/1/fader3", 0.)
12
+ # we rescale the position of fader 3 so that it corresponds to a 2π rotation
13
+ angle = fun() -> angle() * 2. * 3.1416
14
+ # ...and we rotate the video according to the angle
15
+ s = video.rotate(angle=angle, s)
16
+ # Change brightness according to fader 1
17
+ s = video.frei0r.brightness(brightness=osc.float("/1/fader1",0.5), s)
18
+ # Change contrast according to fader 2
19
+ s = video.frei0r.contrast0r(contrast=osc.float("/1/fader2",0.5), s)
20
+
21
+ # We have to buffer here otherwise we get clocks problems
22
+ s = buffer(s)
23
+
24
+ # Output sound and video
25
+ output.pulseaudio(fallible=true, s)
26
+ output.sdl(fallible=true, s)
@@ -0,0 +1,12 @@
1
+ s = single("video.mp4")
2
+
3
+ output.icecast(
4
+ %ffmpeg(format="ogg",
5
+ %audio(codec="libvorbis"),
6
+ %video(codec="libtheora")
7
+ ),
8
+ host="localhost",
9
+ port=8000,
10
+ password="hackme",
11
+ mount="/videostream",
12
+ s)
@@ -0,0 +1,20 @@
1
+ log.level := 4
2
+
3
+ audio = once(single("/tmp/bla.mp3"))
4
+ video = single("/tmp/bla.jpg")
5
+
6
+ # Mux audio and video
7
+ source = source.mux.video(video=video,audio)
8
+
9
+ # Disable real-time processing, to process with the maximum speed
10
+ clock.assign_new(sync='none',[source])
11
+
12
+ # Encode video and copy audio:
13
+ encoder = %ffmpeg(format="mp4",
14
+ %audio.copy,
15
+ %video(codec="libx264"))
16
+
17
+ # Output to a theora file, shutdown on stop
18
+ output.file(fallible=true,on_stop=shutdown,
19
+ encoder, "/tmp/encoded-video.mp4",
20
+ source)
@@ -0,0 +1,5 @@
1
+ s = blank()
2
+ s = video.add_text.sdl(
3
+ font="/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf",
4
+ "Hello world!", s)
5
+ output.dummy(fallible=true, s)
@@ -0,0 +1,5 @@
1
+ s = blank()
2
+ # BEGIN
3
+ s = video.fade.in(transition="fade", duration=3., s)
4
+ # END
5
+ output.dummy(s)
@@ -0,0 +1,7 @@
1
+ img = single("weather.jpg")
2
+ cam = input.v4l2()
3
+ cam = video.alpha.of_color(color=0x0000ff, precision=0.2, cam)
4
+ s = add([img, cam])
5
+
6
+ # END
7
+ output.dummy(fallible=true, s)
@@ -0,0 +1 @@
1
+ output.sdl(input.v4l2())
@@ -28,20 +28,8 @@ Inside liquidsoap scripts, the operations that the OCaml compiler provides to co
28
28
 
29
29
  Typically, to change the garbage collector parameters, one can do:
30
30
 
31
- ```liquidsoap
32
- # This code was contributed by AzuraCast:
33
- # Possible settings:
34
- # - less memory: space_overhead = 20
35
- # - less cpu: space_overhead = 140
36
- # - balanced: space_overhead = 80
37
-
38
- # Optimize for memory usage over CPU
39
- # This results in a slightly increased
40
- # CPU usage and reduced memory usage.
41
- runtime.gc.set(runtime.gc.get().{
42
- space_overhead = 20,
43
- allocation_policy = 2
44
- })
31
+ ```{.liquidsoap include="space_overhead.liq" from=1}
32
+
45
33
  ```
46
34
 
47
35
  These parameters and functions make it possible to experiment and see if you can find better parameters for your application.
@@ -23,18 +23,8 @@ s = single("/path/to/movie.mkv")
23
23
  By default, `liquidsoap` decodes _only_ the track that you tell it to pick. So,
24
24
  if you output this source as an output with only one audio track, it will happily do so:
25
25
 
26
- ```liquidsoap
27
- s = single("/path/to/movie.mkv")
26
+ ```{.liquidsoap include="multitrack.liq"}
28
27
 
29
- # Copy first audio track and video:
30
- output.file(
31
- %ffmpeg(
32
- %audio.copy,
33
- %video.copy
34
- ),
35
- "/path/to/copy.mkv",
36
- s
37
- )
38
28
  ```
39
29
 
40
30
  Resulting in the following logs:
@@ -55,23 +45,8 @@ Eventually, we picked up only first `audio` and first `video` track and reported
55
45
 
56
46
  Now, let's say that we want to also keep the second audio track but convert it to stereo and re-encode it into `aac`. We can then do:
57
47
 
58
- ```liquidsoap
59
- s = single("/path/to/movie.mkv")
48
+ ```{.liquidsoap include="multitrack2.liq"}
60
49
 
61
- # Copy first audio track and video track
62
- # and re-encode second audio track:
63
- output.file(
64
- %ffmpeg(
65
- %audio.copy,
66
- %audio_2(
67
- channels=2,
68
- codec="aac"
69
- ),
70
- %video.copy
71
- ),
72
- "/path/to/copy.mkv",
73
- s
74
- )
75
50
  ```
76
51
 
77
52
  And now we see the following logs:
@@ -87,24 +62,8 @@ Now, we are actually using both audio tracks from `movie.mkv` and one of them is
87
62
 
88
63
  One thing to keep in mind, however, is that **expected content-type drives the input decoder**. Typically, if, instead of a `single`, you use a `playlist`:
89
64
 
90
- ```liquidsoap
91
- s = playlist("/path/to/playlist")
65
+ ```{.liquidsoap include="multitrack3.liq"}
92
66
 
93
- # Copy first audio track and video track
94
- # and re-encode second audio track:
95
- output.file(
96
- fallible=true,
97
- %ffmpeg(
98
- %audio.copy,
99
- %audio_2(
100
- channels=2,
101
- codec="aac"
102
- ),
103
- %video.copy
104
- ),
105
- "/path/to/copy.mkv",
106
- s
107
- )
108
67
  ```
109
68
 
110
69
  Then all the files in the playlist who do not have at least two `audio` tracks and one `video` track will be rejected by the decoder!
@@ -166,57 +125,23 @@ Tracks can be muxed using the `source` operator. The operator takes a record of
166
125
 
167
126
  Here's how to add a video track to a source
168
127
 
169
- ```liquidsoap
170
- # A playlist of audio files
171
- s = playlist(...)
172
-
173
- # A static image
174
- image = single("/path/to/image.png")
175
-
176
- # Get the playlist's audio track, metadata and track marks
177
- let {audio = playlist_audio, metadata, track_marks} = source.track(s)
128
+ ```{.liquidsoap include="multitrack-add-video-track.liq" to="END"}
178
129
 
179
- # Get the video track from our static image
180
- let {video = image_video} = source.tracks(image)
181
-
182
- # Mux the audio tracks with the image
183
- s = source({
184
- audio=playlist_audio,
185
- video=image_video,
186
- metadata=metadata,
187
- track_marks=track_marks
188
- })
189
130
  ```
190
131
 
191
132
  The above example was purposely written in a longer form to make it more explicit. However, if you wish to just add/replace a track, you
192
133
  can also overload the existing tracks from the first source as follows:
193
134
 
194
- ```liquidsoap
195
- # A playlist of audio files
196
- s = playlist(...)
197
-
198
- # A static image
199
- image = single("/path/to/image.png")
135
+ ```{.liquidsoap include="multitrack-add-video-track2.liq" to="END"}
200
136
 
201
- # Mux the audio tracks with the image
202
- s = source(source.tracks(s).{video=source.tracks(image).video})
203
137
  ```
204
138
 
205
139
  ### Add a default video track
206
140
 
207
141
  You can also check if a source has a certain track and do something accordingly:
208
142
 
209
- ```liquidsoap
210
- s = playlist(...)
211
-
212
- # A default video source:
213
- image = single("/path/to/image.png")
214
-
215
- # Pick `s` video track if it has one, otherwise use the default one:
216
- video = source.tracks(s).video ?? source.tracks(image).video
143
+ ```{.liquidsoap include="multitrack-default-video-track.liq" to="END"}
217
144
 
218
- # Return a source that always has video:
219
- s = source(source.tracks(s).{video=video})
220
145
  ```
221
146
 
222
147
  Please note, however, that **tracks available in the playlist sources are determined based on the first decoded file**. If the first file in the playlist is audio-only then the playlist content-type is assumed to be audio-only for the whole playlist and the default video is added to _all decoded files_.
@@ -5,10 +5,8 @@ When compiled with optional support for [mirage/prometheus](https://github.com/m
5
5
 
6
6
  The basic settings to enable exports are:
7
7
 
8
- ```liquidsoap
9
- # Prometheus settings
10
- settings.prometheus.server := true
11
- settings.prometheus.server.port := 9090
8
+ ```{.liquidsoap include="prometheus-settings.liq"}
9
+
12
10
  ```
13
11
 
14
12
  Common metrics, namely `gauge`, `counter` and `summary` are provided via the script language, as well
@@ -39,15 +37,14 @@ This type can be a little confusing. Here's how it works:
39
37
 
40
38
  1. First, one has to create a metric factory of a given type. For instance:
41
39
 
42
- ```liquidsoap
43
- is_playing_metric = prometheus.gauge(labels=["source"],"liquidsoap_is_playing")
40
+ ```{.liquidsoap include="prometheus-callback.liq" from="A0" to="A1"}
41
+
44
42
  ```
45
43
 
46
44
  2. Then, the metric factory can be used to instantiate speific metrics by passing the label's values:
47
45
 
48
- ```liquidsoap
49
- playlist = playlist(id="playlist", ...)
50
- set_playlist_is_playing = is_playing_metric(label_values=["radio"])
46
+ ```{.liquidsoap include="prometheus-callback.liq" from="B0" to="B1"}
47
+
51
48
  ```
52
49
 
53
50
  The returned function is a setter for this metric, i.e.
@@ -58,19 +55,8 @@ The returned function is a setter for this metric, i.e.
58
55
 
59
56
  Finally, the programmer can now use that callback to set the metric as desired. For instance here:
60
57
 
61
- ```liquidsoap
62
- def check_if_ready(set_is_ready, source) =
63
- def callback() =
64
- if source.is_ready(source) then
65
- set_is_ready(1.)
66
- else
67
- set_is_ready(0.)
68
- end
69
- 0.1
70
- end
71
- callback
72
- end
73
- thread.run.recurrent(delay=0.,check_if_ready(set_playlist_is_playing, playlist))
58
+ ```{.liquidsoap include="prometheus-callback.liq" from="C0"}
59
+
74
60
  ```
75
61
 
76
62
  ## `prometheus.latency`
@@ -61,7 +61,7 @@ fallback([your_fallible_source_here, single("failure.ogg")])
61
61
  ```
62
62
 
63
63
  Finally, if you do not care about failures, you can pass the parameter
64
- `fallible=true` to most outputs. In that case, the output
64
+ `fallible=true` to most outputs (or pass the option `--no-fallible-check` to Liquidsoap). In that case, the output
65
65
  will accept a fallible source, and stop whenever the source fails
66
66
  and restart when it is ready to produce data again.
67
67
 
@@ -32,305 +32,8 @@ annotate:file_id="3541",length="400.613877551",\
32
32
 
33
33
  Note that we use annotate to pass some variables to liquidsoap...
34
34
 
35
- ```liquidsoap
36
- #!/usr/bin/liquidsoap
35
+ ```{.liquidsoap include="radiopi.liq"}
37
36
 
38
- # Standard settings
39
- log.file.set(true)
40
- log.file.path.set("/var/log/liquidsoap/pi.log")
41
- log.stdout.set(false)
42
- init.daemon.set(true)
43
- init.daemon.pidfile.path.set("/var/run/liquidsoap/pi.pid")
44
-
45
- # Enable telnet server
46
- settings.server.telnet.set(true)
47
-
48
- # Enable harbor for any external
49
- # connection
50
- settings.harbor.bind_addrs.set(["0.0.0.0"])
51
-
52
- # Verbose logs
53
- log.level.set(4)
54
-
55
- # We use the scheduler intensively,
56
- # therefore we create many queues.
57
- settings.scheduler.generic_queues.set(5)
58
- settings.scheduler.fast_queues.set(3)
59
- settings.scheduler.non_blocking_queues.set(3)
60
-
61
- # === Settings ===
62
-
63
- # The host to request files
64
- stream = "XXXxXXXx"
65
- # The command to request files
66
- scripts = "ssh XXxxxXXX@#{stream} '/path/to/scripts/"
67
- # A substitution on the returned path
68
- sed = " | sed -e s#/path/to/files/#ftp://user:password@#{stream}/#'"
69
-
70
- # Enable replay gain
71
- enable_replaygain_metadata ()
72
-
73
- pass = "XXxXXXXx"
74
- ice_host = "localhost"
75
-
76
- descr = "RadioPi"
77
- url = "http://radiopi.org"
78
-
79
- # === Live ===
80
-
81
- # A live source, on which we strip blank (make the source
82
- # unavailable when streaming blank)
83
- live =
84
- blank.strip(
85
- input.harbor(id="live", port=8000, password=pass,
86
- buffer=8.,max=20.,"live.ogg"),
87
- length=10., threshold=-50.)
88
-
89
- # This source relays the live data, when available,
90
- # to the other streamer, in uncompressed format (WAV)
91
- output.icecast(%wav, host=stream,
92
- port=8005, password=pass,
93
- mount="live.ogg", fallible=true,
94
- live)
95
-
96
- # This source relays the live source to "live.ogg". This
97
- # is used for debugging purposes, to see what is sent
98
- # to the harbor source.
99
- output.icecast(%vorbis, host="127.0.0.1",
100
- port=8080, password=pass,
101
- mount="live.ogg", fallible=true,
102
- live)
103
-
104
- # This source starts an archive of the live stream
105
- # when available
106
- title = '$(if $(title),"$(title)",\
107
- "Emission inconnue")$(if $(artist), \
108
- " par $(artist)") - %m-%d-%Y, %H:%M:%S'
109
- output.file(%vorbis, reopen_on_metadata=true,
110
- fallible=true,
111
- "/data/archives/brutes/" ^ title ^ ".ogg",
112
- live)
113
-
114
- # === Channels ===
115
-
116
- # Specialize the output functions by partial application
117
- output.icecast = output.icecast(description=descr, url=url)
118
- out = output.icecast(host=ice_host,port=8080,password=pass,fallible=true)
119
- out_aac32 = out(%fdkaac(bitrate=32))
120
- out_aac = out(%fdkaac(bitrate=64))
121
- out = out(%mp3)
122
-
123
- # A file for playing during failures
124
- interlude =
125
- single("/home/radiopi/fallback.mp3")
126
-
127
- # Lastfm submission
128
- def lastfm (m) =
129
- if (m["type"] == "chansons") then
130
- if (m["canal"] == "reggae" or m["canal"] == "Jazz" or m["canal"] == "That70Sound") then
131
- canal =
132
- if (m["canal"] == "That70Sound") then
133
- "70sound"
134
- else
135
- m["canal"]
136
- end
137
- user = "radiopi-" ^ canal
138
- lastfm.submit(user=user,password="xXXxx",m)
139
- end
140
- end
141
- end
142
-
143
- # === Basic sources ===
144
-
145
- # Custom crossfade to deal with jingles..
146
- def crossfade (~start_next=5.,~fade_in=3.,~fade_out=3.,
147
- ~default=(fun (a,b) -> sequence([a, b])),
148
- ~high=-15., ~medium=-32., ~margin=4.,
149
- ~width=2.,~conservative=false,s)
150
- fade.out = fade.out(type="sin",duration=fade_out)
151
- fade.in = fade.in(type="sin",duration=fade_in)
152
- add = fun (a,b) -> add(normalize=false,[b, a])
153
- log = log(label="crossfade")
154
-
155
- def transition(a,b,ma,mb,sa,sb)
156
-
157
- list.iter(fun(x)-> log(level=4,"Before: #{x}"),ma)
158
- list.iter(fun(x)-> log(level=4,"After : #{x}"),mb)
159
-
160
- if ma["type"] == "jingles" or mb["type"] == "jingles" then
161
- log("Old or new file is a jingle: sequenced transition.")
162
- sequence([sa, sb])
163
- elsif
164
- # If A and B are not too loud and close, fully cross-fade them.
165
- a <= medium and b <= medium and abs(a - b) <= margin
166
- then
167
- log("Old <= medium, new <= medium and |old-new| <= margin.")
168
- log("Old and new source are not too loud and close.")
169
- log("Transition: crossed, fade-in, fade-out.")
170
- add(fade.out(sa),fade.in(sb))
171
-
172
- elsif
173
- # If B is significantly louder than A, only fade-out A.
174
- # We don't want to fade almost silent things, ask for >medium.
175
- b >= a + margin and a >= medium and b <= high
176
- then
177
- log("new >= old + margin, old >= medium and new <= high.")
178
- log("New source is significantly louder than old one.")
179
- log("Transition: crossed, fade-out.")
180
- add(fade.out(sa),sb)
181
-
182
- elsif
183
- # Opposite as the previous one.
184
- a >= b + margin and b >= medium and a <= high
185
- then
186
- log("old >= new + margin, new >= medium and old <= high")
187
- log("Old source is significantly louder than new one.")
188
- log("Transition: crossed, fade-in.")
189
- add(sa,fade.in(sb))
190
-
191
- elsif
192
- # Do not fade if it's already very low.
193
- b >= a + margin and a <= medium and b <= high
194
- then
195
- log("new >= old + margin, old <= medium and new <= high.")
196
- log("Do not fade if it's already very low.")
197
- log("Transition: crossed, no fade.")
198
- add(sa,sb)
199
-
200
- # What to do with a loud end and a quiet beginning ?
201
- # A good idea is to use a jingle to separate the two tracks,
202
- # but that's another story.
203
-
204
- else
205
- # Otherwise, A and B are just too loud to overlap nicely,
206
- # or the difference between them is too large and overlapping would
207
- # completely mask one of them.
208
- log("No transition: using default.")
209
- default(sa, sb)
210
- end
211
- end
212
-
213
- cross(width=width, duration=start_next, conservative=conservative,
214
- transition,s)
215
- end
216
-
217
- # Create a radiopilote-driven source
218
- def channel_radiopilote(~skip=true,name)
219
- log("Creating canal #{name}")
220
-
221
- # Request function
222
- def request () =
223
- log("Request for #{name}")
224
- ret = list.hd(process.read.lines(scripts^"radiopilote-getnext "^quote(name)^sed))
225
- log("Got answer: #{ret} for #{name}")
226
- [request.create(ret)]
227
- end
228
-
229
- # Create the request.dynamic.list source
230
- # Set conservative to true to queue
231
- # several songs in advance
232
- source =
233
- request.dynamic.list(conservative=true, length=400.,
234
- id="dyn_"^name,request,
235
- timeout=60.)
236
-
237
- # Apply normalization using replaygain
238
- # information
239
- source = amplify(1.,override="replay_gain", source)
240
-
241
- # Skip blank when asked to
242
- source =
243
- if skip then
244
- blank.skip(source, length=10., threshold=-40.)
245
- else
246
- source
247
- end
248
-
249
- # Submit new tracks on lastfm
250
- source = on_metadata(lastfm,source)
251
-
252
- # Tell the system when a new track
253
- # is played
254
- source = on_metadata(fun (meta) ->
255
- system(scripts ^ "radiopilote-feedback "
256
- ^quote(meta["canal"])^" "
257
- ^quote(meta["file_id"]) ^ "'"), source)
258
-
259
- # Finally apply a smart crossfading
260
- crossfade(source)
261
- end
262
-
263
- # Basic source
264
- jazz = channel_radiopilote("jazz")
265
- discoqueen = channel_radiopilote("discoqueen")
266
- # Avoid skipping blank with classic music !!
267
- classique = channel_radiopilote(skip=false,"classique")
268
- That70Sound = channel_radiopilote("That70Sound")
269
- metal = channel_radiopilote("metal")
270
- reggae = channel_radiopilote("reggae")
271
- Rock = channel_radiopilote("Rock")
272
-
273
- # Group those sources in a separate
274
- # clock (good for multithreading/multicore)
275
- clock.assign_new([jazz,That70Sound,metal,reggae])
276
-
277
- # === Mixing live ===
278
-
279
- # To create a channel from a basic source, add:
280
- # - a new-track notification for radiopilote
281
- # - metadata rewriting
282
- # - the live shows
283
- # - the failsafe 'interlude' source to channels
284
- # - blank detection
285
- def mklive(source) =
286
- # Transition function: if transitioning
287
- # to the live, fade out the old source
288
- # if transitioning from live, fade.in
289
- # the new source. NOTE: We cannot
290
- # skip the current song because
291
- # reloading new songs for all the
292
- # sources when live starts costs too much
293
- # CPU.
294
- def trans(old,new) =
295
- if source.id(new) == source.id(live) then
296
- log("Transition to live!")
297
- add([new,fade.out(old)])
298
- elsif source.id(old) == source.id(live) then
299
- log("Transitioning from live!")
300
- add([fade.in(new),old])
301
- else
302
- log("Dummy transition")
303
- new
304
- end
305
- end
306
- fallback(track_sensitive=false,
307
- transitions=[trans,trans,trans],
308
- [live,source,interlude])
309
- end
310
-
311
- # Create a channel using mklive(), encode and output it to icecast.
312
- def mkoutput(~out=out,mount,source,name,genre)
313
- out(id=mount,mount=mount,name=name,genre=genre,
314
- mklive(source)
315
- )
316
- end
317
-
318
- # === Outputs ===
319
-
320
- mkoutput("jazz", jazz, "RadioPi - Canal Jazz","jazz")
321
- mkoutput("discoqueen", discoqueen, "RadioPi - Canal DiscoQueen","discoqueen")
322
- mkoutput("classique", classique, "RadioPi - Canal Classique","classique")
323
- mkoutput("That70Sound", That70Sound,
324
- "RadioPi - Canal That70Sound","That70Sound")
325
- mkoutput("metal", metal, "RadioPi - Canal Metal","metal")
326
- mkoutput("reggae", reggae, "RadioPi - Canal Reggae","reggae")
327
- mkoutput("Rock", Rock, "RadioPi - Canal Rock","Rock")
328
-
329
- # Test outouts
330
- mkoutput(out=out_aac,"reggae.aacp", reggae, "RadioPi - Canal Reggae \
331
- (64 kbits AAC+ test stream)","reggae")
332
- mkoutput(out=out_aac32,"reggae.aacp32", reggae, "RadioPi - Canal Reggae \
333
- (32 kbits AAC+ test stream)","reggae")
334
37
  ```
335
38
 
336
39
  The other machine has a similar configuration except that files are local, but this is exactly the same for liquidsoap !
@@ -68,18 +68,13 @@ done using the `override` parameter.
68
68
 
69
69
  For replay gain implementation, the `amplify` operator would typically be added immediately on top of the basic tracks source, before transitions or other audio processing operators. Typically:
70
70
 
71
- ```liquidsoap
72
- enable_replaygain_metadata()
71
+ ```{.liquidsoap include="replaygain-metadata.liq" to="END"}
73
72
 
74
- s = playlist("~/playlist")
75
- s = amplify(1.,override="replaygain_track_gain",s)
76
73
  ```
77
74
 
78
75
  For convenience, we added the `replaygain` operator which performs the
79
76
  amplification on the right metadata so that this can further be simplified to
80
77
 
81
- ```liquidsoap
82
- enable_replaygain_metadata()
78
+ ```{.liquidsoap include="replaygain-playlist.liq" to="END"}
83
79
 
84
- s = replaygain(playlist("~/playlist"))
85
80
  ```
@@ -25,24 +25,8 @@ Since seeking is currently only supported by request-based sources, it is recomm
25
25
  to hook the function as close as possible to the original source. Here is an example
26
26
  that implements a server/telnet seek function:
27
27
 
28
- ```liquidsoap
29
- # A playlist source
30
- s = playlist("/path/to/music")
31
-
32
- # The server seeking function
33
- def seek(t) =
34
- t = float_of_string(default=0.,t)
35
- log("Seeking #{t} sec")
36
- ret = source.seek(s,t)
37
- "Seeked #{ret} seconds."
38
- end
39
-
40
- # Register the function
41
- server.register(namespace=source.id(s),
42
- description="Seek to a relative position \
43
- in source #{source.id(s)}",
44
- usage="seek <duration>",
45
- "seek",seek)
28
+ ```{.liquidsoap include="seek-telnet.liq"}
29
+
46
30
  ```
47
31
 
48
32
  ## Cue points
@@ -12,12 +12,8 @@ using FDK-AAC or using an [external encoder](external_encoders.html). The recomm
12
12
  Shoutcast output are done using the `output.shoutcast` operator with the appropriate parameters.
13
13
  An example is:
14
14
 
15
- ```liquidsoap
16
- source = single("audiofile.ogg")
15
+ ```{.liquidsoap include="shoutcast.liq"}
17
16
 
18
- output.shoutcast(%mp3, host="shoutcast.example.org",
19
- port=8000, password="changeme",
20
- source)
21
17
  ```
22
18
 
23
19
  As usual, `liquidsoap -h output.shoutcast` gives you the full list of options for this operator.