-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjukebox.liq
154 lines (125 loc) · 4.88 KB
/
jukebox.liq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/usr/local/bin/liquidsoap -v
# Coded by Gareth Lloyd <[email protected]>
# & Lloyd Wallis <[email protected]>
# & Andy Durant <[email protected]>
# Launched on URY 2012-01-27 00:36
%include "conf/ice.conf"
%include "conf/jukebox.conf"
set("init.daemon.pidfile.path", "/usr/local/var/run/liquidsoap/jukebox.pid")
set("log.stdout",true)
set("log.level",4)
set("server.telnet.bind_addr", telnetaddr)
set("server.telnet", true)
set("log.file", true)
set("log.file.path","/usr/local/var/log/liquidsoap/jukebox.log")
set("frame.audio.channels",2)
set("frame.audio.samplerate",48000)
#set("audio.converter.samplerate.libsamplerate.quality","best")
set("protocol.ffmpeg.replaygain",true)
enable_replaygain_metadata()
# Local file if music filestore isn't
interludelong = mksafe(single("/jukebox/intermission-long.mp3"))
interludelong = crossfade(duration=2., fade_in=1.2, fade_out=1.2, interludelong)
techdiff = single("/jukebox/TechnicalDifficultiesVoice.mp3")
techlude = add([interludelong, switch([({0s}, techdiff)])])
# Playlists - used if MyRadio script breaks
# Normal (Backup) playlist
backup_playlist = playlist(reload_mode="watch", "/jukebox/playlists/normal-list.pls", mime_type="application/xspf+xml")
# Main requests queue from MyRadio Requests page
requests = request.queue(id="jukebox_requests")
def myradio_sched() =
# Get the first line of the response
result = list.hd(default="", get_process_lines(sched_script))
# Create and return a request using this result
request.create(result)
end
# The default track scheduler - obeys licence requirements
# and other funsies.
main = request.dynamic(id="jukebox_main", myradio_sched, timeout=15.0, length=30.0, conservative=false)
def on_metadata_cb(meta)
log("on_metadata thinks now playing is " ^ meta["trackid"])
end
main = on_metadata(on_metadata_cb, main)
def on_offset_cb(_, meta)
log("on_offset(1) thinks now playing is " ^ meta["trackid"])
end
main = on_offset(offset=1.0, on_offset_cb, main)
def on_track_cb(meta)
log("on_track thinks now playing is " ^ meta["trackid"])
end
main = on_track(on_track_cb, main)
now_playing_id = ref ""
def update_now_playing(meta)
now_playing_id := meta["trackid"]
end
main = on_metadata(update_now_playing, main)
def get_now_playing(_)
!now_playing_id
end
server.register("now_playing", get_now_playing)
# Jingles every 25min~ish, not to coincide too often with the Jukebox ones below.
jingles = playlist(reload_mode="watch", "/jukebox/jingles")
jingles = delay(1500. , jingles)
# Campus Jukebox jingles every hour
cjjingle = playlist(mode="randomize", reload=3600, "/jukebox/cj-jingles")
cjjingle = delay(3600., cjjingle)
#Interviews every so often I guess sorry future man
#interviews = playlist(mode="randomize", reload=3600, "jukebox/interviews")
#interviews = delay(9780., interviews)
#interviews = at({get_process_output(playjingles_script)=="true"}, interviews)
# Put all the pieces together
#jukebox = fallback([cjjingle, jingles, interviews, requests, main, backup_playlist], replay_metadata = false)
jukebox = fallback([cjjingle, jingles, requests, main, backup_playlist], replay_metadata = false)
jukebox = fallback(track_sensitive=false, [jukebox, techlude])
# Avoid too much blank/silence in tracks
jukebox = skip_blank(max_blank=3., jukebox)
# Apply replay gain
jukebox = amplify(1.,override="replay_gain", jukebox)
#jukebox = amplify(0.3, jukebox)
# Add in some crossfade
#jukebox = smart_crossfade(start_next=5., fade_in=3., fade_out=3., jukebox, conservative=true)
jukebox = crossfade(smart=true, duration=4., fade_in=2., fade_out=2., jukebox, conservative=true)
# Tracklist trigger
last_tracklisted = ref "-1"
def trig_tracklist(j) =
if list.mem_assoc("trackid", j) then
log("Tracklist - recordid: " ^ j["recordid"] ^ "; trackid: " ^ j["trackid"])
if j["trackid"] != !last_tracklisted then
ignore(system(tracklist_script ^ " " ^ j["recordid"] ^ " " ^ j["trackid"] ))
last_tracklisted := j["trackid"]
end
else
log("Tracklist - filename: " ^ j["filename"])
ignore(system(tracklist_script ^ " " ^ j["filename"]))
#ignore("pfft!")
end
end
jukebox = on_metadata(trig_tracklist, jukebox)
#jukebox = on_offset(force=true, offset=3.0, trig_tracklist, jukebox)
#jukebox = on_track(trig_tracklist, jukebox)
# Force Liq to separate Icecast metadata.
def update_meta(m) =
title = m["title"]
artist = m["artist"]
[("title","#{title}"),("artist","#{artist}")]
end
jukebox = map_metadata(update_meta, mksafe(jukebox))
jukebox = amplify(0.7, jukebox)
# Output to soundcards
output.jack(id="jukebox", start=true, jukebox)
# Icecast outputs use a seperate clock to remove lag from the HW output
clock.assign_new(id="jukeboxStream",
[
output.icecast(
%mp3(bitrate=192, samplerate=48000, stereo=true),
host=icehost,
port=iceport,
password=icepass,
mount="jukebox",
url=website,
description=description,
name=name,
genre="Student Radio",
mksafe(buffer(jukebox))
)
])