![Апплодисменты :clap:](./images/smilies/smile_clap.gif)
Список разделов › foobar2000 › Секреты foobar2000
// ==PREPROCESSOR==
// @name "Peak meter"
// @author "kgena_ua"
// ==/PREPROCESSOR==
// foo_vis_vumeter.dll required
function RGB(r,g,b) { return (0xff000000|(r<<16)|(g<<8)|(b)); }
function RGBA(r, g, b, a) { return ((a << 24) | (r << 16) | (g << 8) | (b)); }
var font = gdi.Font("Arial",9,1);
var font2 = gdi.Font("Arial",11,0);
var set_path = fb.ProfilePath + "\\maybe\\settings\\";
DT_CENTER = 0x00000001;
DT_VCENTER = 0x00000004;
DT_SINGLELINE = 0x00000020;
DT_WORD_ELLIPSIS = 0x00040000;
ColorTypeCUI = { background: 3,};
var bgcolor = window.GetColorCUI(ColorTypeCUI.background);
//var bgcolor = RGB(40,40,40);
var dll;
var is_dll = utils.CheckComponent("\\user-components\\foo_vis_vumeter\\foo_vis_vumeter");
if (is_dll) {dll = false} else {dll = true};
var ww, wh;
var on_mouse = false;
var color1 = [ RGB(90,105,114), RGB(140,164,179) ];
var color2 = [ RGB(200,200,200), RGB(90,105,114) ];
var bg_offset_color = bgcolor;
var offset_color = color2[0];
var db = new Array(-30,-25,-20,-17.5,-15,-12.5,-10,-7.5,-5,-4.5,-4,-3.5,-3,-2.5,-2,-1.5,-1,-0.5,0,0.1,1,1.5,2,2.5,3,3.5,5);
var db_l = new Array(-85-80,-75,-70,-65,-50,-45,-40,-35,-30);
var separator;
for (var i = 0; i <= db.length; i++) {
if (db[i] == 0) {separator = i};
}
var VUMOffset_t, t_height, t_width;
if (dll) {VUMeter = new ActiveXObject("VUMeter")};
if (dll) {VUMeter.RegisterWindow(window.ID)}; // do not use for transparent mode
function ToDB(Level){
return Math.round(2000*Math.log(Level)/Math.LN10)/100;
}
function on_size() {
ww = window.Width;
wh = window.Height;
}
//var points = 27;
var col = 10;
var ytext = 5;
var yL = ytext + 16;
var h = 2;
var yLM = yL + h + 4;
var hM = 5;
var yRM = yLM + 10;
var yR = yRM + hM + 4;
var wL = 0, wR = 0;
var xLanim = 0, xRanim = 0;
var xL = 0, xR = 0;
var xLManim = 0, xRManim = 0;
var xLM = 0, xRM = 0;
var kLM = 0, kRM = 0;
var kLM2 = 0, kRM2 = 0;
var xLManim2 = 0, xRManim2 = 0;
var kL = 0, kR = 0;
var wLanim = 0, wRanim = 0;
var oldwL = 0, oldwR = 0;
function on_paint(gr) {
!window.IsTransparent && gr.FillSolidRect(0, 0, ww, wh, bgcolor);
//gr.FillSolidRect(0, 0, ww, wh, RGB(100,100,100));
var color = [];
var combinedColor1 = [];
var combinedColor2 = [];
var points = db.length;
var s1 = separator;
var s2 = points - s1;
var points_l = db_l.length;
for(var j = 0; j < s1; j++) {
combinedColor1.push(combineColors(color1[0], color1[1], j / s1));
}
for(var j = 0; j < s2; j++) {
combinedColor2.push(combineColors(color2[0], color2[1], j / s2));
}
color = combinedColor1.concat(combinedColor2);
if (dll) {
L = VUMeter.LeftLevel;
R = VUMeter.RightLevel;
LM = VUMeter.LeftPeak;
RM = VUMeter.RightPeak;
}
var offset = (ww - col * 1) / points;
var w = offset - 1;
var offset_l = (ww / 6 - col * 1) / points_l;
var w_l = offset_l - 1;
var yLM_l = ytext + 1, yRM_l = yLM_l + 6;
var hM_l = 2;
if (fb.IsPlaying && dll) {
for (var i = 0; i <= points - 0; i++) {
if (ToDB(LM) > db_l[i]) gr.FillSolidRect(col + 20 + i * offset_l, yLM_l, w_l, hM_l, color[5]);
if (ToDB(RM) > db_l[i]) gr.FillSolidRect(col + 20 + i * offset_l, yRM_l, w_l, hM_l, color[5]);
}
for (var i = 0; i <= points - 0; i++) {
if((ToDB(L) > db[i] && ToDB(L) < db[i+1])) {wL = i * offset + offset / Math.abs(db[i + 1]-db[i]) * Math.abs(ToDB(L) - db[i]) }
if (wL > col) gr.FillSolidRect(col, yL, wL, h, color[1]);
if((ToDB(R) > db[i] && ToDB(R) < db[i+1])) {wR = i * offset + offset / Math.abs(db[i + 1]-db[i]) * Math.abs(ToDB(R) - db[i]) }
if (wR > col) gr.FillSolidRect(col, yR, wR, h, color[1]);
if (xLanim <= wL) {xLanim = wL; kL = 0; wLanim = wL - oldwL < 1 ? wLanim : wL - oldwL + 5} else {oldwL = wL};
if (xLanim > col) gr.FillSolidRect(col + xLanim + 2, yL, wLanim <= 0 ? 5 : wLanim, h, xRanim <= wR ? color[15] : color[8]);
if (xRanim <= wR) {xRanim = wR; kR = 0; wRanim = wR - oldwR < 1 ? wRanim : wR - oldwR + 5} else {oldwR = wR};
if (xRanim > col) gr.FillSolidRect(col + xRanim + 2, yR, wRanim <= 0 ? 5 : wRanim, h, xRanim <= wR ? color[15] : color[8]);
var overL = col + xLanim + 2 + wLanim - ww - 10;
if (overL > 0) gr.FillSolidRect(ww - overL, ytext + 12, ww - 10, h, color[10]);
var overR = col + xRanim + 2 + wRanim - ww - 10;
if (overR > 0) gr.FillSolidRect(ww - overR, yR + h + 1, ww - 10, h, color[10]);
if (ToDB(LM) > db[i]) gr.FillSolidRect(col + i * offset, yLM, w, hM, color[i]);
if (ToDB(RM) > db[i]) gr.FillSolidRect(col + i * offset, yRM, w, hM, color[i]);
if (ToDB(LM) > db[i] && ToDB(LM) < db[i+1]) {xLM = i * offset};
if (xLManim <= xLM) {xLManim = xLM; xLManim2 = xLM; kLM = 0; kLM2 = 0};
if (xLManim > col) gr.FillSolidRect(col + xLManim + offset, yLM, w * 0.6, hM , color[Math.round(xLManim/offset)]);
if (ToDB(RM) > db[i] && ToDB(RM) < db[i+1]) {xRM = i * offset};
if (xRManim <= xRM) {xRManim = xRM; xRManim2 = xRM; kRM = 0; kRM2 = 0};
if (xRManim > col) gr.FillSolidRect(col + xRManim + offset, yRM, w * 0.6, hM, color[Math.round(xRManim/offset)]);
if (xLManim2 > col) gr.FillSolidRect(col + xLManim2 + offset - 0, yLM, w * 0.3, hM, color[Math.round(xRManim2/offset)]);
if (xRManim2 > col) gr.FillSolidRect(col + xRManim2 + offset - 0, yRM, w * 0.3, hM, color[Math.round(xLManim2/offset)]);
}
}else {
xLM = 0; xRM = 0; xLManim = 0; xRManim = 0;
}
if (dll) {
for (var i = 0; i <= points - 1; i = i + 2) {
var text_w = gr.CalcTextWidth(db[i], font);
if (fb.IsPlaying) if (i > 6) gr.GdiDrawText(db[i], font, color1[0], col + offset * i - text_w / 2, ytext, ww, wh);
}
for (var i = 1; i <= points - 2; i = i + 2) {
var text_w = gr.CalcTextWidth(db[i], font);
}
}
// gr.GdiDrawText("db", font, on == 0 && on_mouse ? color1[1] : color1[0], col, on == 1 ? ytext : yR - 2, ww, wh);
gr.GdiDrawText("db", font, color1[1], col, ytext, ww, wh);
VUMOffset_t = Math.round(VUMeter.Offset) + " db";
t_height = gr.CalcTextHeight(VUMOffset_t, font2) + 2;
t_width = gr.CalcTextWidth(VUMOffset_t, font2) + 10;
wheel && gr.FillSolidRect(pos_x - t_width, pos_y - t_height + 0, t_width, t_height, bg_offset_color);
wheel && gr.GdiDrawText(VUMOffset_t, font2, offset_color, pos_x - t_width, pos_y - t_height + 0, t_width, t_height, DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_WORD_ELLIPSIS );
// gr.GdiDrawText(on_mouse, font2, RGB(250,250,250), 100, 0, ww, wh);
}
function on_playback_new_track() {
seek_timer && window.ClearInterval(seek_timer);
seek_timer = window.SetInterval(function() {
kL = kL + 6;
wLanim = wLanim - 0.01 * kL;
kR = kR + 6;
wRanim = wRanim - 0.01 * kR;
xLanim = xLanim - 0.5;
xRanim = xRanim - 0.5;
kLM = kLM + 15;
kRM = kRM + 15;
xLManim = xLManim - 0.002 * kLM;
xRManim = xRManim - 0.002 * kRM;
kLM2 = kLM2 + 0.5;
kRM2 = kRM2 + 0.5;
xLManim2 = xLManim2 + kLM2;
xRManim2 = xRManim2 + kRM2;
window.Repaint();
},10);
}
function on_playback_stop(reason) {
if(reason == 0) {
window.ClearInterval(seek_timer);
window.Repaint();
}
}
function on_mouse_lbtn_dblclk(x,y) {
}
var pos_x = 0;
var pos_y = 0;
function on_mouse_move(x,y) {
on_mouse = true;
pos_x = x <= t_width ? col + t_width : col + x;
pos_y = y <= t_height ? t_height : y;
window.SetCursor(32649);
window.Repaint();
}
function on_mouse_lbtn_down(x, y) {
}
function on_mouse_lbtn_up(x, y) {
}
function on_mouse_mbtn_dblclk(){
}
function on_mouse_leave() {
on_mouse = false;
window.SetCursor(32512);
window.Repaint();
}
var wheel = false;
function on_mouse_wheel(step) {
wheel = true;
VUMeter.Offset = VUMeter.Offset + step;
window.Repaint();
tooltip_timer && window.ClearTimeout(tooltip_timer);
tooltip_timer = window.SetTimeout(function() {
wheel = false;
tooltip_timer && window.ClearTimeout(tooltip_timer);
tooltip_timer = false;
}, 2000);
}
function on_playback_time(){
if(!seek_timer) on_playback_new_track();
window.Repaint();
}
var Tooltip = window.CreateTooltip();
var tooltip_timer = false;
var seek_timer;
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]));
return (0xff000000 | (r << 16) | (g << 8) | (b));
}
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];
}
SanJose:SanJose
Вернуться в Секреты foobar2000