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: WSH Panel Mod script discussion/help (Read 1511697 times) previous topic - next topic
0 Members and 3 Guests are viewing this topic.

WSH Panel Mod script discussion/help

Reply #2125
i cut most of the old code out but here is my modified turntable script. https://dl.dropbox.com/u/22801321/2013/march/turntable.txt

turntable image saved as .jpg here: https://dl.dropbox.com/u/22801321/2013/march/turntable.jpg

i'm not sure how memory usage goes after extended use as i haven't really had time to test it properly.

@mobyduck, my simple image viewer script can display images from multiple folders and cycle through them. there is no support for no cover images though.

edit: just realised that script won't work for you. it does not support wildcards for filenames. it only supports title formatting for folders and it automatically displays all the images inside.

and lastly, check the Selection mode submenu. by default it uses the settings found under file>preferences>display to choose whether to follow the playing/selected track but you can over-ride this on a per panel basis. that is far more functionality then you get from anything else.


WSH Panel Mod script discussion/help

Reply #2127
check the Selection mode submenu. by default it uses the settings found under file>preferences>display to choose whether to follow the playing/selected track but you can over-ride this on a per panel basis. that is far more functionality then you get from anything else.
I had missed that, thanks (but, as far as usability goes, in foo_uie_albumart you can toggle that preference with a single click... ).

Well, I can always hope for some programmer to resurrect the plugin some day (source is available). Or I might just learn some C and do it myself.

Alessandro

WSH Panel Mod script discussion/help

Reply #2128
(but, as far as usability goes, in foo_uie_albumart you can toggle that preference with a single click... ).


it's really a single click? how do you know which mode it is in? i guess i need to streamline my 2 click approach.

and whilst on the subject of usability, doesn't that component crash foobar everytime you close it?   

WSH Panel Mod script discussion/help

Reply #2129
foobar2000 performance and usability are TOTALLY CRUSHED when this panel is working!!!!

Maybe using RegisterRect(window.ID,x,y,discW,discH) can reduce CPU loading


RegisterRect()

what's that ? how does it work? nothing in WSH Panel Mod docs about it ...

about RegisterRect



WSH Panel Mod script discussion/help

Reply #2132
little update for my version of the turntable script: https://dl.dropbox.com/u/22801321/2013/march/turntable.txt
image: https://dl.dropbox.com/u/22801321/2013/march/turntable.jpg

the button now responds to clicks for play/pause.

i should say preliminary testing shows this uses around 60-70mb of ram. there is no load on cpu except very heavy usage at album change/panel resize causing the UI for freeze for a couple of seconds.

 

WSH Panel Mod script discussion/help

Reply #2133
it's really a single click?
[a href="http://imageshack.us/photo/my-images/163/imgnd.jpg/" target="_blank"]
i guess i need to streamline my 2 click approach.
I was merely responding to your more functionality then you get from anything else claim: didn't mean to criticize your brilliant work.
and whilst on the subject of usability, doesn't that component crash foobar everytime you close it?
Not here. It has some glitches, granted, but I don't experience frequent crashes as its reputation seems to suggest (perhaps because I'm on XP, don't know).

Alessandro

WSH Panel Mod script discussion/help

Reply #2134
marc2003
ideally it would be great to rotate synchronously with the disc and the ring with setting marks 
But, if we want realism, will impose two areas highlight the blue and red rays, CPU even more sad... 
and if add the angle of rotation of the tonearm as a stylized seekbar...

WSH Panel Mod script discussion/help

Reply #2135
@mobdyduck, single click code for simple image viewer. just stick it right at the end.

Code: [Select]
function on_mouse_mbtn_up(x, y) {
    p.selection_mode = p.selection_mode == 2 ? 1 : 2;
    im.folder = "";
    on_item_focus_change();
}


WSH Panel Mod script discussion/help

Reply #2136
    >> onv:    "and if add the angle of rotation of the tonearm as a stylized seekbar..."

don't forget to remove the tonearm locking clamp (look at the image again)

marc2003 - brilliant work mate, thanks a lot for putting all that effort and skill into this ++++++++++++++++++++++++++++++

WSH Panel Mod script discussion/help

Reply #2137
marc2003

ermm, please excuse my stupidity ....I imported your script; yes it shows an image of a static turntable and the panel does not crash when resizing ...but where is the spinning disc?

Does your code do this? :    Draws a spinning disc (disc.jpg) found in same location as selected track, ELSE draws a default spinning disc from a specified location.

*EDIT*    sorry, upon further testing. . .

   - I see it renders the disc.jpg at playing track location.
   - I see your point about UI freezing! ....this only begins to happen if you have played a track ....if you restart fb2k and then resize the panel, there is no freezing
     ....if you play a track and then try resizing you get freezing ....if you play a track and then STOP playing and then try resizing, the panel freezing continues.
   - Where is the default spinning disc when disc.jpg at playing track is not found? ...I was thinking of using an image of the empty turntable mat itself so the panel looks animated

WSH Panel Mod script discussion/help

