Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: [Request] Weighted random playback (Read 8435 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

[Request] Weighted random playback

Hi foobar community!

I'm not sure if this has already been requested, but a forum search with the keywords above didn't bring any results.

With all those nice ways to create metadata from playback-statistics (e.g. hotness, hot-or-not, auto-rating, ...) I think it is a shame that they are only useful for sorting and eye-candy purposes at the moment. I would be glad to be able to influence a track's playback frequency with TAGZ, too.

foo_skip shows me how such a component could work: I set up a TAGZ string which returns a value between 0 (skip never) and 1 (skip always), so-to-say a skip probability. A little modification in foo_skip should already make this functionality possible. But in general I would prefer a variant which does not require the song to be loaded before, i.e. the next song can be calculated in the background.

The idea behind this is that I can get different playback experiences from one single playlist file (e.g. an autoplaylist containing all music [not speech]) without having to code a seperated autoplaylist. For example
"Play (more probably, not only!) what I haven't heard for a while",
"Avoid everything from %genre%",
"Give me the high rated ones!", ...

I'd like to hear your opinion about that,

ojdo

[Request] Weighted random playback

Reply #1
That would be really cool. Just curious, is there any other music player that already does this?
Everything I've learned about space, I've learned from psytrance.

[Request] Weighted random playback

Reply #2
I would prefer a variant which does not require the song to be loaded before, i.e. the next song can be calculated in the background.

i would love to have this. right now, foo_skip can go through several songs, even playing the first split-second of some of them, before landing on a song that passes the filter. this is annoying and i can't use crossfading because of it.

[Request] Weighted random playback

Reply #3
I have simulated this behaviour by using a VB.net console application that reads my rating tags and outputs the filename into an M3U multiple times.  This effectively gives a weighted playlist.

From an SDK perspective, do we have control over the shuffle mechanism and can we write our own component that will modify the algorithm?

Cheers,

c0utta

[Request] Weighted random playback

Reply #4
Oh yes!

And a fuzzy logic interface too, maybe...

[Request] Weighted random playback

Reply #5
And a fuzzy logic interface too, maybe...

I know about fuzzy logic, but what is a fuzzy logic interface
When I imagine an interface for a possible plugin I tink of something quite simple like foo_skip. The only "fuzzy" part of all this is the calculated skip probability and it is the user's task to make it as... fuzzy (i.e. result in digital skip [1]/don't skip [0] or a value between [0.5=skip in 50% of all cases) as he wishes to.

Example:
Code: [Select]
$ifgreater(%_hotness%,60,'0.8','0.2')

This would skip a track with hotness greater 60 with a probability of 80%, otherwise 20%. I'm quite sure that there could be some nifty algorithms possible.

[Request] Weighted random playback

Reply #6
A little update from the foo_skip-thread: As I learned from a post by SoulMan $rand() can be used in foo_skip to - for example - play high rated tracks more often than low rated:

Code: [Select]
$if($or(%skip%,$greater($add(1,$rand(10)),$add($mul($if2(%rating%,2),2),1))),1,0)


The $greater-function compares a random integer from 1 to 10 with 2*%rating%+1. If no %rating% is present, a value of 2 is assumed. The result:

Code: [Select]
// R = %rating%
R | 2*R+1 | Skip probability
--+-------+------------------
0 | 1     |  90%
1 | 3     |  70%
2 | 5     |  50%
3 | 7     |  30%
4 | 9     |  10%
5 | 11    |   0%


The only bad thing is that this results in a kind of playlist-hopping, until foobar finds a track to play. A solution which would calculate the next song to play in advance would be much more elegant.

ojdo

[Request] Weighted random playback

Reply #7
BUMP!! 

foo_skip is very nice, but as mentioned a few times in this thread, it's not *great*. I think it would be fairly simple for a developer, to make a foo_skip, that actually looks ahead in the playlist and not just evaluates after the skip! ...hint hint 

In regard to the weighted playback function, I did this just before I found this thread:
Code: [Select]
// R = %rating%
R | Skip probability
--+------------------
0 |  100%
1 |  80%
2 |  60%
3 |  40%
4 |  20%
5 |   0%


And the code I came up with:
Code: [Select]
$if($greater($add($mod($rand(),4),2),%rating%),1,0)


Edit: And beware, I don't take any responsability for this code. It has no checking whatsoever, and does not take untagged files into account!
Can't wait for a HD-AAC encoder :P

[Request] Weighted random playback

Reply #8
Foosion always goes on and on about how random playback isn't supported in the SDK every time this comes up.  This is the 3rd that I've counted.  But, I still want it. ;]

[Request] Weighted random playback

Reply #9
Foosion always goes on and on about how random playback isn't supported in the SDK every time this comes up.  This is the 3rd that I've counted.  But, I still want it. ;]

Maybe, but still - since the random play now is a pre-created list of random tracks, how hard could it be to implement?

And we don't get it if we don't whine about it 
Can't wait for a HD-AAC encoder :P

[Request] Weighted random playback

Reply #10
Agreed on the whining.  I'm sure there's more complex ways to implement this type of thing, but it generally wouldn't be worth the trouble when it would be easier to implement in the SDK.  However, it has been some months since this was first brought up, and we don't know when or if there will ever be an update.

Something like background automatic playlist generation (the old history component made a seperate playlist) seems somewhat complicated, but I'm not a coder by choice (I fear that it would consume what little I consider to be my life).

Then there's the whole random-not-being-truly-random discussion, blah, blah, blah... I forgot the point I was trying to make, or if there was one...

[Request] Weighted random playback

Reply #11
Agreed on the whining.  I'm sure there's more complex ways to implement this type of thing, but it generally wouldn't be worth the trouble when it would be easier to implement in the SDK.  However, it has been some months since this was first brought up, and we don't know when or if there will ever be an update.
iirc peters point of view was like "make your own playlist manually" when it was about the playback queue. Maybe this also applies here...

[Request] Weighted random playback

Reply #12
I would like this for a different reason: to make every a song on every ALBUM the same chance of playing, not songs. That way 3 track albums would have as much chance of playing a song as 20 track ones. The only way to do this with a playlist is to duplicate tracks, which is ugly.
err... i'm not using windows any more ;)

 

[Request] Weighted random playback

Reply #13
I would like this for a different reason: to make every a song on every ALBUM the same chance of playing, not songs. That way 3 track albums would have as much chance of playing a song as 20 track ones. The only way to do this with a playlist is to duplicate tracks, which is ugly.

If you have tagged your albums with %total tracks% (or whatever that tag is called) you could use a variant of my skip-control:

$if($greater($mod($rand(),%total tracks%),0),1,0)

Takes a random number between 0 and %total tracks%, and skips if it's above 0. Should make every album have the same amount of proberbility (but still has the disadvantage of foo_skip beginning to play every skipped track though).

Note, I did not test the code above. Edit: ...and I would assume that this code would skip ALOT!!! (All I want for christmas is... that Peter allows components to take control of the playlists  )
Can't wait for a HD-AAC encoder :P