Hi Again Christopher:
I have just found out how to find the length of an audio file!
Use the "soxi" utility:
kevin@citadel:~/radio/content/news$ ls -l wx.ogg
-rw-r--r-- 1 kevin kevin 405420 Apr 4 16:45 wx.ogg
kevin@citadel:~/radio/content/news$ soxi -D wx.ogg
71.124490
kevin@citadel:~/radio/content/news$
71.12 seconds.
Perfect, you can use this to build a 28 minute set of music!
Kevin
On 2013-04-04, at 2:29 PM, Kevin McQuiggin <[email protected]> wrote:
> I am pretty much a novice myself but I will try to help!
>
> The good thing about the playlists and the audio files indicated in the
> playlists is that they can change dynamically, and liquidsoap will notice and
> use the updated playlist and/or audio files.
>
> What I am doing in my application is using shell scripts external to
> liquidsoap to build the playlists and audio files on the fly. I use crontab
> to schedule updates of the audio files and playlists, and then the liquidsoap
> code always uses the latest versions.
>
> In my application, I have a newscast that I want to follow a standard format
> at the top of the hour. I use a shell script to replace the audio files
> indicated in the "news.pls" file every hour. I do the same with weather at
> the bottom of the hour.
>
> You can also change the lines in the playlist file itself and liquidsoap will
> track the changes.
>
> In my application I like having the flexibility of using shell scripts while
> leaving the audio and timing specific stuff to s simpler liquidsoap program.
> Fact is that because I am new I don't really know if (or how) this can all be
> done within liquidsoap. You can use C, Python, or any language in fact to
> build and modify the playlists and audio files, of course. I am using Bourne
> shell scripts (#!/bin/sh) only because I haven't had a need for anything more
> complex yet.
>
> In your case, write a script to choose the item from "liners", the item from
> "comedy", and combine them with a selection of items from "music" into a
> playlist. Then run this script every hour or half hour. Point liquidsoap at
> your .pls file and this will solve the problem, except for one aspect: the
> specific 28 minutes of music.
>
> What I would do in this case (in fact I have a need for this myself) is to
> investigate audio utilities like "sox" to see if they can be used to return
> the length of a particular audio file. Then I would write a little script to
> build 28 minutes of music by choosing tracks and putting them into an ASCII
> .pls file. Put the other two items at the top and bottom, and you're off
> with it!
>
> In my application I have say 100 episodes of a particular radio drama. I
> want to choose one at random for the next show. Here is my Bourne shell
> script:
>
> ---
>
> #!/bin/sh
> if [ ! $1 ]
> then
> echo "Usage: $0 <directory of mp3/m4a files>"
> else
> a=`od -vAn -N4 -tu4 < /dev/urandom`
> echo Random number: $a
> b=`find $1 -name *.mp3 -print | wc -l`
> echo Number of episodes: $b
> c=`dc -e "$a $b % 1 + p"`
> echo Modulus+1: $c
> c="$c"p
> echo c modified: $c
> d=`find $1 -name *.mp3 -print | sed -n $c`
> echo $d
> cp "$d" $1/current.mp3
> fi
> kevin@citadel:~/radio/scripts$
>
> ---
>
> It's still uncommented and has debug "echo" statements in it because I just
> wrote it yesterday. It chooses one of a number of episodes at random and
> copies this to a file called "current.mp3". The associated playlist includes
> an entry for "current.mp3". This script runs once per hour/day/whatever,
> then whenever the show is called on through the switch() construct, the
> randomly-chosen episode will play.
>
> Here's a sample playlist for the science fiction show "X Minus One":
>
> ---
>
> kevin@citadel:~/radio/playlists$ cat xminusone.pls
> /home/kevin/radio/content/ident/id.ogg
> /home/kevin/radio/content/info/xminusone-intro.ogg
> /home/kevin/radio/content/scifi/xminusone/current.mp3
> /home/kevin/radio/content/info/xminusone-trailer.ogg
> kevin@citadel:~/radio/playlists$
>
> ---
>
> I play a station identification, "id.ogg"; then a show intro blurb; then the
> random episode; then end with a show trailer.
>
> This playlist, "xminusone.pls" is a playlist.merge() source that is included
> for triggering at a specific time in a switch() construct.
>
> Hope this helps,
>
> Kevin
>
> On 2013-04-04, at 2:11 PM, Christopher Muldrow <[email protected]>
> wrote:
>
>> This is great information. Let me ask one dumb question. Is there a good way
>> to dynamically merge the 30-minute playlists from the separate sources? In
>> other words, I've got
>> music = playlist(mode='random', "/mnt/musicMount/watch/BLUES/")
>> comedy = playlist(mode='random', "/mnt/musicMount/watch/COMEDY/")
>> liners =
>> playlist(mode='random',"/mnt/musicMount/music/imported/4/unknown/unknown/")
>> If I want one thing from "liners" and then one thing from "comedy" and then
>> 28 minutes from "music," can I make that happen? i thought merge_tracks
>> would do that, but it's clearly not for that. Should I be reading up on PLS
>> files to do this operation in the PLS file instead of inside of the
>> Liquidsoap code?
>> Thanks!!
>>
>>
>> On Thu, Apr 4, 2013 at 4:54 PM, Kevin McQuiggin <[email protected]> wrote:
>> Hi Chris:
>>
>> I just had (and solved) the same problem!
>>
>> Put your two show lineups into two playlists, call them "program1.pls" and
>> "program2.pls".
>>
>> Use playlist.merge() to create a single track out of the playlists. You
>> need a short macro/function definition for this, see below.
>>
>> Then use a switch() construct to schedule the two merged playlists at the
>> top and bottom of the hour.
>>
>> You can do it like this:
>>
>> ---
>>
>> def playlist.merge(uri) =
>> pl = playlist.reloadable(uri)
>> reload = fst(pl)
>> s = snd(pl)
>> s = merge_tracks(s)
>> on_end(delay=0.,fun(_,_)->reload(),s)
>> end
>>
>> security=single("some file to play when all goes wrong")
>> x = audio_to_stereo(playlist.merge("program1.pls"))
>> y = audio_to_stereo(playlist.merge("program2.pls"))
>> s=switch([ ({0m}, x),
>> ({30m}, y)
>> ])
>>
>> radio = fallback(track_sensitive=false, [
>> s,
>> security
>> ]
>> )
>>
>> ---
>>
>>
>> You may not need the audio_to_stereo() function if your files are already
>> 2-channel.
>>
>> Hope this helps, it works for me,
>>
>> Kevin
>>
>>
>>
>>
>> On 2013-04-04, at 12:42 PM, Christopher Muldrow <[email protected]>
>> wrote:
>>
>> > I'm trying to use Liquidsoap to play a jingle, then a news report, then a
>> > weather report at the top of the hour (00m0s). Then I want it to play
>> > music pulled from a single folder until the bottom of the hour (30m0s),
>> > when I want to play another jingle, replay the news report and replay the
>> > weather report. The jingles are in a folder. The news and weather are
>> > single files on the file system. I've tried using a switch, but the news
>> > and weather files aren't necessarily the same length every day, so I can't
>> > figure out how to set the value in the switch to peg the time for this
>> > whole sequence to begin. Any hints?
>> >
>> > --
>> > Chris Muldrow
>> >
>> >
>> > ------------------------------------------------------------------------------
>> > Minimize network downtime and maximize team effectiveness.
>> > Reduce network management and security costs.Learn how to hire
>> > the most talented Cisco Certified professionals. Visit the
>> > Employer Resources Portal
>> > http://www.cisco.com/web/learning/employer_resources/index.html_______________________________________________
>> > Savonet-users mailing list
>> > [email protected]
>> > https://lists.sourceforge.net/lists/listinfo/savonet-users
>>
>>
>> ------------------------------------------------------------------------------
>> Minimize network downtime and maximize team effectiveness.
>> Reduce network management and security costs.Learn how to hire
>> the most talented Cisco Certified professionals. Visit the
>> Employer Resources Portal
>> http://www.cisco.com/web/learning/employer_resources/index.html
>> _______________________________________________
>> Savonet-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/savonet-users
>>
>>
>>
>> --
>> Chris Muldrow
>> Chief Digital Officer
>> The Free Lance-Star Companies
>> [email protected]
>> 540-368-5006
>> ------------------------------------------------------------------------------
>> Minimize network downtime and maximize team effectiveness.
>> Reduce network management and security costs.Learn how to hire
>> the most talented Cisco Certified professionals. Visit the
>> Employer Resources Portal
>> http://www.cisco.com/web/learning/employer_resources/index.html_______________________________________________
>> Savonet-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/savonet-users
>
> ------------------------------------------------------------------------------
> Minimize network downtime and maximize team effectiveness.
> Reduce network management and security costs.Learn how to hire
> the most talented Cisco Certified professionals. Visit the
> Employer Resources Portal
> http://www.cisco.com/web/learning/employer_resources/index.html_______________________________________________
> Savonet-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/savonet-users
------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users