SHOW:
|
|
- or go back to the newest paste.
1 | #!/usr/bin/liquidsoap | |
2 | ||
3 | set("log.stdout", true); | |
4 | set("server.telnet", true); | |
5 | ||
6 | # is skipped flag | |
7 | track.isSkipped = ref false; | |
8 | ||
9 | # transition func | |
10 | def transition(from, to)= | |
11 | if (!track.isSkipped) then | |
12 | track.isSkipped := false; | |
13 | - | add([fade.initial(to), fade.final(from)]); |
13 | + | add(normalize = false, [fade.initial(to), fade.final(from)]); |
14 | else | |
15 | add(normalize = false, [to, from]); | |
16 | end | |
17 | end | |
18 | ||
19 | # extended crossfade | |
20 | def crossfade.switch(~id = "", ~conservative = true, ~start_next = 10., ~fade_in = 5., ~fade_out = 5., s) | |
21 | - | # i've tried to remove following two lines - but there were no effect (volume levels were still jumping) |
21 | + | |
22 | - | s = fade.in(duration = fade_in, s); |
22 | + | |
23 | - | s = fade.out(duration = fade_out, s); |
23 | + | |
24 | # security track | |
25 | security = single("/home/security.mp3"); | |
26 | ||
27 | # external script just returns random track from folder | |
28 | # add your script name here | |
29 | playlist = request.dynamic(conservative = true, fun () -> request.create(list.hd(get_process_lines("external script")))) | |
30 | ||
31 | # apply crossfade (we need it really only for tracks in playlist) | |
32 | playlist = crossfade.switch(playlist); | |
33 | ||
34 | # create main source | |
35 | radio = fallback(track_sensitive = false, [playlist, security]); | |
36 | ||
37 | # output source | |
38 | output.icecast(mount = "testme", host = "localhost", port = 80, password = "hackme", %mp3, radio) | |
39 | ||
40 | # Updates program timeout, server command | |
41 | def server.source.skip(unused) = | |
42 | track.isSkipped := true; | |
43 | source.skip(radio); | |
44 | "done" | |
45 | end | |
46 | ||
47 | # Register server command | |
48 | server.register(namespace = "source", | |
49 | description = "Skips current track", | |
50 | usage = "skip", "skip", server.source.skip); |