Hi Owen,

I understand that it's not easy to get started with liquidsoap. I'll
describe how to get what you step by step, and I'll try to make it
clear. Hopefully, we should eventually find out a simple way to
explain that in the wiki. I'm probably not the best person for
explaining liq to newcomers, but it looks like I'm still almost the
only one :p

One slogan: think layers. Simple liquidsoap scripts describe trees:
the elementary sources at the leafs are wrapped in operators at the
nodes, to yield more and more complex sources. Don't try to think of a
liquidsoap script as a perl script.

On 4/10/07, Owen Mehegan <[EMAIL PROTECTED]> wrote:
For a simple start, all I need is the ability to output songs from
one playlist, [...]

Let's first define a source "s" that does that. I'll leave it to you
to tinker with the optional parameters for reloading playlists, cf.
wiki/LiqReference or "liquidsoap -h playlist" with recent versions.

  s = playlist("/path/to/my/playlist")

[...] insert a jingle pulled from another playlist every 4
songs, [...]

Let's define a source that plays your jingles:

  jingles = playlist("/path/to/jingles_playslit")

And now I define a source that plays repeatedly 4 tracks from "s" and
1 from "jingles". It may be a bit weird, but the way to do that is to
ask for a "strict" random with the appropriate weights. A "strict"
random is not random at all, it just follows the quotas.

 new_s = random(weights=[4,1], [s,jingles])

It is a bit annoying to invent a new name (here "new_s") everytime we
wrap a source (here "s"). Especially since we won't have any use of
the old source anymore. Instead, it is possible to just re-use the
same name. It's just a new alias that will hide the old one. In simple
scripts like that you could safely think of it as a modification of s,
but it is wrong and would lead to errors in more complex scripts. So
think of it as a new definition -- and keep in mind that it is just a
way to avoid the invention of names. So we write:

 s = random(weights=[4,1], [s,jingles])

And now "s" refers to a source that plays repeatedly 4 tracks from the
old "s", then 1 from "jingles".

[...] and switch to relaying the remote http.mp3 stream on specific
days and times. [...]

We first define the http relay:

 remote = input.http.mp3("http://whatever";)

Then we have several choices. The example given on the wiki shows how
to fallback to the relay whenever it is ready (track insensitive means
that the switch doesn't wait for the end of track):

 s = fallback(track_sensitive=false, [remote,s])

You are asking for switching during given periods of time:

 s = switch(track_sensitive=false,
                 [ ( { 0h-10h }, remote ),
                   ( { true }, s ) ])

It says that "s" should be playing "remote" between 0:00 and 9:59, and
the old "s" the rest of the time. The "track_sensitive" says that it
is okay to switch in the middle of a track -- either from "remote" to
"s" or the other way around.

[...] I can write a perl script that will connect to the
liquidsoap telnet port and run studio.start and studio.stop, and I
wonder if it would be simpler to schedule that in cron, and use the
http.mp3 stream as a fallback or something in Liquidsoap, so that I
can change the schedule anytime without having to restart LS.

For doing so, go back to the first solution and just add
autostart=false to the HTTP input. It won't be activated at startup,
and you can turn it on/off using your script via the telnet interface.
The fallback will automatically switch to it when it gets ready.

If  there's any extra code needed to get the stream NOT to switch to the
studio when it detects silence (i.e. no one is IN the studio :) that
would be useful.

For doing so, we are going to wrap the "remote" stream in an operator
that makes it look like unavailable when it is streaming blank. Add
the following right after the first definition of "remote", before its
use in the switch or fallback:

 remote = strip_blank(remote)

I'll let you tinker with blank detection's parameters. These are
tricky, and I actually changed them to decibels in the experimental
branch, which should be merged soon.

I don't really know how to conclude. Write all your script as just one
big expression without any variable definition and identify the big
tree ?...

Hope that helps.
--
David

Reply via email to