INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Play Types of Music Based On Current Time of Day  (Read 1880 times)

Jamil

  • Galactic Citizen
  • ****
  • Posts: 395
Play Types of Music Based On Current Time of Day
« on: April 13, 2013, 06:48:58 pm »

I own a couple of Sony digital audio players -- the A867 and the F807.  The A867 has a really neat feature that plays similar types of music based on the current time of day.  It probably does this based on the tempo, intensity, and possibly some other criteria.  My entire library in MC18 has been analyzed, and it looks like I have enough information on each song to do something similar (BMP, intensity, possibly genre, possible last played date).

I would like to play similar music that has been randomized based on the time:

05:00AM - 09:59AM - BPM < 100 / Intensity over 3
10:00AM - 03:59PM - BPM > 99 / Intensity over 3
04:00PM - 07:59PM - BPM >= 70 AND BPM < 100 / Intensity less than 4
08:00PM - 11:59PM -  BPM < 70 / Intensity less than 4

My question is how would I go about doing such a thing? A single smart list cannot do this, since it will query a large selection of songs not honoring the current time of day.  I guess I could create four separate smart lists that have criteria based on the above, but how could I go about choosing the correct smart list based on the time? This would have to be in a loop that re-checks the time.

Is this feasible?

TIA.

kstuart

  • Citizen of the Universe
  • *****
  • Posts: 1955
  • Upgraded to MC22 Master using preorder discount
Re: Play Types of Music Based On Current Time of Day
« Reply #1 on: April 13, 2013, 08:27:52 pm »

I play a smartlist of random classical music in the morning.

I have Windows Task Scheduler starting MC18 and use the commandline option to play that smartlist.

You could do that with Scheduled tasks at each of your specified times.

(I'm pretty sure that running MC18 with a commandline option, will simply use any currently running MC18 if it exists.)

 see:

http://wiki.jriver.com/index.php/Media_Center_Core_Commands

Jamil

  • Galactic Citizen
  • ****
  • Posts: 395
Re: Play Types of Music Based On Current Time of Day
« Reply #2 on: April 14, 2013, 11:04:18 am »

It looks like what I wish to do is not do-able with MC18.

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Play Types of Music Based On Current Time of Day
« Reply #3 on: April 15, 2013, 12:27:06 pm »

A smartlist for this should be doable.

You can use the entire expression language in Search rules, and these rules have access to Now() - the current time of day - and you can use If() statements to compare Now() with your times converted with ConvertDate() to MC format combined with your BPM or Intensity choices.

The best way to test this is by writing the expression fragments in expression columns, testing each piece, and then combining them into a final expression.  Once that is functional, change it to a custom smartlist Search rule:

[=expression]=1

Ask if you need more help with this.
Logged
The opinions I express represent my own folly.

Jamil

  • Galactic Citizen
  • ****
  • Posts: 395
Re: Play Types of Music Based On Current Time of Day
« Reply #4 on: April 15, 2013, 05:46:58 pm »

Okay -- this makes sense.  I understand.

A single smart list that has criteria based on both Now(), the BPM and intensity checks.

I will play around with this later.

Thank you.

Jamil

  • Galactic Citizen
  • ****
  • Posts: 395
Re: Play Types of Music Based On Current Time of Day
« Reply #5 on: April 15, 2013, 07:07:52 pm »

I experimented a little with this following your suggestion of testing expression fragments.  I started with a simple test of this:

if( IsRange( FormatDate( Now(), hour), 5-9), TRUE, FALSE )

It is 8PM here now, so this returns FALSE.  It works fine.

What I am unsure of is how to combine multiple tests.  It does not look like AND is supported within if():

if( IsRange( FormatDate( Now(), hour), 1-23) AND 1 = 0, TRUE, FALSE )

This returns TRUE.  It looks like the "AND 1 = 0" is being ignored.

I tried to nest if statements thinking the true portion could be another if, which would emulate an AND:

if(IsRange(FormatDate(Now(), hour), 1-23), if (compare(1, =, 1), TRUE, FALSE ), FALSE)

This returns:
1, FALSE)

I am not understanding what the code is doing here.

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Play Types of Music Based On Current Time of Day
« Reply #6 on: April 15, 2013, 07:10:19 pm »

