HydrogenAudio

Hosted Forums => foobar2000 => 3rd Party Plugins - (fb2k) => Topic started by: foosion on 2005-08-28 21:55:48

Title: foo_random
Post by: foosion on 2005-08-28 21:55:48
The component adds support for playlist entries that map to a random entry of a subset of the Media Library on playback.

The component adds a decoder for URIs of the form
Code: [Select]
random:|query|
where query is a valid playlist generator query. The component provides a main menu command to add ("Playlist/Add randomized entry...") and a playlist context menu command to edit ("Edit randomized entries...") entries of this form. The context menu command replaces the existing entry with the new one. It is recommended that you use these commands to manipulate randomized entries instead of the "Add location..." command, as they also check that the query is syntactically valid.

The use of random: paths is limited to playback, i.e. you cannot use them with the Replaygain scanner or the converter. This is by design.

When a randomized entry is played, it will fiter the contents of the Media Library using the specified query and randomly chose one of them. During playback, the static metadata of the chosen track is made available to the player as dynamic information of the random: entry. This works similar to audio streams on the Internet. The dynamic metadata is augmented with "played_path" and "played_subsong" tech info fields that hold the location of the chosen track. The dynamic data of the chosen track is not available.

Note that dynamic metadata is available in (some) titleformatting scripts, including the playlist, main window caption and statusbar. It is however not available to the DSP pipeline, so Replaygain is applied by foo_random using the core settings.

There are a number of error conditions that can lead to the component not being able to play a "real" track. If the Media Library is empty or no tracks are left after filtering its contents, the component will raise a "Not found" type error. An error occurs as well, if the query is not syntactically correct. More information is printed on the console under these conditions.
If you try to use the Replaygain scanner or the converter on a randomized entry, the component will raise an "Access denied" type error. The same happen, if you try to change the tags of a randomized entry.
Title: foo_random
Post by: Silverbolt on 2005-08-29 08:23:50
Thanks, foosion.
Title: foo_random
Post by: foosion on 2005-08-29 10:50:01
Updated to version 1.1.

The component now outputs which file it picked for playback.

There is an issue with full file buffering affecting this component. If you get a "Not found" type error without any console messages originating from foo_random, try turning full file buffering off. This should be fixed in the next beta.
Title: foo_random
Post by: Killmaster on 2005-08-31 01:25:43
Hey this is pretty cool, thanks
Title: foo_random
Post by: mixderax on 2005-08-31 16:26:10
1) When playing random song if pause is presed, the position slider goes to begining but when resuming jumps back.
2) When resume playback on start is enabled, when started a new song is chosen and it starts playing from place where the one that played before exiting. Yust wondering what will happend when the song chosen on startup is shorter than the progress on song playing before exiting.
Title: foo_random
Post by: foosion on 2005-08-31 16:38:22
Quote
1) When playing random song if pause is presed, the position slider goes to begining but when resuming jumps back.[a href="index.php?act=findpost&pid=324001"][{POST_SNAPBACK}][/a]
That is an issue in the user interface. Nothing that can be solved in foo_random.

Quote
2) When resume playback on start is enabled, when started a new song is chosen and it starts playing from place where the one that played before exiting. Yust wondering what will happend when the song chosen on startup is shorter than the progress on song playing before exiting.[a href="index.php?act=findpost&pid=324001"][{POST_SNAPBACK}][/a]
It will attemp to seek to the remembered point, hit the end of the file and skip to the next song (as determind by the playback order).
Title: foo_random
Post by: mixderax on 2005-08-31 16:47:57
Thank's
Title: foo_random
Post by: hunted on 2005-09-07 04:29:32
I know this is pretty trivial, but is there a chance of being able to set a title for the query, that is displayed when the track is not playing. If I were to make a really long query, it will get truncated.  I like the 'Random:' part, but if we could give it our own title, that might making the playlists easier to read.
I guess if you plan on releasing the source like you have with your other components, I will add this myself, but maybe other people would find this useful.
Title: foo_random
Post by: NEMO7538 on 2005-09-07 06:19:37
When a track is playing it would be nice also that Right Click --> Properties provides with the properties of the currently playing track (not the query).

