Advanced Conditional Scripting

You are missing a feature or need an enhancement? Post your suggestion here!
inl_inc
Posts: 76
Joined: 12 Dec 2013 18:42
Advanced Conditional Scripting

Post by inl_inc »

Would it be possible to expand the scripting function to allow dynamic scripting based on comparing characteristics of a previously queued track to pick the next track. For example, if currently queued track is 80bpm then the next track the script selects would be filtered to be +/- 20bpm (i.e. BPM>=60 AND BPM<=100). The exact conditions to use would be defined by the user.

Right now I'm accomplishing this by using a control command to write a text file when track A is scheduled with filter characteristics for the next track B. Then using the filter for the next scripted track by reading the text file to set the filter for track B, etc. But it would be nice to have this feature built it, as it would be more dependable and allow for multiple comparisons.
inl_inc
Posts: 76
Joined: 12 Dec 2013 18:42
Re: Advanced Conditional Scripting

Post by inl_inc »

If you for example add a filter condition to two subsequent script-line, wouldn't that achieve the same?
E.g.
Script-Line 1 Filter: (BPM>=60 AND BPM<=100) AND (...more filter options...)
Script-Line 2 Filter: (BPM>=60 AND BPM<=100) AND (...more filter options...)
Not exactly, because setting static filters like this would result in the exact same sequencing of each program (BPM also was probably not the best example here). I still want to have an element of randomness, within my defined set of parameters.
a) String values (like Genre, Mood, Grouping, Album, Artist, Year, ... etc.):
With all these fields you might only do an 'equals' comparison?!
Something like: 'where this.Genre equals previous.Genre'
However is that really needed?
You are correct, however if string values are re-defined in terms numerics that would allow for > and < comparisons (i.e. RatingValue field can store something other than rating ...). It's really up to the imagination of the programmer how this can be used.

This feature would allow programming of playlists that are still random, but allow for good flow because they are based on a defined set of rules. Just as an example, you probably don't want a pop song to be followed by heavy metal track and finished by a dance song ... Or if track 1 has a vocal end, track 2 should not have a cold vocal opening.
I am not sure, if that is entirely possible and even needed.
If it's not possible to implement in ProppFrexx, then it's a whole different question ...
inl_inc
Posts: 76
Joined: 12 Dec 2013 18:42
Re: Advanced Conditional Scripting

Post by inl_inc »

Anyways it would be nice to have the ability for script line B to be able to get from memory song characteristics of the track queued by the previous script line A, in order to use these values for comparisons in the filter of script line B.
User avatar
radio42
Site Admin
Posts: 8295
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: Advanced Conditional Scripting

Post by radio42 »

Please take at the new v3.0.14.3 - which I just uploaded.

It adds something to play with... a kind of a first version. It doesn't cover all possible dynamic or conditional filters, but at least a lot.

You can now use standard track macros within script-line filters. Any regular track macro like for example ${genre} will then be replaced by the data of the last scheduled track.
E.g. the following filter would make sure, that the Genre of the current script-like is the same as the genre of the previous scheduled track; but the rating must be different:
~[Genre] == '${genre}' And [Rating] <> '${rating}'
User avatar
radio42
Site Admin
Posts: 8295
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: Advanced Conditional Scripting

Post by radio42 »

I am not sure, if that is entirely possible and even needed.

Let's look at what values might be dynamically compared to a 'previously scheduled track'?

a) String values (like Genre, Mood, Grouping, Album, Artist, Year, ... etc.):
With all these fields you might only do an 'equals' comparison?!
Something like: 'where this.Genre equals previous.Genre'
However is that really needed?

b) Numerical values (BPM, RatingValue, AgeCount, AgeCreation ... etc.):
With these fields you might theoretically do a range comparison (>=X and <=Y).
Something like 'where this.BPM is between [previous.BPM - X] and [previous.BPM + Y]'

But this would only make sense for very certain numerical value (like BPM), but not with all.
E.g. the PlayCount field doesn't make much sense.

Thinking further this basically leaves me with the BPM field along, which makes sense.

What other dynamic field comparisons do you have in mind?

If you for example add a filter condition to two subsequent script-line, wouldn't that achieve the same?
E.g.
Script-Line 1 Filter: (BPM>=60 AND BPM<=100) AND (...more filter options...)
Script-Line 2 Filter: (BPM>=60 AND BPM<=100) AND (...more filter options...)

An alternative is to use an additional meta data field for filtering. E.g. I assume in your case you would want to select a subsequent track with a similar mood.
So why not using the 'Mood' field directly, e.g. tag your audio files with a mood like value and the use this?
I am not sure how you would want to configure those additional rules as additional dependencies between sub-sequent script-lines?
User avatar
radio42
Site Admin
Posts: 8295
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: Advanced Conditional Scripting

Post by radio42 »

I see what you mean...and I#ll take a look of what can be done...