Reply #2138
it uses the core display preferences. make sure you set the id variable in the script to match which type you want (i've given all the examples). i was using front for testing because i don't have any disc art.

you can specify a default image under file>preferences>display>album art>TYPE>stub image path - no need for me to code this into the script.

Quote
if you restart fb2k and then resize the panel, there is no freezing


right. resize before starting playback. why are people always resizing?

because of the overhead involved creating the images, there are no updates when playback is stopped. when you stop and select something else, you will still see the image from the previous album. it's only when playback starts again that the display will refresh.

WSH Panel Mod script discussion/help

Reply #2139
_______________________________________________________

disc.jpg     (used for "default disc" animation if disc.jpg at playing track is not found ....i.e. turntable platter contains no disc but looks like it is spinning)


The above is a large thumbnail. The full size image can be found here:  http://i.imgur.com/YgMb13Z.jpg
________________________________________________________

@marc2003
- I placed the above (default disc) image  at <foobar_profile>\images\disc.jpg and I played some music having no disc.jpg at playing track ....your panel is not rendering the default disc.
- @fb2k . . . . . . File > Preferences > Display >  Album art (section) > Disc (tab) . . . . . . I have disc.jpg as first item
- @script_config . . . . . . I have edited this line:   var id = 2;

Ideally I want to keep this script and its resources in one subfolder. All user-made functions in my (portable) foobar2000 go to this location: <foobar_profile>\addons\<subfolder>

therefore I eventually want this WSH scripted panel to reference itself ONLY HERE:
<foobar_profile>\addons\wsh_vis_turntable\disc.jpg                <<<<<<<<< the default disc . . . aka the turntable platter contains no disc but looks like it is spinning
<foobar_profile>\addons\wsh_vis_turntable\script.js                <<<<<<<<< the working script
<foobar_profile>\addons\wsh_vis_turntable\turntable.jpg         <<<<<<<<< the default background image

WSH Panel Mod script discussion/help

Reply #2140
- I placed the above (default disc) image  at <foobar_profile>\images\disc.jpg and I played some music having no disc.jpg at playing track ....your panel is not rendering the default disc.


the artwork preferences don't know about your foobar profile\images folder. paths are relative to the playing track. how would it know to look in there? you'd have to specify the full path for that to work  - with a drive letter. no good if you really need portable i suppose. it can be done in script by changing line 57.

replace

Code: [Select]
if (!img) return(window.Repaint());


with

Code: [Select]
if (!img) img = gdi.Image(fb.ProfilePath + "images\\disc.jpg");


WSH Panel Mod script discussion/help

Reply #2141
that program is made for last.fm and it's not very good for album images. you could look at this instead.

http://www.hydrogenaudio.org/forums/index....showtopic=57392

BTW, i didn't make that art.exe program. the original is here:

http://www.hydrogenaudio.org/forums/index....showtopic=77425

i had to modify it to work with WSH panel mod so i had to include my modified source. (i just commented out a line or 2)

Thanks for the information!
artistArt downloader is useful.
And I think I found the way to download image use jscript.

WSH Panel Mod script discussion/help

Reply #2142
marc2003 - thanks again +++++++
 
 
The 'disc.jpg' (empty turntable platter mat) I posted at Post #2140 was not perfectly round, so I deleted it from the image hosting site.
This one here is perfectly round and will fill the the exact dimensions of the turntable platter without visual errors.

Click on the thumbnail to see/copy the full size image to your computer:       

WSH Panel Mod script discussion/help

Reply #2143
And my next questions (hopefully the last  ):

I have these two arrays in my script:
Code: [Select]
var c_arr = new Array(RGBA(191, 228, 255, 255), RGBA(128, 192, 255, 255), RGBA(0, 255, 0, 255), RGBA(255, 0, 0, 255), RGBA(255, 255, 255, 255), RGBA(255, 255, 0, 255));
var a_arr = new Array(RGBA(191, 228, 255, 8), RGBA(128, 192, 255, 8), RGBA(0, 255, 0, 8), RGBA(255, 0, 0, 8), RGBA(255, 255, 255, 8), RGBA(255, 255, 0, 8));

As you can see only alpha value changes.
This is for drawing rectangles according to a condition in full colour (in "on" mode) or semi-transparent (in "off" mode).

So is there a way to make it easier?
Is there anything like "blending" normal RGB() with alpha?

And is there anything like "blending" two colours (RGB() and RGB()) or substract one from another?
Then i could also use this on/off mode for text (since GdiDrawText doesn't seems to support an alpha value, i could then use a "off" colour depending on the c_arr colour and the background colour)

WSH Panel Mod script discussion/help

Reply #2144
Okay, found the answer for question one.
Have again read the helpers.txt and found the setAlpha function (must have overread it before... shame on me).

But there is still my second question:
Is there a way to blend two colours like:
RGBA(19, 30, 38, 255) and RGBA(191, 228, 255, 10) will give RGBA(25, 38, 47, 255) (at least according to Paint.NET that i used for get the blend colour).

WSH Panel Mod script discussion/help

Reply #2145
^haven't a clue, sorry.

just a note to say after a few problems with my scripts going by un-noticed recently, i've tested all of them to make sure they all work as i expect and i think they do. no doubt i've missed something...

i've tidied up a few bits, bumped the version numbers and updated the readme with a few more troubleshooting hints.

https://dl.dropbox.com/u/22801321/samples.zip

i've also created a new readme:

configuring the foobar2000 core to use Last.fm art fetched by my scripts

catchy title eh? 

WSH Panel Mod script discussion/help

Reply #2146
Okay, found the answer for question one.
Have again read the helpers.txt and found the setAlpha function (must have overread it before... shame on me).

But there is still my second question:
Is there a way to blend two colours like:
RGBA(19, 30, 38, 255) and RGBA(191, 228, 255, 10) will give RGBA(25, 38, 47, 255) (at least according to Paint.NET that i used for get the blend colour).


not sure what you want really as result for "blending" but i "blend" colour sometimes to get differents shades of a coulour with "&" and "|" :

    i.e : RGBA(0, 255, 0, 255) | RGBA(0, 0, 255, 255) gives RGBA(0, 255, 255, 255)

but i generally play with the alpha channel ony to get the differents shades of a same colours by increasing or decresing the apha.

HTH


WSH Panel Mod script discussion/help

Reply #2147
tedgo

maybe this helps

Code: [Select]
// Combine two colors
// this [url=http://www.colortools.net/color_combination.html]http://www.colortools.net/color_combination.html[/url] web site uses similar formula

function RGB(r, g, b) {
return (0xff000000 | (r << 16) | (g << 8) | (b));
}

color1 = {
    r : 0,
    g : 255,
    b : 0

}
color2 = {
    r : 0,
    g : 0,
    b : 255


function combineColors(c1, c2, f){
 
// When fraction is 0, result is 100% color1, when f is 1, result is 100% color2.

var r = Math.round(c1.r + f * (c2.r - c1.r));
var g = Math.round(c1.g + f * (c2.g - c1.g));
var b = Math.round(c1.b + f * (c2.b - c1.b));

fb.trace("R = " + r + " G = " + g + " B = " + b);

return (0xff000000 | (r << 16) | (g << 8) | (b));

}
   
var combinedColor = combineColors(color1, color2, 0.5);
 
function on_paint(gr){
   
gr.FillSolidRect(20,20, 100, 100, RGB(color1.r, color1.g, color1.b));
gr.FillSolidRect(140,20, 100, 100, RGB(color2.r, color2.g, color2.b));
gr.FillSolidRect(260,20, 100, 100, combinedColor);

}

WSH Panel Mod script discussion/help

Reply #2148
Thanks Falstaff. New idea to play with

But i want more something like this formula:
Code: [Select]
first colour: RBA(r1, g1, b1, a1)
second colour: RGBA(r2, g2, b2, a2)

r = Math.min(255, r1/255*a1 + r2/255*a2)
g = Math.min(255, g1/255*a1 + g2/255*a2)
b = Math.min(255, b1/255*a1 + b2/255*a2)
a = 255

new colour: RGBA(r, g, b, a)

This would exactly do what i need.
But how could i do this in jscript?

Edit:
@ExtremeHunter
Thanks, i'll give it a try.

EDIT:
@ExtremeHunter

Thank you
This does what i need with an easier formula

But how could i rewrite this function to use the colours from my array and the background colour i set in my global script (both given as RGBA(r,g,b,a))?
I'd need it working like this:
var combinedColor = combineColors(RGBA(19, 30, 38), RGBA(191, 228, 255), 0.5);

Edit: typo...

WSH Panel Mod script discussion/help

Reply #2149
tedgo

I think this is what you need, but this script has lot of rgb conversions, maybe someone knows better way, like how to directly combine decimal colors without that RGB mambo jumbo. 


Code: [Select]
// Combine two colors
// this [url=http://www.colortools.net/color_combination.html]http://www.colortools.net/color_combination.html[/url] web site uses similar formula

function RGB(r, g, b) {
return ( 0xff000000 | (r << 16) | (g << 8) | (b)  );
}

var color1 = RGB(0,255,0);
var color2 = RGB(0,0,255);

function toRGB(d){ // convert back to RGB values
 
var d = d-0xff000000;
var r = d >> 16;
var g = d >> 8 & 0xFF;
var b = d & 0xFF;

return [r,g,b];
}

function combineColors(c1, c2, f){

// When fraction is 0, result is 100% color1, when f is 1, result is 100% color2.
var c1 = toRGB(c1);
var c2 = toRGB(c2);

var r = Math.round(c1[0] + f * (c2[0] - c1[0]));
var g = Math.round(c1[1] + f * (c2[1] - c1[1]));
var b = Math.round(c1[2] + f * (c2[2] - c1[2]));

fb.trace("R = " + r + " G = " + g + " B = " + b);

return (0xff000000 | (r << 16) | (g << 8) | (b));

}

var combinedColor = combineColors(color1, color2, 0.5);

function on_paint(gr){

gr.FillSolidRect(20,20, 100, 100, color1);
gr.FillSolidRect(140,20, 100, 100, color2);
gr.FillSolidRect(260,20, 100, 100, combinedColor);

}