.... if this is feasible.
Title: foo_random
Post by: foosion on 2005-09-07 08:42:02
hunted:
I'll think about it.

NEMO7538:
Unfortunately not.
Title: foo_random
Post by: foosion on 2006-03-13 10:43:20
foo_random updated for 0.9 RC 2006-03-11.
Title: foo_random
Post by: nightgaunt on 2006-04-10 19:58:25
foo_random updated for 0.9 RC 2006-03-11.


This is an awesome plug-in, and I'm totally psyched to be able to use a custom ratings-weighted shuffle. It looks like foo_random doesn't play especially well with playlist statistics or with audioscrobber. I imagine this is a pretty hard problem. Any insight into why this is the case, or suggested workarounds? It's not mission critical for me: this is a great bit of code and, as is, I really appreciate it.

stephen
Title: foo_random
Post by: foosion on 2006-04-10 20:35:23
The problem is that foo_random adds an additional layer of indirection that obscures what track is playing to all components that are not aware of what foo_random does - which means virtually every component in existence. This obfuscation is an (unavoidable) side-effect and not a deliberate attempt to prevent these other components from working.
Title: foo_random
Post by: Fiend Angelical on 2006-06-07 07:52:40
Sorry for reviving an old topic.

Is there a way to make foo_random truly random?

That is, a query that make foo_random pick rnadomly from my whole database? I'm currently struggling to find a plugin that offers truly random playback qualities.

(foo_dbshuffle?  )
Title: foo_random
Post by: foosion on 2006-06-07 14:00:52
You just need to devise a query that selects all songs, like "%path% IS *" or "NOT all IS golden".
Title: foo_random
Post by: Fiend Angelical on 2006-06-07 14:02:58
Aha, thank you. I will try it as soon as I finish processing the ReplayGains of my music collection.

LATER:

The component adds a decoder for URIs of the form
Code: [Select]
random:|query|
where query is a valid playlist generator query. The component provides a main menu command to add ("Playlist/Add randomized entry...") and a playlist context menu command to edit ("Edit randomized entries...") entries of this form. The context menu command replaces the existing entry with the new one. It is recommended that you use these commands to manipulate randomized entries instead of the "Add location..." command, as they also check that the query is syntactically valid.

I'm non-computer programming literate. What is a 'syntactically valid' query? Is there anywhere I could look to help me learn these queries? I'm struggling to find a query that defines a random playlist by genre, or another tag field.

The use of random: paths is limited to playback, i.e. you cannot use them with the Replaygain scanner or the converter. This is by design.

Could I ask why?
Title: foo_random
Post by: Squeller on 2006-06-21 09:17:53
I'm non-computer programming literate. What is a 'syntactically valid' query? Is there anywhere I could look to help me learn these queries?

http://www.hydrogenaudio.org/forums/index....ndpost&p=400521 (http://www.hydrogenaudio.org/forums/index.php?s=&showtopic=45443&view=findpost&p=400521)
Title: foo_random
Post by: Squeller on 2009-01-17 10:54:55
Could you maybe offer a variable which indicates the number of matches of the query. Unlike Autoplaylists or search results, here we don't have information about the number of matches. I want to display it in panels.
Title: foo_random
Post by: Squeller on 2009-02-27 14:04:41
Another question: tracks played by foo_random do not update playback statistics data, as those tracks are not recognized as Media Library tracks. Can you change this?
Title: foo_random
Post by: GreenSmurf on 2009-06-16 10:34:56
Can anyone explain why Queen's "You're my Best Friend" does not appear with this query?

"title HAS best friend"

It only plays two songs and neither have the words "best" or "friend" in them.

Thanks to anyone who can help.

-Brandon
Title: foo_random
Post by: foosion on 2009-06-16 23:12:47
Could you maybe offer a variable which indicates the number of matches of the query. Unlike Autoplaylists or search results, here we don't have information about the number of matches. I want to display it in panels.
The benefit of having this information does not justify the development and runtime cost to provide it, which is quite significant.

