Perfect Time - backtiming script (collective effort!)

I’d like to pull our resources and see if we can come up with a script that looks at an hourly playlist and shaves-off the end of songs (that fade) to produce a perfect hour with a smooth junction into a news feed at 00:00. I’ve started the script, here’s a sample - perhaps Cad would like to have a go, too ? 8)

[code]const
// This assumes that you want to hit a news intro and it’s 15 seconds long
BACKTIME = FormatDateTime(‘hh’, now) + ‘:59:45’ ;

// This assumes that you want to want to backtime until 2 minutes past the hour
//BACKTIME = FormatDateTime(‘hh’, now + 0.04166) + ‘02:00’);

// Sets the maximum permitted time that can be removed from a song - 30 seconds
CROP_TIME = 300000000;

if CurrentPlaylist.GetItem(i).GetEndType = ‘f’ then

begin

<the science bit goes here!>

// If the script was successful
SystemLog(‘Perfect Time … SUCCESS!’)

// If there was a problem - ie: couldn’t crop enough time to fit hour
SystemLog(‘Perfect Time … ERROR: x seconds over!’)[/code]

That’s the basic idea… Hopefully we can fill the gaps together.

I get the intention of your code, Charlie, but I’m not sure that FormatDateTime is the right kind of time value to check against total Playlist duration? Actually, I’m not sure how to check total Playlist duration either :-, unless it’s something like:
(EstimatedStartTime of final item) + (EffectiveDuration of final item)
But if someone can tell me how to Do That, then it should all be pretty simple.

I would expect the code would do something like this:

  1. Determine whether Playlist is currently ‘over’ time, and by how many seconds.
  2. Count number of ‘fade’ Endings in the Playlist.
  3. Divide number of ‘fades’ by ‘over’ time, and compare that ‘crop per track’ time to max ‘crop.’
  4. If less or equal, move the FadeOut point of all ‘fade’ tracks forward by computed amount from 3.

Does that sound about right to you, Charlie?

(PS: it’s pool our resources—pull sounds rather rude! :-[)

BFN
CAD

Hi Cad,
Yeah - that list looks about right. We have the GetDuration for a Playlist item, so we can add all those together - FormatDateTime was my idea of typing in a simple time/clock format that a casual user could calculate :wink: It may even end up as a +/- offset of “top of the hour” in the usual time format.

ie: BACKTIME = -100000000; // backtime to xx:59:50 , 10 seconds before top of hour

PS: “Pool” it is, then :wink:

GetEffectiveDuration is what you need: GetDuration is the TOTAL duration of the item from end to end ;). Also as I said, all you need is the effective start of the final item, plus its effective duration. Add those two and it will always give you the total Playlist duration correct to within 1 sec.

What I’m working with is TARGET_DURATION = ‘01:00:00’ because I’ve written routines to convert seconds to hh:mm:ss and vice versa. :slight_smile:

I hope to have something working within a day or three: I have had dreadful ‘man flu’ for the past few days. :stuck_out_tongue:

BFN
CAD

OK Charlie, here’s the final PerfectTime script. 8)

As usual with my scripts, all the ‘magic numbers’ etc. are CONSTs so you can easily change things like the target duration, max. adjustment per item, Ending to match on, and so forth.

Also as usual ;), you’ll get sensible information messages if you try to do anything ‘silly.’ :smiley:

IMPORTANT! Due to shortcomings in Pascal Script (=mAirList Script) time and date conversions, hence my need to ‘roll my own’ conversion functions, you MUST specify the target time string as (e.g.) 00:58:30 and NOT (e.g.) 58:30. Anything that isn’t exactly eight characters long won’t work.

Enjoy!

BFN
CAD


PerfectTime.mls (6.95 KB)

Cad,
Thanks and well done for this - it appears to work very well. However, I’ve just realised that maybe my original intention was misleading. Whilst a perfect 1-hour playlist can be created and saved in a production environment - How’s about the on-air side of things ? What I mean is ensuring that a specific point in the Playlist is reached/played at a certain time (in other words: a “soft” Fixed Time item).