Until then, you might look to the 'Script-Rules' feature: with script-rule you can actually today define rules like "after a pop song do not followed a heavy metal track"...
See here: viewtopic.php?f=4&t=705&hilit=Script+Rules
...however if string values are re-defined in terms numeric...
No, string values are always string values!
'RatingValue' just tries to convert the 'Rating' string to a number (to e.g. translate stars '***' to its equivalent numeric value).
inl_inc
Posts: 76
Joined: 12 Dec 2013 18:42
Re: Advanced Conditional Scripting

Post by inl_inc »

Bernd thank you for implementing these changes so quickly. This is one of the many reasons why ProppFrexx is a great scheduler/playout system.

Looks like the macros are working correctly - will look over the overnight playlist logs tomorrow morning to check if the rules were being followed. But so far so good. Thanks again!
inl_inc
Posts: 76
Joined: 12 Dec 2013 18:42
Re: Advanced Conditional Scripting

Post by inl_inc »

Bernd, is there a macro for current system time? And is the filter capable of doing a comparison against a pre-defined time? Right now I have multiple versions of the same script for dayparting (and it gets kinda messy keeping track of what each script does, plus i have to update multiple scripts when making changes to common rules).

For example, have something like:
And
{$currentSystemTime}=<'hh:mm:ss(my upper threshold)'
{$currentSystemTime}>='hh:mm:ss(my lower threshold)'
[myDayPartField]<>'myDefinedValueForTracksThatShouldBeExcludedDuringThePeriod'

Also would it be possible to add an Int() function to use in the filter comparisons. I.e. I store numerical song characteristics in string fields, would be great to be able to convert them to Integers for additional comparisons, arithmetic. And if the function is called with a non-int value just return 0 (false).

I realize I'm asking for a lot of changes here, and I really hope that I'm not the only one who will find them useful ;-). This will set ProppFrexx miles apart from all the other "jukebox" schedulers (IHMO, of course)
User avatar
radio42
Site Admin
Posts: 8295
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: Advanced Conditional Scripting

Post by radio42 »

All questions are valid, I would add them if I wouldn't find them useful myself ;-)

I'll take a look what additional functions might be added...

Regarding the numeric value string translations:
I guess it would be easier to add resp. numeric fieldnames (like the existing Rating and RatingValue).
I also assume, that it wouldn't make sense to add those additional fields for all, e.g. I guess no one would need to translate 'Title', 'Artist' or 'Album' to a numerical value?!
So what fields do you have in mind?

Here is a list of available (string) fields:
Filename, Trackname, Title, Artist, Album, Mood, Grouping, ISRC, Year, Genre, AlbumArtist, Comment, Composer, Conductor, Copyright, DiscNumber, EncodedBy, Lyricist, Producer, Publisher, Remixer, TrackNumber.

What fields do you find useful to 'translate'?

In addition I think, that it might also make sense to add an extra 'Condition' column to a script-line. Which is evaluated and if the condition evaluates to false that entire script-line would be skipped/ignored.

Note, that the script-line Filter effectively evaluates/applies to the tracks of the given library - so it filters 'certain' tracks out of all available!
In your example above ({$currentSystemTime}=<'hh:mm:ss(my upper threshold)'...) it sounds, that this wouldn't make sense to be used in a filter; as the system date/time isn't an attribute of a track such filter would either always fail or match for all tracks!
So that example more sounds like a real script-line condition, e.g. do not use this script-line during morning hours...?

For a list of all macros see the Appendix in the User Manual.
For the current system date and/or time you might use the following macros:
${now} : the current date and time in format ‘yyyy-MM-dd HH:mm:ss’
${yyyy} : the current year (4-digits)
${yy} : the current year (2-digits)
${MM} : the current month (2-digits, 01-12)
${dow} : the current day of the week (1=Monday…7=Sunday)
${week} : the current Iso8601 week number 2-digits (00-53)
${dd} : the current day (2-digits, 01-31)
${HH} : the current hour (2-digits, 00-23)
${mm} : the current minute (2-digits, 00-59)
${ss} : the current second (2-digits, 00-59)

E.g. you might use something like this:
${HH}${mm}${ss} >= ''
inl_inc
Posts: 76
Joined: 12 Dec 2013 18:42
Re: Advanced Conditional Scripting

Post by inl_inc »

Here is a list of available (string) fields:
Filename, Trackname, Title, Artist, Album, Mood, Grouping, ISRC, Year, Genre, AlbumArtist, Comment, Composer, Conductor, Copyright, DiscNumber, EncodedBy, Lyricist, Producer, Publisher, Remixer, TrackNumber.

What fields do you find useful to 'translate'?
Currently I'm using Producer, EncodedBy, DiscNumber and TrackNumber to store numeric representations of song characteristics.
In addition I think, that it might also make sense to add an extra 'Condition' column to a script-line. Which is evaluated and if the condition evaluates to false that entire script-line would be skipped/ignored.
Yes - this feature would be nice, as it would allow to mimic an IF statement.

Thanks for the sharing the time related macros, going to play round with them.

Post Reply