I think that this is because your input is pulseaudio so it doesn't have
tracks. In this case, you also need to insert a track mark to give the
append operator a chance to insert the blank.

Something like this:

binaural = insert_metadata(binaural)
insert_track = fun () -> binaural.insert_metadata(new_track=true, [])

Then, later:
        insert_track()
        silence_source.skip()

I just tested it locally and it worked!

-- Romain

Le mar. 23 mai 2023 à 02:31, Tyna Pelletier-Bilodeau <ecole.t...@gmail.com>
a écrit :

> Of course, I will share everything needed here, even the effects I
> applied to the live stream in case they are useful in finding what's
> wrong.
>
> binaural = input.pulseaudio(device =
> "alsa_input.usb-ZOOM_Corporation_F3-00.analog-stereo")
>
> live =
> input.harbor("harbor",port=8005,user="username",password="password",icy=true)
>
> def multiband_band(live, from, _to, attack, release, ratio, threshold,
> gain)
>         high_live = filter.iir.eq.high(live, frequency = from,)
>         live_filtered = filter.iir.eq.low(high_live, frequency = _to,)
>         live_compressed = ladspa.tap_limiter(limit_level = -0.5,
> ladspa.sc4(rms_peak = 0.5, attack_time = attack, release_time = release,
> threshold_level = threshold, ratio=ratio, makeup_gain = gain,
> live_filtered))
>         live_compressed
> end
> live = ladspa.gate(live, threshold = -80.0, attack = 0.15, hold = 1.0,
> decay = 200.0, range = -25.0)
> live = normalize(gain_min = -16., gain_max = 0., target = 0.5, live)
> live = ladspa.sc4(rms_peak=0.3, attack_time = 0.5, release_time = 3.,
> threshold_level = -36.0, ratio=1., makeup_gain = 6., live)
> live = ladspa.tap_equalizer(band_1_freq=70., band_1_gain=4., live)
> live = ladspa.tap_equalizer(band_1_freq=150., band_1_gain=-2., live)
> live = add(normalize=false,
>         [
>         multiband_band(live, 0., 200., 3.5, 30., 3., -10., 2.),
>         multiband_band(live, 200., 1000., 2.25, 40., 2., -13., 2.),
>         multiband_band(live, 1000., 3500., 2.25, 40., 3., -9., 2.),
>         multiband_band(live, 3500., 6500., 2.25, 60., 2., -6., 1.5),
>         multiband_band(live, 6500., 20000., 2.25, 70., 2., -4., 1.)
>         ])
> live = ladspa.tap_limiter(limit_level = -0.5, live)
>
> # Set to `true` when we should be adding
> # silence
> should_append = ref(false)
>
> # Append 10. of silence when needed.
> silence_source = append(
>         binaural, fun (_) ->
>         if should_append() then
>                 should_append := false
>                 blank(duration=10.)
>         else
>                 source.fail()
>         end
> )
>
> # Transition to live
> def to_live(binaural, live) =
>         sequence([binaural,live])
> end
>
> # Transition back to playlist
> def to_binaural(live, binaural) =
>         # Ask to insert a silent track.
>         should_append := true
>
>         # Cancel current track. This will also set the playlist
>         # to play a new track. If needed, `cancel_pending` can
>         # be used to for a new silent track without skipping the
>         # playlist current track.
> silence_source.skip()
>
>         sequence([live, binaural])
> end
>
> source = fallback(
>         track_sensitive=false,
>         transitions=[to_live, to_binaural],
>         [live, silence_source]
> )
>
> I stream to icecast in mp3.cbr with a 192 kbps bitrate, in case this
> matters.
>
> I also see the blanks coming on and going, and the append track being
> played, except it doesn't play any silence and just goes back to pulseaudio.
>
> Hope this helps!
>
> On Mon May 22, 2023 at 11:12 PM CEST, Romain Beauxis wrote:
> > No it should be the same. Could you share a little more of your script?
> >
> > Le lun. 22 mai 2023 à 09:20, Tyna Pelletier-Bilodeau <
> ecole.t...@gmail.com>
> > a écrit :
> >
> > > Hi,
> > > I tried with a git pull on the master branch. Should I switch to the
> > > 2.2.x branch?
> > >
> > > On Mon May 22, 2023 at 3:46 PM CEST, Romain Beauxis wrote:
> > > > Hi,
> > > >
> > > > Have you tried with the latest rolling release code:
> > > >
> > >
> https://github.com/savonet/liquidsoap/releases/tag/rolling-release-v2.2.x
> > > >
> > > > Le dim. 21 mai 2023 à 15:14, Tyna Pelletier-Bilodeau <
> > > ecole.t...@gmail.com>
> > > > a écrit :
> > > >
> > > > > After I used the example provided in the cookbook to append a
> silence
> > > > > track, I get a whole bunch of these  while simulating a timeout
> from
> > > > > harbor by disconnecting the vpn while the phone was streaming, and
> > > > > there's no silence playing, it immediately switches to pulseaudio:
> > > > >
> > > > > 2023/05/21 22:02:16 [fail_0:3] Content type is {audio=pcm(stereo)}.
> > > > >
> > > > > What does that mean, exactly? Should I be doing something for the
> > > > > source.fail() portion of the code?
> > > > >
> > > > > Thanks for your work, by the way!
> > > > >
> > > > > On Sun May 21, 2023 at 6:43 PM CEST, Romain Beauxis wrote:
> > > > > > Le sam. 20 mai 2023 à 23:08, Romain Beauxis <
> > > romain.beau...@gmail.com> a
> > > > > > écrit :
> > > > > >
> > > > > > >
> > > > > > > Le sam. 20 mai 2023 à 13:02, Tyna Pelletier-Bilodeau <
> > > > > ecole.t...@gmail.com>
> > > > > > > a écrit :
> > > > > > >
> > > > > > >> Hi Romain,
> > > > > > >> thank you, I will try this and see how it goes.
> > > > > > >>
> > > > > > >> By the way I've been toying a bit with harbor, and wondered if
> > > there
> > > > > was
> > > > > > >> a way to have liquidsoap waiting a little in case the live
> drops
> > > out
> > > > > > >> for a few seconds instead of immediately swtching back to the
> main
> > > > > > >> source?
> > > > > > >>
> > > > > > >> I stream to the input over wireguard, which means sometimes
> I'm
> > > > > roaming
> > > > > > >> to get a signal from 4g towers. I'd like if I could stream
> some
> > > > > silence
> > > > > > >> instead of immediately falling back to the main source, which
> is
> > > > > another
> > > > > > >> live done with input.pulseaudio, and which is jarring since
> the
> > > > > > >> transition happens out of nowhere. Maybe up to say 10 seconds
> of
> > > delay
> > > > > > >> before giving up and switching to the main source, is this
> > > possible?
> > > > > > >>
> > > > > > >
> > > > > > > Yes, it's a pretty legit use-case. I'm sure it's possible right
> > > now but
> > > > > > > might be a little tricky to setup. I'll think about what we
> can do
> > > to
> > > > > make
> > > > > > > this easy to setup.
> > > > > > >
> > > > > >
> > > > > > I have a PR making a couple of tweaks to make it possible:
> > > > > > https://github.com/savonet/liquidsoap/pull/3098
> > > > > >
> > > > > >
> > > > > > >
> > > > > > >
> > > > > > >> On Sat May 20, 2023 at 2:18 AM CEST, Romain Beauxis wrote:
> > > > > > >> > Hi!
> > > > > > >> >
> > > > > > >> > Le ven. 19 mai 2023 à 02:39, Tyna Pelletier-Bilodeau <
> > > > > > >> ecole.t...@gmail.com>
> > > > > > >> > a écrit :
> > > > > > >> >
> > > > > > >> > > Hi,
> > > > > > >> > > it looks like after a connection timeout with liquidsoap
> > > 2.1.4, it
> > > > > > >> can't
> > > > > > >> > > automatically retry to reconnect to icecast. I'm not sure
> > > weather
> > > > > it's
> > > > > > >> > > because I use a tls enabled port or not, but in any event
> this
> > > > > > >> shouldn't
> > > > > > >> > > be happening. It is perfectly able to try reconnecting if
> for
> > > > > example
> > > > > > >> > > the icecast server has a too low maximum number of sources
> > > > > allowed,
> > > > > > >> but
> > > > > > >> > > when it is already streaming, and out of nowhere there's a
> > > > > problem, it
> > > > > > >> > > seems totally unable to do anything for itself.
> > > > > > >> > >
> > > > > > >> > > 2023/05/13 18:06:28 [asmrpmp3:3] Connection setup was
> > > successful.
> > > > > > >> > > 2023/05/19 08:12:42 [asmrpmp3:2] Error while sending data:
> > > could
> > > > > not
> > > > > > >> > > write data to host: connection timeout!
> > > > > > >> > > 2023/05/19 08:12:42 [asmrpmp3:3] Closing connection...
> > > > > > >> > > 2023/05/19 08:12:54 [clock.pulseaudio:2] Source asmrpmp3
> > > failed
> > > > > while
> > > > > > >> > > streaming: could not close connection: SSL connection()
> error:
> > > > > > >> > > error:00000000:lib(0)::reason(0)!
> > > > > > >> > > 2023/05/19 08:12:54 [clock.pulseaudio:2] Raised at
> Cry.close
> > > in
> > > > > file
> > > > > > >> > > "src/cry.ml", line 193, characters 11-34
> > > > > > >> > > 2023/05/19 08:12:54 [clock.pulseaudio:2] Called from
> > > > > > >> > > Icecast2.output#icecast_stop in file "outputs/icecast2.ml
> ",
> > > line
> > > > > 596,
> > > > > > >> > > characters 14-34
> > > > > > >> > > 2023/05/19 08:12:54 [clock.pulseaudio:2] Called from
> > > > > > >> > > Icecast2.output#icecast_send in file "outputs/icecast2.ml
> ",
> > > line
> > > > > 509,
> > > > > > >> > > characters 10-27
> > > > > > >> > > 2023/05/19 08:12:54 [clock.pulseaudio:2] Called from
> > > > > > >> > > Output.encoded#send_frame.output_chunks.f in file
> "outputs/
> > > > > output.ml
> > > > > > >> ",
> > > > > > >> > > line 240, characters 10-24
> > > > > > >> > > 2023/05/19 08:12:54 [clock.pulseaudio:2] Called from
> > > > > > >> > > Output.output#output in file "outputs/output.ml", line
> 174,
> > > > > > >> characters
> > > > > > >> > > 10-35
> > > > > > >> > > 2023/05/19 08:12:54 [clock.pulseaudio:2] Called from
> > > > > > >> > > Clock.clock#end_tick.(fun) in file "clock.ml", line 300,
> > > > > characters
> > > > > > >> > > 14-22
> > > > > > >> > > 2023/05/19 08:12:54 [clock.pulseaudio:2]
> > > > > > >> > > 2023/05/19 08:12:54 [asmrpmp3:3] Closing connection...
> > > > > > >> > > 2023/05/19 08:12:54 [clock:2] Error when leaving output
> > > asmrpmp3:
> > > > > > >> could
> > > > > > >> > > not close connection: SSL connection() error:
> > > error:0A000126:SSL
> > > > > > >> > > routines::unexpected eof while reading!
> > > > > > >> > > 2023/05/19 08:12:54 [main:3] Shutdown started!
> > > > > > >> > >
> > > > > > >> > > Any ideas what I can do to mitigate this issue? I'm
> thinking
> > > of
> > > > > > >> checking
> > > > > > >> > > out the latest 2.2.x but I don't know if that has been
> solved
> > > or
> > > > > not,
> > > > > > >> if
> > > > > > >> > > it was even known to begin with, but I don't know how I
> could
> > > try
> > > > > this
> > > > > > >> > > out if I'm using opam.
> > > > > > >> > >
> > > > > > >> >
> > > > > > >> > This looks like a leak in the resources initializations.
> > > > > > >> >
> > > > > > >> > I would definitely try with `2.2.x`. The SSL stack was
> entirely
> > > > > > >> rewritten
> > > > > > >> > there and some resource cleaning issues were fixed. And we
> also
> > > > > have TLS
> > > > > > >> > support now so you have two stacks to try if one still has
> > > issues.
> > > > > > >> >
> > > > > > >> > To use SSL/TLS in v2.2.x you can now pass an abstract
> transport
> > > > > > >> variable.
> > > > > > >> > This is explained here:
> > > > > > >> >
> > > https://www.liquidsoap.info/doc-dev/harbor_http.html#https-support
> > > > > > >>
> > > > > > >>
> > > > > > >>
> > > > > > >> _______________________________________________
> > > > > > >> Savonet-users mailing list
> > > > > > >> Savonet-users@lists.sourceforge.net
> > > > > > >> https://lists.sourceforge.net/lists/listinfo/savonet-users
> > > > > > >>
> > > > > > >
> > > > >
> > > > >
> > > > >
> > > > > _______________________________________________
> > > > > Savonet-users mailing list
> > > > > Savonet-users@lists.sourceforge.net
> > > > > https://lists.sourceforge.net/lists/listinfo/savonet-users
> > > > >
> > >
> > >
> > >
> > > _______________________________________________
> > > Savonet-users mailing list
> > > Savonet-users@lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/savonet-users
> > >
>
>
>
> _______________________________________________
> Savonet-users mailing list
> Savonet-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/savonet-users
>
_______________________________________________
Savonet-users mailing list
Savonet-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to