Reliably play a jingle between Live and Fallback / Use jingle as bridge/buffer / always play a jingle playlist from the beginning #3980
kmnx
started this conversation in
User Support
Replies: 1 comment
-
I tried again with a simplified version of just a request.queue and it seems to work now. Maybe i was just too impatient during testing the other scripts, as from looking at the logs it seems all the previous sources from fading in Live have to be finished and gone down before clearing the queue works. Also threw in a list.iter(request.destroy, q) for good measure although debug statements said there were no requests left at this point. It still struggles when the next disconnect with empty Live buffers comes too fast after going live, but I guess at that point the streamers connection seems too unstable to stream anyway. set("log.level", 4)
settings.harbor.bind_addrs.set(["0.0.0.0"])
replaystream = "https://oursmallradio.org/stream"
restream = mksafe(id="restream",buffer(input.http(id="replaystream",replaystream)))
# "Stay Locked" - Live indicator Jingle 4s
jingle_vc_path = "./jingle/jinglevc.wav"
# Going offline / bridge jingle 14s
jingle_ba_path = "./jingle/jingleba.mp3"
jingle_queue = request.queue(id="jingle_queue")
# flush the jingle queue
def flush_and_skip()
q = jingle_queue.queue()
jingle_queue.set_queue([])
jingle_queue.skip()
list.iter(request.destroy, q)
end
# jingle refill, triggered when live streamer disconnects, through on_disconnect
def refill_jingle_queue() =
print("refill_jingle_queue")
flush_and_skip()
jingle_request = request.create(jingle_ba_path)
jingle_queue.push(jingle_request)
print("Jingles refilled, q is " ^ string(jingle_queue.length()) ^ " ,length is " ^ string(jingle_queue.length()))
end
def on_live_disconnected()
refill_jingle_queue()
end
live = input.harbor("stream",buffer=8.,port=42600,password="hackme",on_disconnect=on_live_disconnected)
def tolive(a,b)
print("inside tolive, passed sources are " ^ source.id(a) ^ " and " ^ source.id(b))
if source.id(a) == "restream" then
# coming from archive restream so inject the "Stay Locked"-jingle
add(normalize=false, [
sequence([fade.out(duration=4.,type="sin",a)]),
sequence([blank(duration=4.5),once(single(jingle_vc_path))]),
sequence([blank(duration=8.7),fade.in(duration=1.7,type="sin",b)])
])
else
# coming from the jingle_queue, so fade out the long 14s bridge/buffer jingle and go back to live
add(normalize=false, [
sequence([fade.out(duration=2.,type="sin",a)]),
sequence([blank(duration=4.),fade.in(duration=1.7,type="sin",b)])
])
end
end
def tojingle(a,b)
print("inside tojingle, passed sources are " ^ source.id(a) ^ " and " ^ source.id(b))
sequence([a, blank(duration=1.7),b])
end
def torestream(a,b)
print("inside torestream, passed sources are " ^ source.id(a) ^ " and " ^ source.id(b))
add(normalize=false,[
sequence([
fade.in(duration=1.7,type="sin",b)
])
])
end
# init the jingle_queues at station startup
refill_jingle_queue()
# fallback of live, jingle, restream. jingle_queue is filled and becomes active when live streamer disconnects.
livestream = fallback(track_sensitive=false, transition_length=25.,
[live, jingle_queue,restream],transitions=[tolive,tojingle,torestream])
def get_current_stream(metadata)
print("Livestream current source")
print(string(livestream.selected()))
end
livestream.on_track(get_current_stream)
output.icecast(%mp3(bitrate=320, samplerate=44100, stereo=true),
host="localhost",port=8000,password="howarewestillnothacked",
mount="stream",livestream)``` |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
EDIT: I think my simplified version in my own comment below works now! Maybe the convoluted original version already worked and I was just testing too fast. It seems clearing the queue is only possible after all fade sources have gone down even if they're unrelated to the jingle queue.
Convoluted title but the idea is simple:
I'd like to play a Jingle after Live source disconnects, then either go to Fallback or continue with Live if the DJ had a connection error and manages to reconnect during the jingle.
So either Live disconnect, Jingle, Fallback.
Or Live disconnect, Jingle, DJ manages to reconnect during Jingle, back to Live.
I got it to work somewhat, but not reliably. It only works the first time, but if the jingle is successfully used as a disconnect buffer, it shows unexpected (to me) behavior. In most scripts i tried it works on the first reconnect, but afterwards the jingle does not reset as expected, playing from the point where the DJ reconnected the last time.
Any ideas on how to successfully play the jingle from the start every time, and why my reset attempts are not working as expected?
Here's a Diagram:
Things I tried:
Also it seems difficult to find the right place to issue the skip() on the jingle queue. If it's in the transition to_live, it does not wait until the transition is finished and you can hear the jingle being skipped inside the fade. This was described in this old example here, but it does not work as you can hear the skip. #530
My preferred moment to issue the skip would be after all transitions are done and Live is playing alone, or after the jingle_queue is definitely done playing, but there does not seem to be a way to measure that. something like on_leave or on_is_only_source_playing.
So currently I'm issuing the flush/reset/skip/refill right on Live disconnect because it seems to be the only time it does not interfere with the playing audio.
Beta Was this translation helpful? Give feedback.
All reactions