HydrogenAudio

Hosted Forums => foobar2000 => General - (fb2k) => Topic started by: Regular John on 2019-11-30 19:43:21

Title: Different colours for artists
Post by: Regular John on 2019-11-30 19:43:21
Hi everyone,
Always managed to find answers and solutions without bothering the community too much. This time after a lot of searching I couldn’t find any help.
What I.m trying to figure out is how to assign a different color to certain artists in my filter panel, vs the “standard one” provided in my color scheme.

Is this something feasible?
Maybe it could be done assigning a different color to preferred artists... but Ik’m lost as how to do it

Thanks a lot,
RJ
Title: Re: Different colours for artists
Post by: Regular John on 2019-12-05 21:54:24
Anyone?

 :)) 
Title: Re: Different colours for artists
Post by: davideleo on 2019-12-06 15:36:27
Well, assuming you are talking about Columns UI filters, it's pretty straightforward: use the conditional statement $if() combined with the $rgb() function.
For example, if you want to set the font colour to red for all artists whose name begins with an "A", you can write in the field description something like:
Code: [Select]
$ifequal($strcmp($left(%artist%,1),A),1,$rgb(255,0,0),)%artist%
Title: Re: Different colours for artists
Post by: Regular John on 2019-12-08 17:21:48
Thank you so much!

Yes, it's CUI filters.
Looked so easy (after your advice - before I had been playing randomly with the machine for days  :)) )

Now (and excuse me once more for my noobieness).

Suppose I want to turn in red a number of artists of my choice, which have nothing in common (they don't all begin with the A).

This string turns in red Bach
Code: [Select]
$ifequal($stricmp($left(%artist%,3),bac),1,$rgb(255,0,0),)%artist%
How can I add after "bac" - "cho" for chopin and "vel" for velvet underground?

I've tried with the $or and $xor functions but didn't manage to get it working.

Will seem again a super simple question for you - not for me tho!  O:)

Thanks again

Roberto
Title: Re: Different colours for artists
Post by: davideleo on 2019-12-08 18:40:46
Will seem again a super simple question for you - not for me tho!  O:)

Not really, I actually realized that the $rgb() function alters the sort order, as if there was a number in front of the artist name, therefore, all the names in red are sorted after those beginning with a special characters and before those beginning with a number. I never noticed something similar before and I actually don't know how to handle it. Does that happen to you, too?

Anyway, sort order issue aside, to compare the whole field with specific values I would use the $strstr() function rather than $strcmp(), for example:
Code: [Select]
$ifequal($strstr(%artist%,Bach),1,$rgb(255,0,0),
$ifequal($strstr(%artist%,Chopin),1,$rgb(255,0,0),
$ifequal($strstr(%artist%,Velvet Underground),1,$rgb(255,0,0),
)))%artist%

The above is just to get the idea, but to make it work properly in real life you need to manage capital letters and prefixes, like this:
Code: [Select]
$puts(ar,$stripprefix($lower(%artist%)))
$ifequal($strstr($get(ar),bach),1,$rgb(255,0,0),
$ifequal($strstr($get(ar),chopin),1,$rgb(255,0,0),
$ifequal($strstr($get(ar),velvet underground),1,$rgb(255,0,0),
)))$swapprefix(%artist%)
Title: Re: Different colours for artists
Post by: Regular John on 2019-12-08 20:57:59
Quote
I actually realized that the $rgb() function alters the sort order, as if there was a number in front of the artist name
I had not noticed it as bach and chopin were my first entries as artists (I was playing within my "classical" collection)  :o

Setting that aside, it also happens that with your code (which by the way works perfectly for everything else) the artists that go "red" are not just bach but say also "BACHi da pietra". But anyway - that's just a detail. Am now trying to solve the "order" issue (which with my infallible trial and error strategy will take months to be sorted out  :'(

thank you davideleo
Title: Re: Different colours for artists
Post by: davideleo on 2019-12-09 03:57:33
Setting that aside, it also happens that with your code (which by the way works perfectly for everything else) the artists that go "red" are not just bach but say also "BACHi da pietra".
Sorry, I didn't understand you wanted it that way. The $stricmp() than is what you need.
Title: Re: Different colours for artists
Post by: Regular John on 2020-01-19 20:14:44
Will seem again a super simple question for you - not for me tho!  O:)