Another question: tracks played by foo_random do not update playback statistics data, as those tracks are not recognized as Media Library tracks. Can you change this?
No. Effectively a randomized playlist entry is a radio station that plays tracks from your media library. It comes with the same limitations (w.r.t. playback statistics tracking) as a normal web radio station. See also post #13 (http://www.hydrogenaudio.org/forums/index.php?s=&showtopic=36632&view=findpost&p=380970) in this thread.

Sorry for the late replies. Apparently I didn't get a notification for this topic.

Can anyone explain why Queen's "You're my Best Friend" does not appear with this query? ...
Have you tried this query in the media library search?
You can also try the plugin's built-in troubleshooting tool. In the context menu preferences, you have to add the command "Random Encounter" to your context menu. Now when you open the context menu for a single random entry, there will be a "Random Encounter" submenu that lists up to 10 matches for your query. If this submenu is missing, the plugin found no matches. In that case, the foobar2000 console will show an error message:
Quote
Failed to open random entry. No items left after applying filter: this IS an example
Title: foo_random
Post by: q-stankovic on 2009-06-20 17:37:02
Hello foosion,

here a short list of some issues i experienced with foo_random:

1. (an old one i mentioned over one year ago in the database search thread): "There is a little but annoying usability issue with foo_random: when choosing a query preset from the dropdown list you can't access the OK button as long as you don't add a space sign(f.e) to the query text)"

2. foo_random seems to have a conflict with two newer features of foobar core.
a) I typed "ALL" as query to get back an random entry of whole library but foo_random interpretes that as string "all"
b) Furthermore it also looks in fields that are not in the search restriction field in advanced preferences.

3. The seekbar doesn't work - on the other side you can seek in a playing track by "seek ahead by ..." command
Title: foo_random
Post by: foosion on 2009-06-21 14:12:04
1. (an old one i mentioned over one year ago in the database search thread): "There is a little but annoying usability issue with foo_random: when choosing a query preset from the dropdown list you can't access the OK button as long as you don't add a space sign(f.e) to the query text)"
Reproduced. I will look into it, but please report such issues in the correct topic in the future.

2. foo_random seems to have a conflict with two newer features of foobar core.
a) I typed "ALL" as query to get back an random entry of whole library but foo_random interpretes that as string "all"
b) Furthermore it also looks in fields that are not in the search restriction field in advanced preferences.
I can't reproduce this with the latest version from my website (currently 1.2.3) and foobar2000 0.9.6.8.

Edit: I'll have to try this when I'm back home. The media library on my laptop only contains songs in "C:\Documents and Settings\All users\...".

3. The seekbar doesn't work - on the other side you can seek in a playing track by "seek ahead by ..." command
Known/won't fix. This is due to how foo_random works.
Title: foo_random
Post by: foosion on 2009-06-30 22:40:16
foo_random 1.3.0

Changes:
Title: foo_random
Post by: Guhndahb on 2009-07-01 00:10:45
I'm totally psyched to be able to use a custom ratings-weighted shuffle.
How can this be attained?  I've been trying to find a way to do ratings-weighted random but it seems that the method people have previously used, utilizing foo_skip, does not work anymore.  Is using foo_random the only current option?  If so, I'm unsure how to make a playlist generator query that works to achieve ratings-weighted random unless rand() will work with this plugin.  But I thought rand() doesn't currently work in most situations.

Also, foosion, can I assume from the fact that you had to design foo_random the way you did (as a kind of channel) that there's no way currently to add playlist order options or modify the behavior of those that exist?  I'm unsure if I can live with the understandably necessary limitations that foo_random imposes such as limited compatibility with functionality and other plugins that I like (such as audioscrobbler and the seek bar).  I was going to look into writing a plugin to do what I wanted, but if someone as experienced as yourself found this the best option I'm guessing what I want to do is currently impossible.

Thank you.
Title: foo_random
Post by: Morfeus on 2009-07-01 00:22:41
foosion: Sorry, but I don't really understand purpose of this plugin, when you can create autoplaylist with ALL query, set playback mode to Random and let it play...
Title: foo_random
Post by: Mikus Rakis on 2009-07-01 09:15:12
You can create a playlist like
Play random abba not longer that 3 minutes
play random jingle
play random song with the genre Jazz and longer than 1 minute but not from a live album

Basically your own programmed radio station etc.
Title: foo_random
Post by: wojtek on 2009-07-01 09:18:09
Quote
Basically your own programmed radio station etc.