Usually, you’d place a backtime marker at the point where you want to hit (a fixed time item is easy within an MLP playlist, but not so for an scheduled M3U) and the software would move to it after the current item. However, having a cluster of songs towards the end of a Playlist and the last few items being a block of adverts and a news in jingle will require some re-jigging of your script. I’ll have a go tonight :slight_smile: I think the script will also have to delete songs that blatantly cannot be trimmed to meet the target time/duration.

Thanks—and you’re welcome!

Probably just me, but I don’t understand how a script could be run on a running live-assist Playlist? Or am I completely missing the point?

  1. Again I don’t understand your point about a block of songs causing problems? All eligible songs get trimmed by the same amount, so I don’t see why that would cause problems in the scenario you describe? Or why the script would need changing?

  2. Since mAirListScript cannot display message boxes (or any other user feedback mechanism—really annoying!), I’m very leery of having a script doing anything drastic like ‘dumping’ songs. The user can’t click Cancel or back things out, and I’m philosophically opposed to ‘gotchas’ being run automatically. Also, presumably someone with >2 brain cells will be running the script, so if the Playlist still comes out ‘over,’ presumably the user can check the signals from those optical input devices either side of their nose ::slight_smile: to determine which songs patently need to be ‘dropped’ manually?

If there are any specific functions you’d like added and/or changed, please give me a detailed description and I’ll be happy to build them in for you. I also hope that some of the functions in the PerfectTime script will be of general use and help to others. I’m pretty sure I for one will be using some of them quite a lot in other scripts!

BFN
CAD

Cad,
I think perhaps this may be something that mAirList could actually do internally (as a config option) rather than a script.

  1. With regards the cluster of songs, it’s common to over schedule an hour because until it’s generated you won’t know it’s exact length - StationPlaylist, for example, gives you an average length of an item based on the average length of audio items in that particular category/spot group. If you are 15mins over in a playlist then you or I would know that we could drop songs from the end of the list rather than fade every song by 30s :wink:

Other systems use playlist command items such as “Play Log To Hour” at the start of the Playlist, and a Time Marker/s within it - these can be soft (for ad breaks or playlist loading) or hard (for news feeds) branches depending upon the required action. It’s quite easy to be within a minute or so of your :20 and :40 ad-breaks - but when you get towards the end of the hour/playlist, you’ve got some timing issues to overcome. There are certain “rules” with other systems that may or may not be “too clever” for our humble scripts… Here are some to consider:

a) Never trim a song by more than x seconds (check)
b) Never trim a song with a natural ending (check)
c) Never drop a song with a voicetrack either side of it

  1. Song-dumping could be achieved by marking them “as played” or perhaps a new soft delete function to remove it from the active items but still be available should the user wish to enable it - ie: removed from the backtiming calculation (a feature that is currently available).

The main aim here is to hit the hour perfectly (ie: a news feed via the line input) without the unfortunate instance of playing the first 10 seconds of “Sultans of Swing” before cutting into the news jingle 8)

One final thought - It’d be a major pain in the bum to run “PerfectTime” on every hourly playlist, or can that be automated, too ?!

I can support Charlie for what it is worth.

Our current home-grown automation system has an application which runs automatically at xx:45:00 and reads the format for the following hour and then ‘compiles’ the appropriate playlist. This includes automatically adding/deleting tracks to get the time to just over an hour then chopping the fading tracks by an equal amount to hit the 60mins.

The calculated start time is written into the hour playlist so the separate playout program only has to start the track at the appropriate time (and fade the previous track if it has not ended!).

It may sound crude but it still makes me smile when a song ends hard, the news bed plays and IRN comes in bang on time [opting out of the news at xx:03 is a different matter of course ;D ]

The down side is of course that there is no adjustment possible once the hour has started. We have considered a ‘rolling’ compiler which looks forward about 20 mins and dynamically ‘adjusts’ the timing to hit the hour point so that it is possible to change the schedule within the hour but never quite got around to it!