Remove the space after your if and before the first paren:

   if (

should be

   if(


See this page for AND, OR, XOR:

   http://wiki.jriver.com/index.php/Database_Expressions_AND_OR_And_XOR
Logged
The opinions I express represent my own folly.

Jamil

  • Galactic Citizen
  • ****
  • Posts: 395
Re: Play Types of Music Based On Current Time of Day
« Reply #7 on: April 15, 2013, 07:12:09 pm »

Ah -- thank you!

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Play Types of Music Based On Current Time of Day
« Reply #8 on: April 15, 2013, 07:16:23 pm »

You may also be able to get away with a series of simple Less Than tests, since you have a sequence of non-overlapping ranges.

pseudocode:

  IfElse(
     now <= 10, ...,
     now <= 16, ...,
     now <= 20, ...,
     1, ...
  )
Logged
The opinions I express represent my own folly.

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Play Types of Music Based On Current Time of Day
« Reply #9 on: April 15, 2013, 07:21:58 pm »

Here's another trick that can help prevent nest If() statements:

Combine the tests you would normally use in nested If() statement to create a sequence of result strings.  Then test that result string.  For exampie:

   IsRange(FormatDate(Now(), hour), 5-9):Compare([BPM], <, 100):Compare([Intensity], >, 3)

This will produce a string with three 0 or 1 values separated by :, which you can test against a string which you know stands for ALL True:

    if(isequal(above sub expression, 1:1:1), true, false)
Logged
The opinions I express represent my own folly.

Jamil

  • Galactic Citizen
  • ****
  • Posts: 395
Re: Play Types of Music Based On Current Time of Day
« Reply #10 on: April 16, 2013, 04:01:36 am »

I got the combination trick above to work only with expressions.  It does not seem to work correctly when used with a smartlist.  I tried it a couple times and also tried removing all whitespace, but what I enter ends up changed after I click OK.

Now I am running into an issue where MC is completely unresponsive.  It is playing my music, but it is acting like a modal dialog is currently showing (even though one is not present at all).  I am going to have to kill the process to regain control.

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Play Types of Music Based On Current Time of Day
« Reply #11 on: April 16, 2013, 04:09:31 am »

I'll give you the expression tomorrow -- I'm not at my computer currently.
Logged
The opinions I express represent my own folly.

Jamil

  • Galactic Citizen
  • ****
  • Posts: 395
Re: Play Types of Music Based On Current Time of Day
« Reply #12 on: April 16, 2013, 08:17:02 am »

Thinking about this a bit more, I do not understand how a smart list will do what I am looking for.  A smart list is a one time dynamically created play list.  After creation, it becomes static unless I manually change it.

What I am looking for is dynamic in nature.  I am currently not able to get expressions to work in a smart list.  Even if I could get them to work, the smart list will contain content based on the time of day I created it.  This is not what I am looking for.  I am looking for a play list that dynamically changes based on the time of day.  kstuart's proposal is close to what I am after, but it is hack-like.

I looked for a way to do this through COM, but I was not finding a way with my quick searches.

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Play Types of Music Based On Current Time of Day
« Reply #13 on: April 16, 2013, 12:11:44 pm »


A smartlist defines a selection of files based on the evaluated criteria.  The criteria are not reevaluated until the list is refreshed or reused in some way.  Once you Play something in MC, the Playing Now playlist is populated with the selected file set.  It is *this* list that remains static.  To have the current playing now scrapped and filled with new content, you'll have to schedule something to refill Playing Now.

You can use the smartlist I've mentioned here as the basis for generating the correct files to populate Playing Now.  And you can later call upon a scheduling tool to place new Playing Now content (using the same smartlist) to play next (after the currently playing track, or you could abort playback and replace all of Playing Now).

Play Doctor generates new content at intervals of 100 songs, but this period is too long to ensure your time period crossovers are honored.


The expression that accomplishes what you want is:

ifelse(
   compare(formatdate(Now(), H.mm, 10), <, 10),
      math(below([BPM], 100) & above([Intensity], 3)),
   compare(formatdate(Now(), H.mm, 16), <, 16),
       math(above([BPM], 99) & above([Intensity], 3)),
   compare(formatdate(Now(), H.mm, 20), <, 20),
       math(above([BPM], 69) & below([BPM], 100) & below([Intensity], 4)),
   compare(formatdate(Now(), H.mm, 23.59), <, 23.59),
      math(below([BPM], 70) & below([Intensity], 4)),
   1, 0
)

This produces a 1 when the criteria are met and a 0 otherwise.  To wrap it up into a smartlist, use the [=expression]=1 construct:

[=ifelse(compare(formatdate(Now(), H.mm, 10), <, 10), math(below([BPM], 100) & above([Intensity], 3)),compare(formatdate(Now(), H.mm, 16), <, 16), math(above([BPM], 99) & above([Intensity], 3)), compare(formatdate(Now(), H.mm, 20), <, 20), math(above([BPM], 69) & below([BPM], 100) & below([Intensity], 4)), compare(formatdate(Now(), H.mm, 23.59), <, 23.59), math(below([BPM], 70) & below([Intensity], 4)), 1, 0)]=1

Logged
The opinions I express represent my own folly.
Pages: [1]   Go Up