Not really, I actually realized that the $rgb() function alters the sort order, as if there was a number in front of the artist name, therefore, all the names in red are sorted after those beginning with a special characters and before those beginning with a number. I never noticed something similar before and I actually don't know how to handle it. Does that happen to you, too?


Hi, I have bee trying to solve this issue, but all the tricks I could think of just didn't work. E.g. I tried redefining the colors of all the lines, but color (I really can't imagine why) mess with the sorting order.

I wonder if there's anyone out there that could take a look at that ?

Thank you
Title: Re: Different colours for artists
Post by: Daeron on 2020-01-19 22:45:14
That is a limitation of CUI Filter panels and some other components as well.

They hide the color codes visually but the original code is still taken as literal for the purposes of the sorting operation. For example:
Code: [Select]
$rgb(200,200,200)Artist 1
$rgb(100,100,100)Artist 2
In the context of sorting, '$rgb(1' comes before '$rgb(2', therefore the second line will end up first on the CUI Filter panel list. If the sorting only compared 'Artist 1' vs 'Artist 2', the first line would win.

You can sometimes use this to your advantage to force-sort certain items. You can also do the same by inserting an increasing number of zero-width characters in front of strings.

The downside is that in your specific scenario you are stuck with the unintended force-sorting.
Title: Re: Different colours for artists
Post by: Regular John on 2020-01-19 23:06:32

The downside is that in your specific scenario you are stuck with the unintended force-sorting.


So just to understand I got it right: there’s nothing I can do, correct?
Title: Re: Different colours for artists
Post by: Daeron on 2020-01-20 20:42:42
I believe that is the case.
Title: Re: Different colours for artists
Post by: Regular John on 2020-04-25 15:17:15
A couple of months have passed, but I'm wondering if there's a workaround for this.
What about linking the colour scheme to a tag?

What about creating a tag  "preferred" and attributing a red colour to the artists whose songs carries a positive value fot the "preferred" tag?

Would you help me in creating a string for this?
Sorry, of course I've been trying to do it, but with no success.

The rule should say "attribute a rgb code IF %preferred% is positive" .

Would it be possible?

RJ
Title: Re: Different colours for artists
Post by: fuffi on 2020-04-25 20:24:09
I really like that idea.

A couple of months have passed, but I'm wondering if there's a workaround for this.

If this is the case
That is a limitation of CUI Filter panels and some other components as well.
you can try to bring the developers attention to this (https://hydrogenaud.io/index.php?topic=28647.0), maybe he has an idea or there is a simple way to fix this w/o loosing backwardscompabilities...


This is only a dumb idea of a workaround, but maybe it helps?

You can add a new column, make it very small and put in only [%ARTIST%] or $cut([%ARTIST%],1) (only display first letter) or whatever you want to sort, in the Display Script. Then, when you want to sort, you click on that column-header, instead of the header for the colored-column.
That way, the $rgb will not interfer the sorting.

Just an idea, dunno, if it is useful in practical use.


Another approach is to use a Style script for colouring:
Code: [Select]
$set_style(text,$rgb($mod($crc32(%ARTIST%),256),128,128) ,0)
and leave the Display script as simple as [%ARTIST%]
The above code will generate kinda "random" colours for artists, you can always use your own colour code.
Title: Re: Different colours for artists
Post by: Regular John on 2020-04-26 13:54:52
Thank you fuffi,

Quote
You can add a new column

This is interesting. My "use case" is that I would like to mark some artists (by changing their colour in the filter tab) in my classical music collection (the idea is to highlight the major composers vs minor ones). So if a custom colour for some of them is not possible, having something like a green V in a column for the major composers would be great.

Still, I wouldn't know how to do it  :))

Quote
Another approach is to use a Style script for colouring:

As you said, this would generate random colours. I'm wondering if I can use your idea to reach the scenario where every artist is in the default column except some of them

RJ
Title: Re: Different colours for artists
Post by: Regular John on 2020-04-26 18:51:34
EDIT (I don't know how to edit my own message above!)

Quote
As you said, this would generate random colours. I'm wondering if I can use your idea to reach the scenario where every artist is in the default column except some of them


should have been:  the scenario where every artist is in the default COLOUR except some of them
Title: Re: Different colours for artists
Post by: fuffi on 2020-04-26 22:16:35
As you said, this would generate random colours.
What is stopping you from replacing my random color code with yours, or the code you'd like to use?
Try to search/read/learn about $set_style.
You can seperate the code for sorting from the code for colouring. (IMHO + AFAIK + fingers crossed)