Of course CAD has already worked out the flaw to this cunning plan when the clocks go forward one hour (solution is to ‘fudge’ the Sunday 0200 hour in advance) or back an hour (repeats the 0100 hour) - not elegant but it is only twice a year!

Lots to consider there!

Charlie: to implement the ‘no drop if VT either side’ rule, we would need to be able to definitively identify voicetracks. I think that the most generally applicable way would be to ‘pull in’ the code from IVP-MarkEndings which does a full and/or partial match on artist and/or title (you see? all this code does all hang together after a while! ;)). But there is also the issue of working out which songs to drop in the first place! Presumably one would work back from the end, looking for songs which don’t break the ‘rules’ and which are short enough to drop without going ‘under;’ then if you’re still ‘over,’ do the existing ‘trim eligible songs’ stuff. Does that sound like the right way to do it?

As for running the script against multiple files, I know how to iterate all the files in a folder using VB, but have not tried doing that in mAirList scripting: it may or may not be possible (depends on whether the required statements/functions/etc. are available or not, which I’m discovering isn’t possible to predict—at which point the workarounds get written ;)).

Ron: I’ll take your word for it :-[ because frankly I’m a ‘live assist’ sort of guy and I find it very hard to visualise exactly what you’re describing (no doubt it all makes sense to Charlie!). Well … OK, I’ll be honest: never having used a scheduler, actually my brain starts hurting while trying to understand what you’re explaining!

BFN
CAD

Cad

Is it possible to enhance your (excellent) script to work between fixed points in a playlist?

Let me explain - I have a 24h playlist with fixed points every hour at xx:00:00 (start news) and xx:59:54 (start news jingle) therefore the ‘perfect time’ script needs to work it’s magic on the items between the fixed points (59m 54s in this case) in each hour.

I guess this will involve a loop running the curent script between each instance of the fixed time markers but I don’t know how difficult this would be.

Any thoughts?

Ron

Ron,

I don’t quite understand the question as it applies to ‘fixed points?’ It’s so long since I wrote this code that I would need to spend a bit of time reminding myself what the heck it does, and how!

I might be able to do that tonight, but I also have a quick-ish pinball repair to do, and a couple of trails/promos to produce.

BFN
CAD

Cad

I’m sure it will come flooding back to you :wink:

I perhaps should have said items with a ‘fixed time’ assigned to them such as news elements.

Thanks in advance for your help

Ron

Light dawns (slowly!), I think (?).

Is what you’re saying that you’d like to be able to set the ‘finish line’ for an ‘hour’ in PerfectTime from xx:00:00 to xx:59:54 (for example)? And ditto the ‘start line’ might not be xx:00:00 either? If so, let me know: if not, give me a clue!!! :smiley:

(About to start swapping out the slot machine scoop in my Twilight Zone pinball machine for a newer, better made one than the original…)

BFN
CAD

Naah … there’s a better, easier way. Create a new Event in the Event Scheduler to run the script at a sensible number of minutes past each hour. :wink:

When I wrote the script, that’s how I envisaged it being run in practice: from the Event Scheduler. Makes it harder for people to ‘tinker’ with it as well! 8)

BFN
CAD

Cad

A picture paints a thousand words.

What I am trying to achieve with ‘Perfect Time’ is to have a daily schedule similar to the attached image and get the script to ‘adjust’ the fading tracks within the bounds of the fixed time events.

In the case of the example shown, in the 1am hour the script would reduce all 3 fading events by an equal amount to make it fit the time between 01:00:00 and 01:59:54. In the 2am hour it will ‘adjust’ part 2 to make the hour fit between 02:00:00 and 02:59:54 etc.

The aim of this is really for overnight automation so that a schedule template with all the coloured events could be loaded in the evening (hence my other post about ‘locked’ playlist items) and the hours could be filled with the pre-recorded programs until the next morning. The modified ‘perfect time’ script would then run through the playlist and ‘adjust’ the fading tracks to fit within the time given. (and possibly report any under-runs).

I hope that makes things a bit clearer.

Cheers

Ron.

p.s. the shows are in 3 parts so we can insert trailers/ads etc but I have not included them in the example