-
Notifications
You must be signed in to change notification settings - Fork 1
/
sel.liq
271 lines (241 loc) · 5.31 KB
/
sel.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
#!/usr/local/bin/liquidsoap -v
%include "conf/sel.conf"
#%include "conf/ice.conf"
#
# Streams for the Live output
#
set("init.daemon.pidfile.path", "/usr/local/var/run/liquidsoap/sel.pid")
set("log.level",3)
set("log.stdout", true)
set("log.file", true)
set('log.file.path', '/usr/local/var/log/liquidsoap/sel.log')
set('server.telnet', true)
set('server.telnet.port', 1360)
# Set the OSC port to match TouchOSC's default port
set("osc.port", 8000)
set("frame.audio.channels",2)
set("frame.audio.samplerate",48000)
def fade.final(~id="fade.final",~duration=3.,~type="lin",s) =
fn = mkfade(start=1.,stop=0.,type=type,duration=duration,s)
should_play = ref true
def fn() =
v = fn()
if v == 0. then
should_play := false
end
v
end
s = amplify(id=id,fn,s)
switch(track_sensitive=false,[({!should_play},s)])
end
# Selector sources (sel num)
# Studio1 (1), Studio2 (2), Jukebox (3), OB (4), WebStudio (5), Sine (7), Off-Air (8)
# Default to Off Air when starting Liq.
S1 = ref false
S2 = ref false
JB = ref false
OB = ref false
WS = ref false
SI = ref false
OF = ref true
# Functions for reading Selector bools
def onS1 () =
!S1
end
def onS2 () =
!S2
end
def onOB () =
!OB
end
def onJB () =
!JB
end
def onWS () =
!WS
end
def onSI () =
!SI
end
def onOF () =
!OF
end
# Function for changing selector bools
# - returns string for telnet use as this is required
def selS1 (_) =
S1 := true
S2 := false
JB := false
OB := false
WS := false
SI := false
OF := false
"Studio 1 Selected"
end
def selS2 (_) =
S1 := false
S2 := true
JB := false
OB := false
WS := false
SI := false
OF := false
"Studio 2 Selected"
end
def selJB (_) =
S1 := false
S2 := false
JB := true
OB := false
WS := false
SI := false
OF := false
"Jukebox Selected"
end
def selOB (_) =
S1 := false
S2 := false
JB := false
OB := true
WS := false
SI := false
OF := false
"OB Stream Selected"
end
def selWS (_) =
S1 := false
S2 := false
JB := false
OB := false
WS := true
SI := false
OF := false
"WebStudio Stream Selected"
end
def selSI (_) =
S1 := false
S2 := false
JB := false
OB := false
WS := false
SI := true
OF := false
"Sine Wave Selected"
end
def selOF (_) =
S1 := false
S2 := false
JB := false
OB := false
WS := false
SI := false
OF := true
"Off Air Selected"
end
# Enable selector functions on telnet
server.register("selJB", selJB)
server.register("selS1", selS1)
server.register("selS2", selS2)
server.register("selOB", selOB)
server.register("selWS", selWS)
server.register("selSI", selSI)
server.register("selOF", selOF)
# OSC Function
# - take string and run selection based on that
# - ignore() turns function returning string to unit
def sel(s) =
if s == "S1" then
ignore(selS1())
elsif s == "S2" then
ignore(selS2())
elsif s == "JB" then
ignore(selJB())
elsif s == "OB" then
ignore(selOB())
elsif s == "WS" then
ignore(selWS())
elsif s == "SI" then
ignore(selSI())
elsif s == "OF" then
ignore(selOF())
end
end
# Setup OSC hook for /sel/XX
osc.on_string("/sel", sel)
# A simple cross-fade for transitions
def crossswitch(a,b)
#old = fade.final(duration=2.5,a) #.2
#new = fade.initial(duration=2.5,b), #.2
#add(normalize=false, [sequence([old,new]);
# add(
# normalize=false,
# [
# #sequence([
# #blank(duration=2.5),
# #fade.in(duration=5.0,b),
# #]),
#
# fade.out(duration=2.5,a),
# fade.in(duration=2.5,b)
# ]
# )
add(normalize=false,
[ fade.final(duration=4.,a), sequence([ blank(duration=2.),
fade.initial(duration=2.,b) ])
]
)
# fade.final(duration=5.,type="wow",a) ])
end
# Blank detection system
def blankHandler()
system(blankscript)
end
def blankEndHandler()
system(blankendscript)
end
def blankCritHandler()
system(criticalblankscript)
end
# Sources
studio1 = input.jack(id="selStudio1")
studio2 = input.jack(id="selStudio2")
# Try to make jukebox<-> studio transitions perfect
jukebox = buffer(buffer=0.1,max=0.1,input.jack(id="selJukebox"))
ob = buffer(buffer=0.1,max=0.1,input.jack(id="selOB"))
webstudio = buffer(buffer=0.1,max=0.1,input.jack(id="selWS"))
sine = input.jack(id="selSine")
offair = input.jack(id="selOffAir")
# Selector Handlers
selector = switch(
track_sensitive=false,
transitions=[
# crossfade,
# crossfade,
# crossfade,
# crossfade,
# crossfade,
# crossfade,
# crossfade
crossswitch,
crossswitch,
crossswitch,
crossswitch,
crossswitch,
crossswitch,
crossswitch,
],
[
(onS1, studio1),
(onS2, studio2),
(onJB, jukebox),
(onOB, ob),
(onWS, webstudio),
(onSI, sine),
(onOF, offair)
]
)
#selector = amplify(0.85, selector)
selector = on_blank(threshold=-55., max_blank=2., min_noise=1., on_noise=blankEndHandler, blankHandler, selector)
selector = on_blank(threshold=-55., max_blank=30., blankCritHandler, selector)
selector = mksafe(selector)
output.jack(id="selector", start=true, selector)