But still - you can achieve it with normall autoplaylist (;

EDIT: There is no chance for support of scrobbling played tracks - am I right?
Title: foo_random
Post by: The Link on 2009-07-01 09:28:07
But still - you can achieve it with normall autoplaylist (;

I wouldn't know how you could achieve the same with one autoplaylist. Basically you can create an arbitrary number of "virtual" autoplaylists in a row using foo_random where every entry is a random pick taken out of such a "virtual" autoplaylist. Already a small number of foo_random entries in a playlist set on repeat can keep you entertained for quite a while.
Title: foo_random
Post by: odyssey on 2009-07-01 10:28:46
This component is brilliant (can't imagine I haven't seen it before)!!

It works, in a limited way somewhat like the trivial automated playlist generation (http://www.hydrogenaudio.org/forums/index.php?showtopic=70520) proposal i made. However, it would be cool if it could somehow be possible to say "NOT ARTIST PLAYED DURING LAST 2 HOURS".
Title: foo_random
Post by: Morfeus on 2009-07-01 13:53:48
Just as you can use query in foo_random, exactly you can use query in autoplaylist, which does essentially the same thing. I still think this component is obsolete from the beginning.
Title: foo_random
Post by: odyssey on 2009-07-01 14:39:58
Just as you can use query in foo_random, exactly you can use query in autoplaylist, which does essentially the same thing. I still think this component is obsolete from the beginning.

Did you try it or even read the thread? You can use this if you want to create a playlist with random entrys based on certain rules - FOR EACH ITEM ONLY. Useful if you rnu a radio station and want to schedule commercials or anything like that. You might not find it useful - others will, and I will defainately not call this the same thing as autoplaylists!
Title: foo_random
Post by: wojtek on 2009-07-01 15:29:44
OK, quick question then - does it allow to limit number or time of random entries in that one entry? if not I still cannot see the point...
Title: foo_random
Post by: q-stankovic on 2009-07-01 17:38:58
Thanks for the update, foosion!


... I still cannot see the point...


Well, if you just add one randomized entry to a playlist and also set your playback order to repeat track, then you also can take an autoplaylist to achieve same listening experience. But as The Link already said: We have a row of randomized entry but not only that - the order of the queries aims to achieve a certain dramaturgy. Example: You can achieve that after a Hip-Hop track an Funk track follows, then a Big Beat track, after that then 2 Rock songs and then an evergreen - if you set the playbackorder to repeat playlist then you have your own station. I have absolutely no idea how you can achieve that by using playlists. This little component offers in a bit different way a feature that is known in other players as Auto-Dj playlist.

... does it allow to limit number or time of random entries in that one entry?


What should limitation mean in the context of one single entry - that makes no sense for me?
Title: foo_random
Post by: 2E7AH on 2009-07-01 19:53:55
I also first noticed this component this week when the topic got hot. And it's really interesting playing with it.
I noticed this: using title formattings you can get standard fields: ARTIST, ALBUM, TITLE etc. in some panels/elements but the fields are not present in:
- Item Properties/Selection Properties
- UPnP Controler panel displays: GetPositionInfo Error
- foo_vis_shpeck / foo_winamp_ipc / foo_winamp_spam doesn't output them if someone uses winamp emulation software

So because streaming radios, as I know, has at least ARTIST, TITLE can they be available in near future for use in above cases. Playback statistics tracking isn't possible like mentioned before, but it would be nice if it was

[edit] Playback statistics SQL tracks the statistics (on actual track) and user can assign rating to named random queue
Title: foo_random
Post by: foosion on 2009-07-01 20:26:37
foosion: Sorry, but I don't really understand purpose of this plugin, when you can create autoplaylist with ALL query, set playback mode to Random and let it play...
The ALL query in the change log is just an example that I mentioned. One of the posts preceding mine contains a report that ALL queries did not work as expected with the older version.

There is no chance for support of scrobbling played tracks - am I right?
Correct. That would require special support in the scrobbling component.

It works, in a limited way somewhat like the trivial automated playlist generation (http://www.hydrogenaudio.org/forums/index.php?showtopic=70520) proposal i made. However, it would be cool if it could somehow be possible to say "NOT ARTIST PLAYED DURING LAST 2 HOURS".
I do not plan to add that. For one thing, I couldn't use the core's filter API any more and I would have to add tracking of group based playback statistics.

q-stankovic already said it, but I am going to repeat this for emphasis. The following two things are equivalent in that they result in the same (potential) order of played songs:

Aside from that there are things you cannot do with autoplaylists, and there are things you cannot do with foo_random. It is up to you to decide whether you need the possibilities offered by foo_random and whether you are willing to pay the price for that (seek bar not working, no scrobbling).

On the other hand, one of the design goals of foo_random was that you don't have to pay for something you don't use. Selecting a subset of the media library and keeping that selection up-to-date costs CPU time and memory. You can easily create 100 "random" entries, and it will only cost CPU time and memory while you are actually playing one of those tracks. With an autoplaylist, this maintenance cost has to be paid while the autoplaylist exist, no matter whether it is currently used or not. See, it is all about trade-offs.
Title: foo_random
Post by: foosion on 2009-07-01 20:33:53
Also, foosion, can I assume from the fact that you had to design foo_random the way you did (as a kind of channel) that there's no way currently to add playlist order options or modify the behavior of those that exist?
No, you cannot. It is not possible to add custom playback orders, because that is not part of the SDK. However, this didn't not influence the design of foo_random. It may have influenced that this component came into being in the first place, but I don't remember that exactly.

I noticed this: using title formattings you can get standard fields: ARTIST, ALBUM, TITLE etc. in some panels/elements but the fields are not present in:
That is because of the difference between static and dynamic meta data. The information about the song played by a "random:" track is dynamic metadata, and some components only use static metadata (on purpose).
Title: foo_random
Post by: odyssey on 2009-07-02 17:50:26
It works, in a limited way somewhat like the trivial automated playlist generation (http://www.hydrogenaudio.org/forums/index.php?showtopic=70520) proposal i made. However, it would be cool if it could somehow be possible to say "NOT ARTIST PLAYED DURING LAST 2 HOURS".
I do not plan to add that. For one thing, I couldn't use the core's filter API any more

I'm not saying that you shouldn't, but maybe it would be possible to implement in the core filter? I could imagine this being useful in regular autoplaylists as well.

and I would have to add tracking of group based playback statistics.

What do you mean by group based?

Do you plan to fix playback statistics?
Title: foo_random
Post by: foosion on 2009-07-02 18:03:41
What do you mean by group based?
Aggregate playback statistics for groups of songs, for example all songs by a given artist.

Do you plan to fix playback statistics?
They are not broken. The official playback statistics component does not count songs played through "random" entries, but this is merely a consequence of how the two components work. If playback statistics are important to you, you would probably be better off using autoplaylists.
Title: foo_random
Post by: romor on 2010-12-26 17:09:41
Old thread but interesting component

What can be rationale not to consider ReplayGain values?
Is it implementation problem or some design decision?

I can't think of reason not to use ReplayGain when tracks are randomized. Or maybe there is some switch?

Thanks
Title: foo_random
Post by: foosion on 2010-12-26 18:58:28
There is no intention to not consider Replay Gain data. The problem is merely how foobar2000 treats dynamic Replay Gain data, since this component works similarly to an on-line radio station (except that it does not bother to transmit the audio data over a network). It used to work at some point. I do not know, if it still does, as I have not used the component for a while.
Title: foo_random
Post by: Marc27 on 2011-06-08 04:30:52
Neat component.
This component is brilliant (can't imagine I haven't seen it before)!!

Same!!

Also, maybe a minor glitch I noticed the track title is sometimes not displayed on playback, but the query syntax instead...

Thanks.
Title: Re: foo_random
Post by: Simon_ Thunder on 2018-05-12 20:31:43
First, big thanks to Foosion for plugin.
Nice plugin, but something very weird happened, when i type title "sun" in foo random plugin window, foobar start playing all files in library even they doesn't much title "sun". Same thing happened when i type query "m".
But when you type query "ALL" and set playback order to shuffle folders - plugin work properly - foobar start playing only one track from folder and then play other track from another folder.