Autor Thema: WSH Panel mod - Scriptbeispiele (Seekbar, Rating, Album-Rating, Coverart & mehr)  (Gelesen 82552 mal)

tedgo

  • Globaler Moderator
  • *
  • Beiträge: 3391
@ tedgo
Wenn Du willst kann ich Dir auch den Programtrick zukommen lassen, mit welchem Du auch Unterordner per Script erstellen kannst, hatte den nur vor der Veröffentlichung dieses Scriptes raus genommen; siehe Diskussionsaufruf an anderer Stelle hier im Board.
Wenn du mit diesem "Trick" FSO meinst, das kenne ich schon, nutze es aber nicht, weil ich es für unsicher halte :)

fbuser

  • Globaler Moderator
  • *
  • Beiträge: 275
Ob man jetzt das FileSystemObject verwendet oder mit einem externen Programmaufruf über foo_run sein System schrottet, ist letztendlich egal. Es ist sicherlich nicht notwendig, entsprechenden Code "geheim" zu halten. Wer wirklich böse Absichten hat, wird ohnehin wissen, was er machen muss.

tedgo

  • Globaler Moderator
  • *
  • Beiträge: 3391
Das stimmt, aber als unversierter User kann man u. U. mit FSO unabsichtlich auch selbst Schaden am eigenen System anrichten ;)
Den Code nicht weiterzugeben ist allerdings nicht unbedingt notwendig. Ein Hinweis, dass man ihn besser nicht ändert und damit herumspielt, wenn man sich nicht auskennt, sollte reichen.

TomPro

  • * Tutorialschreiber *
  • Stammposter
  • *
  • Beiträge: 233
Ja FSO meinte ich, da war ich wohl ein wenig zu paranoid, habs trotzdem wieder bei mir rausgeschmissen "...Und führe uns nicht in Versuchung..."

Gruß TomPro

grimes

  • * Tutorialschreiber *
  • Administrator
  • *
  • Beiträge: 2294
Hier kommen neue Skripte für WSH Panel mod.

Es handelt sich zum einen um ein Metronom:

//metronome by grimes
//fb2k 1.0+, WSH Panel Mod 1.3.0+ required
//DUI/CUI ready


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

var dui = window.InstanceType;

var bpm2 = window.GetProperty("Beats per minute (bpm):", 120);
var mbpm = window.GetProperty("Fine Tuning in mbpm (-999 to +999):", 0);
var bpm = bpm2 + mbpm / 1000;
var bar = window.GetProperty("Beats per measure:", 4);
var sr = window.GetProperty("Sample rate [Hz]:", 44100);
var console = window.GetProperty("Open console on timer start?", false);
var rate = 60000 / bpm;
rate = (Math.round(rate * 100)) / 100;
var tempo = "";
var dance = "";
var ml = rate * bar;
ml = (Math.round(ml * 100)) / 100;
var mm = bpm / bar;
mm = (Math.round(mm * 100)) / 100;
var f = 1000 / rate;
f = (Math.round(f * 100)) / 100;
var sb = rate / 1000 * sr;
sb = (Math.round(sb * 100)) / 100;
var sa = sb * bar;
sa = (Math.round(sa * 100)) / 100;
b2 = fb.TitleFormat("%bpm%");
b2 = b2.Eval();
var proz = "";
proz = -((bpm - b2) * 100 / bpm);
proz = (Math.round(proz * 100)) / 100;
var countinmeasure = 1;
var rate2 = 0;

var g_timer_started = false;
var g_count = 0;
var g_count2 = 0;
var seconds = 0;
var g_timer1, g_timer2;
var mod;
var mod2;

var sr2 = fb.TitleFormat("%samplerate%");
var sr3 = sr2.Eval();
var pl = fb.PlaybackLength;
var pl2 = (Math.round(pl * 100)) / 100;
var bt = pl * 1000 / rate;
bt = (Math.round(bt * 100)) / 100;
var mt = (pl * 1000 / rate) / bar;
mt = (Math.round(mt * 100)) / 100;
var st = sr3 * pl;
st = (Math.round(st * 100)) / 100;
var samp = (Math.round(sb * (g_count - 1) * 100)) / 100;

//var note = window.GetProperty("Note (1=A0, 49=A4, 88=C8)", 49);
//var magic = Math.pow(2, 1 / 12);
//var piano = (27.5 * Math.pow(magic, note - 1));
//piano = (Math.round(piano * 100)) / 100;
var half = 120000 / bpm;
half = (Math.round(half * 100)) / 100;
var quarter = 60000 / bpm;
quarter = (Math.round(quarter * 100)) / 100;
var eighth = 30000 / bpm;
eighth = (Math.round(eighth * 100)) / 100;
var sixteenth = 15000 / bpm;
sixteenth = (Math.round(sixteenth * 100)) / 100;
var dottedquarter = 90000 / bpm;
dottedquarter = (Math.round(dottedquarter * 100)) / 100;
var dottedeighth = 45000 / bpm;
dottedeighth = (Math.round(dottedeighth * 100)) / 100;
var dottedsixteenth = 22500 / bpm;
dottedsixteenth = (Math.round(dottedsixteenth * 100)) / 100;
var tripletquarter = 40000 / bpm;
tripletquarter = (Math.round(tripletquarter * 100)) / 100;
var tripleteighth = 20000 / bpm;
tripleteighth = (Math.round(tripleteighth * 100)) / 100;
var tripletsixteenth = 10000 / bpm;
tripletsixteenth = (Math.round(tripletsixteenth * 100)) / 100;

var half2 = bpm / 120;
half2 = (Math.round(half2 * 1000)) / 1000;
var quarter2 = bpm / 60;
quarter2 = (Math.round(quarter2 * 1000)) / 1000;
var eighth2 = bpm / 30;
eighth2 = (Math.round(eighth2 * 1000)) / 1000;
var sixteenth2 = bpm / 15;
sixteenth2 = (Math.round(sixteenth2 * 1000)) / 1000;
var dottedquarter2 = bpm / 90;
dottedquarter2 = (Math.round(dottedquarter2 * 1000)) / 1000;
var dottedeighth2 = bpm / 45;
dottedeighth2 = (Math.round(dottedeighth2 * 1000)) / 1000;
var dottedsixteenth2 = bpm / 22.5;
dottedsixteenth2 = (Math.round(dottedsixteenth2 * 1000)) / 1000;
var tripletquarter2 = bpm / 40;
tripletquarter2 = (Math.round(tripletquarter2 * 1000)) / 1000;
var tripleteighth2 = bpm / 20;
tripleteighth2 = (Math.round(tripleteighth2 * 1000)) / 1000;
var tripletsixteenth2 = bpm / 10;
tripletsixteenth2 = (Math.round(tripletsixteenth2 * 1000)) / 1000;

//global Variables for text field
var DT_TOP = 0x00000000;
var DT_LEFT = 0x00000000;
var DT_CENTER = 0x00000001;
var DT_RIGHT = 0x00000002;
var DT_VCENTER = 0x00000004;
var DT_BOTTOM = 0x00000008;
var DT_WORDBREAK = 0x00000010;
var DT_SINGLELINE = 0x00000020;
var DT_EXPANDTABS = 0x00000040;
var DT_TABSTOP = 0x00000080;
var DT_NOCLIP = 0x00000100;
var DT_EXTERNALLEADING = 0x00000200;
var DT_CALCRECT = 0x00000400;
var DT_NOPREFIX = 0x00000800;
var DT_INTERNAL = 0x00001000;
var DT_EDITCONTROL = 0x00002000;
var DT_PATH_ELLIPSIS = 0x00004000;
var DT_END_ELLIPSIS = 0x00008000;
var DT_MODIFYSTRING = 0x00010000;
var DT_RTLREADING = 0x00020000;
var DT_WORD_ELLIPSIS = 0x00040000;
var DT_NOFULLWIDTHCHARBREAK = 0x00080000;
var DT_HIDEPREFIX = 0x00100000;
var DT_PREFIXONLY = 0x00200000;
var g_font = dui == 1 ? window.GetFontDUI(0) : window.GetFontCUI(0);
//var color = RGB(200,0,0);
var color = dui == 1 ? window.GetColorDUI(2) : RGB(200,0,0);
//var color2 = RGB(0,0,0);
var color2 = dui == 1 ? window.GetColorDUI(0) : window.GetColorCUI(0);

function on_paint(gr) {
    gr.FillSolidRect(0, 0, window.Width, window.Height, dui == 1 ? window.GetColorDUI(1) : window.GetColorCUI(3));
    gr.GdiDrawText("Click here to start (and stop) timers", g_font, color2, 5, 30, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
    gr.GdiDrawText("To change parameter: right click + Properties", g_font, color, 5, 45, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
    gr.GdiDrawText("Beats per minute b = " + bpm + " bpm " + "f = " + f + " Hz " + tempo, g_font, color2, 5, 60, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
    gr.GdiDrawText("Delay time t = " + rate + " ms", g_font, color2, 5, 75, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
    gr.GdiDrawText("Beats per measure bm = " + bar, g_font, color2, 5, 90, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
    gr.GdiDrawText("Sample rate sr = " + sr + " Hz", g_font, color2, 5, 105, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
    gr.GdiDrawText("Measures per minute mm = " + mm + " mpm " + dance, g_font, color2, 5, 120, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
    gr.GdiDrawText("Measure length ml = " + ml + " ms", g_font, color2, 5, 135, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
    gr.GdiDrawText("Samples per measure sa = " + sa, g_font, color2, 5, 150, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
    gr.GdiDrawText("Samples per beat sb = " + sb, g_font, color2, 5, 165, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
    gr.GdiDrawText("Note duration [ms]: 1/2=" + half + ", 1/4=" + quarter + ", 1/8=" + eighth + ", 1/16=" + sixteenth, g_font, color2, 5, 180, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
    gr.GdiDrawText("dot1/4=" + dottedquarter + ", dot1/8=" + dottedeighth + ", dot1/16=" + dottedsixteenth, g_font, color2, 5, 195, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
    gr.GdiDrawText("triplet1/4=" + tripletquarter + ", triplet1/8=" + tripleteighth + ", triplet1/16=" + tripletsixteenth, g_font, color2, 5, 210, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
    gr.GdiDrawText("Hertz [Hz]: 1/2=" + half2 + ", 1/4=" + quarter2 + ", 1/8=" + eighth2 + ", 1/16=" + sixteenth2, g_font, color2, 5, 225, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
    gr.GdiDrawText("dot1/4=" + dottedquarter2 + ", dot1/8=" + dottedeighth2 + ", dot1/16=" + dottedsixteenth2, g_font, color2, 5, 240, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
    gr.GdiDrawText("triplet1/4=" + tripletquarter2 + ", triplet1/8=" + tripleteighth2 + ", triplet1/16=" + tripletsixteenth2, g_font, color2, 5, 255, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
    gr.GdiDrawText("playing track", g_font, color2, 5, 285, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
    gr.GdiDrawText("Playback length pl = " + pl2 + " s", g_font, color2, 5, 300, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
    gr.GdiDrawText("Measures per track mt = " + mt, g_font, color2, 5, 315, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
    gr.GdiDrawText("Beats per track bt = " + bt, g_font, color2, 5, 330, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
    gr.GdiDrawText("Samples per track (sr = " + sr3 + " Hz) st = " + st, g_font, color2, 5, 345, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
    gr.GdiDrawText("(%bpm% = " + b2 + " bpm " + proz + " %)", g_font, color2, 5, 360, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
    //gr.GdiDrawText("Calculate piano frequency, note: " + note + " = " + piano + " Hz", g_font, color2, 5, 390, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
    if (g_timer_started) {
        gr.GdiDrawText("Running", g_font, color, 250, 30, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
        if (mod === 0 || g_count === 0) {
            gr.GdiDrawText("1", g_font, color, 350, 60, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
        } else {
            gr.GdiDrawText("0", g_font, color, 350, 60, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
        }
        gr.GdiDrawText(g_count, g_font, color, 370, 60, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
        if (mod2 !== 0 && g_count !== 0) {
            gr.GdiDrawText("0", g_font, color, 350, 120, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
        } else {
            gr.GdiDrawText("1", g_font, color, 350, 120, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
        }
        gr.GdiDrawText(Math.floor((g_count) / bar), g_font, color, 370, 120, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
        gr.GdiDrawText(countinmeasure, g_font, color, 350, 90, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
        gr.GdiDrawText(seconds + "s", g_font, color, 350, 30, window.Width, window.Height, DT_TOP | DT_LEFT | DT_SINGLELINE);
    }
}

function CurrentTempo() {
    if (bpm < 40) {
        tempo = "Larghissimo";
    } else if (bpm >= 40 && bpm < 60) {
        tempo = "Largo";
    } else if (bpm >= 60 && bpm < 66) {
        tempo = "Larghetto";
    } else if (bpm >= 66 && bpm < 76) {
        tempo = "Adagio";
    } else if (bpm >= 76 && bpm < 108) {
        tempo = "Andante";
    } else if (bpm >= 108 && bpm < 120) {
        tempo = "Moderato";
    } else if (bpm >= 120 && bpm < 168) {
        tempo = "Allegro";
    } else if (bpm >= 168 && bpm < 208) {
        tempo = "Presto";
    } else if (bpm >= 208) {
        tempo = "Prestissimo";
    }
}



function CurrentDance() {
    if (bar === 4) {
        if (mm >= 27 && mm < 28) {
            dance = "Rumba(4/4)";
        } else if (mm >= 28 && mm <= 29) {
            dance = "Rumba(4/4), Foxtrot(4/4)";
        } else if (mm > 29 && mm <= 30) {
            dance = "Foxtrot(4/4)";
        } else if (mm >= 32 && mm <= 34) {
            dance = "Tango(4/4), Cha Cha(4/4)";
        } else if (mm >= 44 && mm < 50) {
            dance = "Jive(4/4)";
        } else if (mm >= 50 && mm <= 52) {
            dance = "Quickstep(4/4), Jive(4/4)";
        }
    }

    else if (bar === 2) {
        if (mm >= 48 && mm <= 50) {
            dance = "Samba(2/4)";
        } else if (mm >= 60 && mm <= 62) {
            dance = "Paso Doble(2/4)";
        }
    }

    else if (bar === 3) {
        if (mm >= 28 && mm <= 31) {
            dance = "Waltz(3/4)";
        } else if (mm >= 56 && mm <= 60) {
            dance = "Viennese Waltz(3/4)";
        }
    }
}

var ct = new CurrentTempo();
var cd = new CurrentDance();



function print_to_console(msg) {
    fb.trace("bpm:", bpm, msg);
}



function on_mouse_lbtn_down() {
    if (!g_timer_started) {
        // Timer are created here
        g_timer1 = window.CreateTimerInterval(1000);
        g_timer2 = window.CreateTimerInterval(rate);
        print_to_console("Timers started.");
        // Print and show console
        if (console) {
            fb.ShowConsole();
            print_to_console("Show console now.");
        }
        g_timer_started = true;
       
    } else if (g_timer_started) {
        // Kill all timers
        window.KillTimer(g_timer1);
        window.KillTimer(g_timer2);
        g_timer_started = false;
        g_count = 0;
        seconds = 0;
        rate2 = 0;
        print_to_console("Timers killed.");
    }
    window.Repaint();
}



function on_timer(id) {
    if (g_timer1 && id === g_timer1.ID) {
        seconds++;
    } else if (g_timer2 && id === g_timer2.ID) {
        g_count2 = g_count / bar;
        g_count2 = (Math.round(g_count2 * 100)) / 100;
        rate2 = rate * (g_count) / 1000;
        rate2 = (Math.round(rate2 * 100)) / 100;
        g_count++;
        if (console) {
            print_to_console(" " + g_count + " beat(s) measure: " + Math.floor(g_count2) + " " + g_count2 + " time: " + rate2 + " s samples: " + (Math.round(sb * (g_count - 1) * 100)) / 100);
        }
        mod = g_count % 2;
        mod2 = g_count % bar;
        if (g_count % bar === 0 || g_count === 0) {
            countinmeasure = 0;
        }
        countinmeasure++;

    }
    window.Repaint();
}



function on_playback_new_track(metadb) {
    b2 = fb.TitleFormat("%bpm%");
    b2 = b2.Eval();
    sr2 = fb.TitleFormat("%samplerate%");
    sr3 = sr2.Eval();
    pl = fb.PlaybackLength;
    pl2 = (Math.round(pl * 100)) / 100;
    bt = pl * 1000 / rate;
    bt = (Math.round(bt * 100)) / 100;
    mt = (pl * 1000 / rate) / bar;
    mt = (Math.round(mt * 100)) / 100;
    st = sr3 * pl;
    st = (Math.round(st * 100)) / 100;
    proz = -((bpm - b2) * 100 / bpm);
    proz = (Math.round(proz * 100)) / 100;
    window.Repaint();
}



function on_playback_stop(reason) {
    pl = pl2 = bt = mt = st = 0;
    sr3 = "";
    b2 = "";
    proz = "-100";
    window.Repaint();
}


function on_playback_seek(time) {
    seconds = 0;
    g_count = 0;
}


function on_playback_pause(state) {
    countinmeasure = 1;
}

function on_colors_changed() {
    color = dui ==1 ? window.GetColorDUI(2) : RGB(200,0,0);
    color2 = dui ==1 ? window.GetColorDUI(0) : window.GetColorCUI(0);
    window.Repaint();
}

function on_font_changed() {
    g_font = dui == 1 ? window.GetFontDUI(0) : window.GetFontCUI(0);
    window.Repaint();
}

EDIT:
ADD: %bpm% einlesen und anzeigen
ADD: Fine Tuning bpm
ADD: Notendauer in s und Hz
ADD: Playback Pause bei Timer-Stop
ADD: Track abspielen bei Timer-Start
ADD: Berechnung Tonhöhe in Hz
ADD: Sekunden-Timer
ADD: Anzeige der Timer im Panel (Console optional)
FIX: Bugs



« Letzte Änderung: 26. Februar 2010, 09:50:17 von grimes »
Joseph Mallord William Turner (1775-1851) - Die kämpfende Temeraire (1838)

grimes

  • * Tutorialschreiber *
  • Administrator
  • *
  • Beiträge: 2294
zum anderen um den BPM Tapper (Beats per minute) - ein manueller BPM-Counter:

//BPM Tapper by grimes
//fb2k 1.0+, WSH Panel Mod 1.3.0+ required
//DUI/CUI ready


secs2 = 0;
count = 0;
allBpm = 0;
avgBpm = 0;
bpm = 0;
oldBpm=0;

var dui = window.InstanceType;

function RGBA(r, g, b, a) {
r &= 0xff;
    g &= 0xff;
    b &= 0xff;
    a &= 0xff;
    return ((a << 24) | (r << 16) | (g << 8) | (b));
}



function RGB(r, g, b) {
    return RGBA(r, g, b, 0xff);
}

function bpmTapper(){
timeSeconds = new Date;
    secs = timeSeconds.getTime();
    if (count == 0) {
        AVG = "Hit any key!";
        NOW = "Click Here to Reset!";
        HIT = "";
        ACG = "";
        NCG = "";
        secs2 = secs;
        count++;
    } else {
oldBpm = bpm;
        bpm = (1 / ((secs - secs2) / 1000)) * 60;
if (bpm > 600) {bpm = oldBpm;}
        bpmChg = (Math.round((bpm - oldBpm) * 10)) / 10;
        count++;
        allBpm = allBpm + bpm;
        oldAvg = avgBpm;
        avgBpm = allBpm / (count - 1);
        avgChg = (Math.round((avgBpm - oldAvg) * 10)) / 10;
        secs2 = secs;
        if (bpmChg >= 0) {
            PbpmChg = "+" + bpmChg
        } else {
            PbpmChg = bpmChg
        }
        if (avgChg >= 0) {
            PavgChg = "+" + avgChg
        } else {
            PavgChg = avgChg
        }
        AVG = (Math.round(avgBpm * 100)) / 100;
        ACG = PavgChg;
        NOW = (Math.round(bpm * 100)) / 100;
        NCG = PbpmChg;
        HIT = count;
    }
}
new bpmTapper();

var g_font = gdi.Font("Segoe UI", 20, 0);
//var color = RGB(200,0,0);
var color = dui == 1 ? window.GetColorDUI(2) : RGB(200,0,0);
//var color2 = RGB(0,0,0);
var color2 = dui == 1 ? window.GetColorDUI(0) : window.GetColorCUI(0);
    var DT_TOP = 0,
        DT_LEFT = 0,
        DT_CENTER = 1,
        DT_RIGHT = 2,
        DT_VCENTER = 4,
        DT_BOTTOM = 8,
        DT_WORDBREAK = 16,
        DT_SINGLELINE = 32,
        DT_EXPANDTABS = 64,
        DT_TABSTOP = 128,
        DT_NOCLIP = 256,
        DT_EXTERNALLEADING = 512,
        DT_CALCRECT = 1024,
        DT_NOPREFIX = 2048,
        DT_INTERNAL = 4096,
        DT_EDITCONTROL = 8192,
        DT_PATH_ELLIPSIS = 16384,
        DT_END_ELLIPSIS = 32768,
        DT_MODIFYSTRING = 65536,
        DT_RTLREADING = 131072,
        DT_WORD_ELLIPSIS = 262144,
        DT_NOFULLWIDTHCHARBREAK = 524288,
        DT_HIDEPREFIX = 1048576,
        DT_PREFIXONLY = 2097152

function on_paint(gr) {
    gr.FillSolidRect(0, 0, window.Width, window.Height, dui ==1 ? window.GetColorDUI(1) : window.GetColorCUI(3));
    gr.GdiDrawText("Hits: " + HIT, g_font, color2, 5, 10, window.Width, window.Height, DT_LEFT | DT_TOP | DT_SINGLELINE);
    gr.GdiDrawText("Average bpm: " + AVG, g_font, color, 5, 50, window.Width, window.Height, DT_LEFT | DT_TOP | DT_SINGLELINE);
    gr.GdiDrawText("Average Change: " + ACG, g_font, color2, 5, 90, window.Width, window.Height, DT_LEFT | DT_TOP | DT_SINGLELINE);
    gr.GdiDrawText("Current bpm: " + NOW, g_font, color, 5, 130, window.Width, window.Height, DT_LEFT | DT_TOP | DT_SINGLELINE);
    gr.GdiDrawText("Current Change: " + NCG, g_font, color2, 5, 170, window.Width, window.Height, DT_LEFT | DT_TOP | DT_SINGLELINE);
}


function on_key_down(key) {
new bpmTapper();
window.Repaint();
}



function on_mouse_lbtn_down(x, y) {
    count = 0;
    allBpm = 0;
    avgBpm = 0;
    bpm = 0;
    secs2 = secs;
new bpmTapper();
    window.Repaint();
}

function on_colors_changed() {
    color = dui ==1 ? window.GetColorDUI(2) : RGB(200,0,0);
    color2 = dui ==1 ? window.GetColorDUI(0) : window.GetColorCUI(0);
    window.Repaint();
}

function on_font_changed() {
    window.Repaint();
}

EDIT:
FIX: bug

(Ich wünsche euch fröhliches "Hämmern")

Viel Spaß beim Ausprobieren!



« Letzte Änderung: 26. Februar 2010, 09:49:25 von grimes »
Joseph Mallord William Turner (1775-1851) - Die kämpfende Temeraire (1838)

grimes

  • * Tutorialschreiber *
  • Administrator
  • *
  • Beiträge: 2294
Statistics
Sammelt statistische Daten, wie Anzahl der Trackstarts/Stops/Pausen/Sekunden etc. seit foobar2000-Start (bzw. WSH Panel-Start)

//Statistics by grimes
//fb2k 1.0+, WSH Panel Mod 1.3.0+ required
//DUI/CUI ready


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

var g_timer1 = 0;
var count2 = 0;
var console = window.GetProperty("Print to console?", true);
var enabletimer = window.GetProperty("Enable timer?", true);

var on_item_played2 = 0;
var on_volume_change2 = 0;
var on_get_album_art_done2 = 0;
var on_metadb_changed2 = 0;
var on_item_focus_change2 = 0;
var on_playback_order_changed2 = 0;
var on_playback_time2 = 0;
var on_playback_dynamic_info_track2 = 0;
var on_playback_dynamic_info2 = 0;
var on_playback_edited2 = 0;
var on_playback_pause2 = 0;
var on_playback_seek2 = 0;
var on_playback_stop2 = 0;
var on_playback_new_track2 = 0;
var on_playback_starting2 = 0;
var on_playlist_switch2 = 0;
var on_selection_changed2 = 0;
var seconds = 0;
var minutes = 0;
var hours = 0;
var days = 0;
var seconds2 = 0;
var minutes2 = 0;
var hours2 = 0;
var days2 = 0;
var seconds3 = 0;
var minutes3 = 0;
var hours3 = 0;
var days3 = 0;

var dt = Date();
if (enabletimer) {
g_timer1 = window.CreateTimerInterval(1000);
}
var dt2 = "Never";
var dt3 = "Never";
var dt4 = "Never";
var dt5 = "Never";
var dt6 = "Never";
var dt7 = "Never";
var dt8 = "Never";
var dt9 = "Never";
var dt10 = "Never";
var dt11 = "Never";
var dt12 = "Never";
var dt13 = "Never";
var dt14 = "Never";
var dt15 = "Never";
var dt16 = "Never";
var dt17 = "Never";
var dt18 = "Never";

var idle = 0;
var proc = 0;
var proc2 = 0;
var sum = 0;

var dui = window.InstanceType;

var g_font = dui == 1 ? window.GetFontDUI(0) : window.GetFontCUI(0);
//var color = RGB(200,0,0);
var color = dui == 1 ? window.GetColorDUI(2) : RGB(200,0,0);
//var color2 = RGB(0,0,0);
var color2 = dui == 1 ? window.GetColorDUI(0) : window.GetColorCUI(0);

//global Variables for text field
var DT_TOP = 0x00000000;
var DT_LEFT = 0x00000000;
var DT_CENTER = 0x00000001;
var DT_RIGHT = 0x00000002;
var DT_VCENTER = 0x00000004;
var DT_BOTTOM = 0x00000008;
var DT_WORDBREAK = 0x00000010;
var DT_SINGLELINE = 0x00000020;
var DT_EXPANDTABS = 0x00000040;
var DT_TABSTOP = 0x00000080;
var DT_NOCLIP = 0x00000100;
var DT_EXTERNALLEADING = 0x00000200;
var DT_CALCRECT = 0x00000400;
var DT_NOPREFIX = 0x00000800;
var DT_INTERNAL = 0x00001000;
var DT_EDITCONTROL = 0x00002000;
var DT_PATH_ELLIPSIS = 0x00004000;
var DT_END_ELLIPSIS = 0x00008000;
var DT_MODIFYSTRING = 0x00010000;
var DT_RTLREADING = 0x00020000;
var DT_WORD_ELLIPSIS = 0x00040000;
var DT_NOFULLWIDTHCHARBREAK = 0x00080000;
var DT_HIDEPREFIX = 0x00100000;
var DT_PREFIXONLY = 0x00200000;

function on_paint(gr) {
    gr.FillSolidRect(0, 0, window.Width, window.Height, dui ==1 ? window.GetColorDUI(1) : window.GetColorCUI(3));
    if (enabletimer) {
gr.GdiDrawText("startup = " + count2 + "s (" + days2 + "d" + hours2 + "h" + minutes2 + "m" + seconds2 + "s) (" + dt + ")", g_font, color, 5, 5, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
gr.GdiDrawText("time idle = " + idle + "s (" + days3 + "d" + hours3 + "h" + minutes3 + "m" + seconds3 + "s) " + proc2 + "%", g_font, color, 5, 25, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
}
gr.GdiDrawText("on_playback_time = " + on_playback_time2 + "s (" + days + "d" + hours + "h" + minutes + "m" + seconds + "s) " + proc + "%", g_font, color, 5, 45, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
    gr.GdiDrawText("on_playback_starting = " + on_playback_starting2 + " (" + dt2 + ")", g_font, color2, 5, 65, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
    gr.GdiDrawText("on_playback_new_track = " + on_playback_new_track2 + " (" + dt4 + ")", g_font, color2, 5, 85, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
    gr.GdiDrawText("on_playback_stop = " + on_playback_stop2 + " (" + dt5 + ")", g_font, color2, 5, 105, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
    gr.GdiDrawText("on_playback_seek = " + on_playback_seek2 + " (" + dt6 + ")", g_font, color2, 5, 125, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
    gr.GdiDrawText("on_playback_pause = " + on_playback_pause2 + " (" + dt7 + ")", g_font, color2, 5, 145, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
    gr.GdiDrawText("on_playback_edited = " + on_playback_edited2 + " (" + dt8 + ")", g_font, color2, 5, 165, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
    gr.GdiDrawText("on_playback_dynamic_info = " + on_playback_dynamic_info2 + " (" + dt9 + ")", g_font, color2, 5, 185, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
    gr.GdiDrawText("on_playback_dynamic_info_track = " + on_playback_dynamic_info_track2 + " (" + dt10 + ")", g_font, color2, 5, 205, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
    gr.GdiDrawText("on_item_played = " + on_item_played2 + " (" + dt3 + ")", g_font, color, 5, 225, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
    gr.GdiDrawText("on_playback_order_changed = " + on_playback_order_changed2 + " (" + dt11 + ")", g_font, color2, 5, 245, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
    gr.GdiDrawText("on_item_focus_change = " + on_item_focus_change2 + " (" + dt12 + ")", g_font, color2, 5, 265, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
    gr.GdiDrawText("on_metadb_changed = " + on_metadb_changed2 + " (" + dt13 + ")", g_font, color2, 5, 285, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
    gr.GdiDrawText("on_get_album_art_done = " + on_get_album_art_done2 + " (" + dt14 + ")", g_font, color2, 5, 305, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
    sum = on_playback_starting2 + on_playback_new_track2 + on_playback_stop2 + on_playback_seek2 + on_playback_pause2 + on_playback_edited2 + on_playback_dynamic_info2 + on_playback_dynamic_info_track2 + on_item_played2 + on_playback_order_changed2 + on_item_focus_change2 + on_metadb_changed2 + on_get_album_art_done2 + on_volume_change2 + on_playlist_switch2 + on_selection_changed2;
    gr.GdiDrawText("on_volume_change = " + on_volume_change2 + " (" + dt15 + ")", g_font, color2, 5, 325, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
    gr.GdiDrawText("on_playlist_switch = " + on_playlist_switch2 + " (" + dt16 + ")", g_font, color2, 5, 345, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
    gr.GdiDrawText("on_selection_changed = " + on_selection_changed2 + " (" + dt17 + ") [sum: " + sum + "]", g_font, color2, 5, 365, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
}



function on_playback_starting(cmd, is_paused) {
    on_playback_starting2++;
    dt2 = Date();
if (console) {
print_to_console("on_playback_starting = " + on_playback_starting2 + " (" + dt2 + ")");
    }
window.Repaint();
}



function on_item_played(metadb) {
    on_item_played2++;
    dt3 = Date();
if (console) {
print_to_console("on_item_played = " + on_item_played2 + " (" + dt3 + ")");
}
    window.Repaint();
}



function on_playback_new_track(metadb) {
    window.WatchMetadb(metadb)
    on_playback_new_track2++;
    dt4 = Date();
if (console) {
print_to_console("on_playback_new_track = " + on_playback_new_track2 + " (" + dt4 + ")");
}
    window.Repaint();
}



function on_playback_stop(reason) {
    on_playback_stop2++;
    dt5 = Date();
if (console) {
print_to_console("on_playback_stop = " + on_playback_stop2 + " (" + dt5 + ")");
}
    window.Repaint();
}



function on_playback_seek(time) {
    on_playback_seek2++;
    dt6 = Date();
if (console) {
print_to_console("on_playback_seek = " + on_playback_seek2 + " (" + dt6 + ")");
}
    window.Repaint();
}



function on_playback_pause(state) {
    on_playback_pause2++;
    dt7 = Date();
if (console) {
print_to_console("on_playback_pause = " + on_playback_pause2 + " (" + dt7 + ")");
}
    window.Repaint();
}



function on_playback_edited() {
    on_playback_edited2++;
    dt8 = Date();
if (console) {
print_to_console("on_playback_edited = " + on_playback_edited2 + " (" + dt8 + ")");
}
    window.Repaint();
}



function on_playback_dynamic_info() {
    on_playback_dynamic_info2++;
    dt9 = Date();
//if (console) {
// print_to_console("on_playback_dynamic_info = " + on_playback_dynamic_info2 + " (" + dt9 + ")");
//}
    window.Repaint();
}



function on_playback_dynamic_info_track() {
    on_playback_dynamic_info_track2++;
    dt10 = Date();
if (console) {
print_to_console("on_playback_dynamic_info_track = " + on_playback_dynamic_info_track2 + " (" + dt10 + ")");
}
    window.Repaint();
}



function on_playback_time(time) {
    on_playback_time2++;
    var dt = new Date(on_playback_time2 * 1000);
    seconds = dt.getUTCSeconds();
    minutes = dt.getUTCMinutes();
    hours = dt.getUTCHours();
    days = Math.floor(on_playback_time2 / 86400);
    //if (console) {
// print_to_console("on_playback_time = " + on_playback_time2 + "s (" + days + "d" + hours + "h" + minutes + "m" + seconds + "s) " + proc + "%");
//}
window.Repaint();
}



function on_playback_order_changed(new_order_index) {
    on_playback_order_changed2++;
    dt11 = Date();
if (console) {
print_to_console("on_playback_order_changed = " + on_playback_order_changed2 + " (" + dt11 + ")");
}
    window.Repaint();
}



function on_item_focus_change() {
    on_item_focus_change2++;
    dt12 = Date();
if (console) {
print_to_console("on_item_focus_change = " + on_item_focus_change2 + " (" + dt12 + ")");
}
    window.Repaint();
}



function on_metadb_changed(metadb, fromhook) {
    on_metadb_changed2++;
    dt13 = Date();
if (console) {
print_to_console("on_metadb_changed = " + on_metadb_changed2 + " (" + dt13 + ")");
}
    window.Repaint();
}



function on_get_album_art_done(metadb, art_id, image) {
    on_get_album_art_done2++;
    dt14 = Date();
if (console) {
print_to_console("on_get_album_art_done = " + on_get_album_art_done2 + " (" + dt14 + ")");
}
    window.Repaint();
}



function on_volume_change(val) {
    on_volume_change2++;
    dt15 = Date();
if (console) {
print_to_console("on_volume_change = " + on_volume_change2 + " (" + dt15 + ")");
}
    window.Repaint();
}



function on_playlist_switch() {
    on_playlist_switch2++;
    dt16 = Date();
if (console) {
print_to_console("on_playlist_switch = " + on_playlist_switch2 + " (" + dt16 + ")");
}
    window.Repaint();
}

function on_selection_changed() {
    on_selection_changed2++;
    dt17 = Date();
if (console) {
print_to_console("on_selection_changed = " + on_selection_changed2 + " (" + dt17 + ")");
}
    window.Repaint();
}

function on_timer(id) {
    if (g_timer1 && id == g_timer1.ID) {
        count2++;
        idle = count2 - on_playback_time2;
        var dt1000 = new Date(idle * 1000);
        seconds3 = dt1000.getUTCSeconds();
        minutes3 = dt1000.getUTCMinutes();
        hours3 = dt1000.getUTCHours();
        days3 = Math.floor(count2 / 86400);
        var dt100 = new Date(count2 * 1000);
        seconds2 = dt100.getUTCSeconds();
        minutes2 = dt100.getUTCMinutes();
        hours2 = dt100.getUTCHours();
        days2 = Math.floor(count2 / 86400);
        proc = on_playback_time2 / count2 * 100;
        proc = Math.round(proc);
        proc2 = 100 - (on_playback_time2 / count2 * 100);
        proc2 = Math.round(proc2);
        window.Repaint();
    }
}

function print_to_console(msg) {
fb.trace("statistics:", msg);
}

function on_colors_changed() {
    color = dui ==1 ? window.GetColorDUI(2) : RGB(200,0,0);
    color2 = dui ==1 ? window.GetColorDUI(0) : window.GetColorCUI(0);
    window.Repaint();
}

function on_font_changed() {
    g_font = dui == 1 ? window.GetFontDUI(0) : window.GetFontCUI(0);
    window.Repaint();
}

EDIT:
ADD: Zeitformat h:m:s
ADD: Timestamps, startup time, time idle etc.
ADD: print to console
ADD: console output optional
ADD: enable/disable startup timer
REMOVE: average tracktime

« Letzte Änderung: 05. April 2010, 19:00:01 von grimes »
Joseph Mallord William Turner (1775-1851) - Die kämpfende Temeraire (1838)

grimes

  • * Tutorialschreiber *
  • Administrator
  • *
  • Beiträge: 2294
Die Skripte werden immer kürzer...


Alarm
Starte playback nach einer bestimmten Zeit

//alarm by grimes
//fb2k 1.0+, WSH Panel Mod 1.3.0+ required
//DUI/CUI ready


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

var g_timer1;
var alarm = window.GetProperty("Set timer:", 10);
var alarmmode = window.GetProperty("Alarmmode:", false);
var running = false;
var dui = window.InstanceType;

var g_font2 = gdi.Font("Segoe UI", 20, 0);
var g_font = gdi.Font("Segoe UI", 16, 0);
var g_font3 = gdi.Font("Segoe UI", 12, 0);
//var color = RGB(200,0,0);
var color = dui == 1 ? window.GetColorDUI(2) : RGB(200,0,0);
//var color2 = RGB(0,0,0);
var color2 = dui == 1 ? window.GetColorDUI(0) : window.GetColorCUI(0);

function on_paint(gr){
gr.FillSolidRect(0, 0, window.Width, window.Height, dui ==1 ? window.GetColorDUI(1) : window.GetColorCUI(3));
    gr.DrawString("Alarm (" + alarmmode + ")", g_font2, color, 0, -80, window.Width, window.Height, 0x11005000);
gr.DrawString( "Timer = " + alarm + " s", g_font2, color2, 0, -40, window.Width, window.Height, 0x11005000);
if (running) {gr.DrawString("Running", g_font, color2, 0, 0, window.Width, window.Height, 0x11005000);}
gr.DrawString("enable/disable alarm = lbtn, set timer = wheel", g_font3, color2, 0, 40, window.Width, window.Height, 0x11005000);
}

function on_mouse_lbtn_down(x,y){
    if (!alarmmode){
        alarmmode = true;  
        window.NotifyOthers("alarm", "true"); //true
    }
    else {
        alarmmode = false;
        window.NotifyOthers("alarm", ""); // false
    }
window.Repaint();
}

function on_playback_starting(){
    if (alarmmode) {
        fb.Pause();
        running = true;
        g_timer1 = window.CreateTimerTimeout(alarm*1000);
    }
    window.Repaint();
}

function on_mouse_wheel(delta){
for (i = 0; i<delta; i++) {alarm++;}
for (i = 0; i<-delta; i++) {alarm--;}
if(alarm <= 1) { alarm = 1}
window.Repaint();
}

function on_playback_stop(reason) {
if(running){
        running = false;
        window.KillTimer(g_timer1);
    }
    window.Repaint();
}

function on_timer(id) {
if (g_timer1 && id == g_timer1.ID) {
fb.Play();
running = false;
window.Repaint();
}
}

function on_colors_changed() {
    color = dui ==1 ? window.GetColorDUI(2) : RGB(200,0,0);
    color2 = dui ==1 ? window.GetColorDUI(0) : window.GetColorCUI(0);
    window.Repaint();
}

function on_font_changed() {
    window.Repaint();
}


« Letzte Änderung: 26. Februar 2010, 09:54:12 von grimes »
Joseph Mallord William Turner (1775-1851) - Die kämpfende Temeraire (1838)

grimes

  • * Tutorialschreiber *
  • Administrator
  • *
  • Beiträge: 2294
... und weiter gehts.


Gap
Einfügen einer variablen Zeitlücke zwischen den Tracks.

//gap by grimes
//gap between tracks
//fb2k 1.0+, WSH Panel Mod 1.3.0+ required
//DUI/CUI ready


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

var g_timer1;
var alarm = window.GetProperty("Set timer:", 10);
var running = false;
var start = false;
var gap = window.GetProperty("Gap? ", false);
var dui = window.InstanceType;

var g_font2 = gdi.Font("Segoe UI", 20, 0);
var g_font = gdi.Font("Segoe UI", 16, 0);
var g_font3 = gdi.Font("Segoe UI", 12, 0);
//var color = RGB(200,0,0);
var color = dui == 1 ? window.GetColorDUI(2) : RGB(200,0,0);
//var color2 = RGB(0,0,0);
var color2 = dui == 1 ? window.GetColorDUI(0) : window.GetColorCUI(0);

function on_paint(gr){
gr.FillSolidRect(0, 0, window.Width, window.Height, dui ==1 ? window.GetColorDUI(1) : window.GetColorCUI(3));
    if(gap){gr.DrawString("Gap (true)", g_font2, color, 0, -80, window.Width, window.Height, 0x11005000);}
else {gr.DrawString("Gap (false) / Gapless", g_font2, color, 0, -80, window.Width, window.Height, 0x11005000);}
gr.DrawString("Timer = " + alarm + " s", g_font2, color2, 0, -40, window.Width, window.Height, 0x11005000);
if (running) {gr.DrawString("Timer running", g_font, color2, 0, 0, window.Width, window.Height, 0x11005000);}
if(start) {gr.DrawString("Track started", g_font, color2, 0, 0, window.Width, window.Height, 0x11005000);}
gr.DrawString("gap/gapless = lbtn, set timer = wheel", g_font3, color2, 0, 40, window.Width, window.Height, 0x11005000);
}
function on_mouse_lbtn_down(x,y){
if (!gap) {
        gap = true;
        window.NotifyOthers("gap", "true"); //true
        fb.StopAfterCurrent=true;
    }
else {
        gap = false;
        window.NotifyOthers("gap", ""); // false
        fb.StopAfterCurrent=false;
    }
window.Repaint();
}
function on_mouse_lbtn_up(x,y){

}
function on_mouse_move(x,y){

}
function on_mouse_wheel(delta){
for (i = 0; i<delta; i++) {alarm++;}
for (i = 0; i<-delta; i++) {alarm--;}
if(alarm <= 0) { alarm = 0}
window.Repaint();
}

function on_playback_stop(reason) {
    start = false;
    if (gap && reason != 0 && reason != 2) {
        running = true;
        g_timer1 = window.CreateTimerTimeout(alarm*1000);
    }
    window.Repaint();
}

function on_playback_new_track() {
    start = true;
    running = false;
    window.Repaint();
}

function on_timer(id) {
if (g_timer1 && id == g_timer1.ID) {
fb.Play();
running = false;
start = true;
window.Repaint();
}
}

function on_colors_changed() {
    color = dui ==1 ? window.GetColorDUI(2) : RGB(200,0,0);
    color2 = dui ==1 ? window.GetColorDUI(0) : window.GetColorCUI(0);
    window.Repaint();
}

function on_font_changed() {
    window.Repaint();
}

FIX: Bug



« Letzte Änderung: 26. Februar 2010, 09:51:13 von grimes »
Joseph Mallord William Turner (1775-1851) - Die kämpfende Temeraire (1838)

grimes

  • * Tutorialschreiber *
  • Administrator
  • *
  • Beiträge: 2294
Timebomb
Stop/Pause/Exit nach Timerende

//timebomb by grimes
//fb2k 1.0+, WSH Panel Mod 1.3.0+ required
//DUI/CUI ready


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

var g_timer1;
var alarm = window.GetProperty("Set timer [s]:", 10);
var running = false;
var timebombmode = window.GetProperty("Timebombmode:", false);
//var start = false;
var tbpause = window.GetProperty("Pause playback?", false);
var tbexit = window.GetProperty("Exit foobar2000?", false);
var dui = window.InstanceType;

var g_font2 = gdi.Font("Segoe UI", 20, 0);
var g_font = gdi.Font("Segoe UI", 16, 0);
var g_font3 = gdi.Font("Segoe UI", 12, 0);
//var color = RGB(200,0,0);
var color = dui == 1 ? window.GetColorDUI(2) : RGB(200,0,0);
//var color2 = RGB(0,0,0);
var color2 = dui == 1 ? window.GetColorDUI(0) : window.GetColorCUI(0);

function on_paint(gr){
gr.FillSolidRect(0, 0, window.Width, window.Height, dui ==1 ? window.GetColorDUI(1) : window.GetColorCUI(3));
    gr.DrawString("Timebomb (" + timebombmode + ")", g_font2, color, 0, -80, window.Width, window.Height, 0x11005000);
gr.DrawString( "Timer = " + alarm + " s", g_font2, color2, 0, -40, window.Width, window.Height, 0x11005000);
if(running) {gr.DrawString("Running", g_font, color2, 0, 00, window.Width, window.Height, 0x11005000);}
if(!tbexit){
if(tbpause) {gr.DrawString("Pause mode (mbtn)", g_font, color2, 0, 40, window.Width, window.Height, 0x11005000);}
else {gr.DrawString("Stop mode (mbtn)", g_font, color2, 0, 40, window.Width, window.Height, 0x11005000);}
}
else { gr.DrawString("Exit mode", g_font, color, 0, 40, window.Width, window.Height, 0x11005000);}
gr.DrawString("enable/disable timebomb = lbtn, set timer = wheel", g_font3, color2, 0, 80, window.Width, window.Height, 0x11005000);
}
function on_mouse_lbtn_down(x,y){
    if (!timebombmode){
        timebombmode = true;
        window.NotifyOthers("timebomb", "true"); //true        
    }
    else {
        timebombmode = false;
        window.NotifyOthers("timebomb", ""); // false
    }
window.Repaint();
}

function on_playback_starting(){
    if (timebombmode) {
        running = true;
        g_timer1 = window.CreateTimerTimeout(alarm*1000);
    }
    window.Repaint();
}

function on_mouse_wheel(delta){
for (i = 0; i<delta; i++) {alarm++;}
for (i = 0; i<-delta; i++) {alarm--;}
if(alarm <= 1) { alarm = 1}
window.Repaint();
}

function on_playback_stop(reason) {
running = false;
window.Repaint();
}

function on_mouse_mbtn_down(x, y) {
if(!tbpause) {tbpause = true;}
else {tbpause = false;}
window.Repaint();
}


function on_timer(id) {
if (g_timer1 && id == g_timer1.ID) {
if(tbpause) {fb.Pause();}
else {
fb.Stop();
if(tbexit) {fb.Exit();}
}
running = false;
window.Repaint();
}
}

function on_colors_changed() {
    color = dui ==1 ? window.GetColorDUI(2) : RGB(200,0,0);
    color2 = dui ==1 ? window.GetColorDUI(0) : window.GetColorCUI(0);
    window.Repaint();
}

function on_font_changed() {
    window.Repaint();
}


« Letzte Änderung: 26. Februar 2010, 09:57:11 von grimes »
Joseph Mallord William Turner (1775-1851) - Die kämpfende Temeraire (1838)

grimes

  • * Tutorialschreiber *
  • Administrator
  • *
  • Beiträge: 2294
Statistics 2




statistische Funktionen:

sum = Summe
max = Maximaler Wert
min = Minimaler Wert
ran = Spannweite (range)
avg = Durchschnitt (average)
dev = Standardabweichung http://de.wikipedia.org/wiki/Standardabweichung

//statistics2 by grimes
//4 digits %date% format required
//fb2k 1.0+, WSH Panel Mod 1.3.0+ required
//DUI/CUI ready


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

var avgrating = 0;
var avgplaycount = 0;
var on_playback_time2 = 0;
var on_playback_new_track2 = 0;
var avgtracktime = 0;

var rating = "NaN";
var rating2 = 0;
var rating3 = 0;
var avgrating = 0;
var minrating = 0;
var maxrating = 0;
var ranrating = 0;
var devrating = 0;

var playcount = "NaN";
var playcount2 = 0;
var playcount3 = 0;
var playcount4 = 0;
var avgplaycount = 0;
var minplaycount = 0;
var maxplaycount = 0;
var ranplaycount = 0;
var devplaycount = 0;

var year = 0;
var date = 0;
var difyear = 0;
var date2 = 0;
var avgdate = 0;
var difdate = 0;

var today = 0;
var ar_days = 0;
var ar_years = 0;
var ar_days2 = 0;
var ar_years2 = 0;
var ar_days3 = 0;
var ar_years3 = 0;
var ar_days4 = 0;
var ar_years4 = 0;

var losslesscount = 0;
var lossycount = 0;
var losslessproc = 50;
var lossyproc = 50;

var bitrate = 0;
var bitrate2 = 0;
var bitrate3 = 0;
var avgbitrate = 0;
var minbitrate = 0;
var maxbitrate = 0;
var ranbitrate = 0;
var devbitrate = 0;

var filesize = 0;
var filesize2 = 0;
var avgfilesize = 0;
var bfilesize = 0;
var bfilesize2 = 0;
var bavgfilesize = 0;

var length = 0;
var length_seconds = 0;
var length_seconds2 = 0;
var avglength_seconds = 0;

var days = 0;
var hours = 0;
var minutes = 0;
var seconds = 0;

var playbacktimeperc = 0;
var compressionperc = 0;
var compressionperc2 = 0;
var avgcompressionperc = 0;
var mincompressionperc = 0;
var maxcompressionperc = 0;
var rancompressionperc = 0;

var totaltracks = 0;
var totaltracks2 = 0;
var avgtotaltracks = 0;
var mintotaltracks = 0;
var maxtotaltracks = 0;
var rantotaltracks = 0;

var tracknumber = 0;
var tracknumber2 = 0;
var avgtracknumber = 0;
var mintracknumber = 0;
var maxtracknumber = 0;
var rantracknumber = 0;

function readablizeBytes(bytes) {
    var s = ['bytes', 'kb', 'MB', 'GB', 'TB', 'PB'];
    var e = Math.floor(Math.log(bytes) / Math.log(1024));
    return (bytes / Math.pow(1024, Math.floor(e))).toFixed(2) + " " + s[e];
}

var dui = window.InstanceType;

var g_font = dui == 1 ? window.GetFontDUI(0) : window.GetFontCUI(0);
//var color = RGB(200,0,0);
var color = dui == 1 ? window.GetColorDUI(2) : RGB(200,0,0);
//var color2 = RGB(0,0,0);
var color2 = dui == 1 ? window.GetColorDUI(0) : window.GetColorCUI(0);

//global Variables for text field
var DT_TOP = 0x00000000;
var DT_LEFT = 0x00000000;
var DT_CENTER = 0x00000001;
var DT_RIGHT = 0x00000002;
var DT_VCENTER = 0x00000004;
var DT_BOTTOM = 0x00000008;
var DT_WORDBREAK = 0x00000010;
var DT_SINGLELINE = 0x00000020;
var DT_EXPANDTABS = 0x00000040;
var DT_TABSTOP = 0x00000080;
var DT_NOCLIP = 0x00000100;
var DT_EXTERNALLEADING = 0x00000200;
var DT_CALCRECT = 0x00000400;
var DT_NOPREFIX = 0x00000800;
var DT_INTERNAL = 0x00001000;
var DT_EDITCONTROL = 0x00002000;
var DT_PATH_ELLIPSIS = 0x00004000;
var DT_END_ELLIPSIS = 0x00008000;
var DT_MODIFYSTRING = 0x00010000;
var DT_RTLREADING = 0x00020000;
var DT_WORD_ELLIPSIS = 0x00040000;
var DT_NOFULLWIDTHCHARBREAK = 0x00080000;
var DT_HIDEPREFIX = 0x00100000;
var DT_PREFIXONLY = 0x00200000;

function on_paint(gr) {
    gr.FillSolidRect(0, 0, window.Width, window.Height, dui ==1 ? window.GetColorDUI(1) : window.GetColorCUI(3));
    gr.GdiDrawText("on_playback_new_track = " + on_playback_new_track2, g_font, color, 5, 5, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
if (playbacktimeperc === 20 || playbacktimeperc === 40 || playbacktimeperc === 60 || playbacktimeperc === 80 || playbacktimeperc >=90) {
gr.GdiDrawText("playbacktime = " + playbacktimeperc + "%", g_font, color, 5, 25, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
}
else {gr.GdiDrawText("playbacktime = " + playbacktimeperc + "%", g_font, color2, 5, 25, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);}
gr.GdiDrawText("rating = " + rating + ", avg = " + avgrating + ", max = " + maxrating + ", min = " + minrating + ", ran = " + ranrating + ", dev = " + devrating, g_font, color2, 5, 65, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
    gr.GdiDrawText("playcount = " + playcount + ", sum = " + playcount4 + ", avg = " + avgplaycount + ", max = " + maxplaycount + ", min = " + minplaycount + ", ran = " + ranplaycount + ", dev = " + devplaycount, g_font, color2, 5, 85, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
    gr.GdiDrawText("on_playback_time = " + on_playback_time2 + "s ("+ days + "d" + hours + "h" + minutes + "m" + seconds + "s), avg = " + avgtracktime + "s", g_font, color2, 5, 45, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
    gr.GdiDrawText("bitrate = " + bitrate + "kbps, avg = " + avgbitrate + ", max = " + maxbitrate + ", min = " + minbitrate + ", ran = " + ranbitrate + ", dev = " + devbitrate, g_font, color2, 5, 105, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
    gr.GdiDrawText("filesize = " + filesize + ", sum = " + filesize2 + ", avg = " + avgfilesize, g_font, color2, 5, -65, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
    gr.GdiDrawText("tracklength = " + length + " (" + length_seconds + "s), sum = " + length_seconds2 + "s, avg = " + avglength_seconds + "s", g_font, color2, 5, 125, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
gr.GdiDrawText("track number = " + tracknumber + ", sum = " + tracknumber2 + ", avg = " + avgtracknumber + ", max = " + maxtracknumber + ", min = " + mintracknumber + ", ran = " + rantracknumber, g_font, color2, 5, 145, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
gr.GdiDrawText("total tracks = " + totaltracks + ", sum = " + totaltracks2 + ", avg = " + avgtotaltracks + ", max = " + maxtotaltracks + ", min = " + mintotaltracks + ", ran = " + rantotaltracks, g_font, color2, 5, 165, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
//gr.GdiDrawText("current date (year) = " + year, g_font, RGB(80, 80, 80), 0, 20, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
    gr.GdiDrawText("recording year = " + date + " (" + difyear + " years ago)" + ", avg = " + avgdate + " (" + difdate + " years ago)", g_font, color2, 5,185, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);   
    gr.GdiDrawText("added to media library " + ar_days + " days ago (" + Math.floor(ar_years) + " years)", g_font, color2, 5, 205, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
    gr.GdiDrawText("first played " + ar_days2 + " days ago (" + Math.floor(ar_years2) + " years) ", g_font, color2, 5, 225, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
    gr.GdiDrawText("last played " + ar_days3 + " days ago (" + Math.floor(ar_years3) + " years)", g_font, color2, 5, 245, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
    if (playcount === 0) {
        gr.GdiDrawText("Never", g_font, color, 240, 225, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
        gr.GdiDrawText("Never", g_font, color, 240, 245, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
    }
    gr.GdiDrawText("last modified " + ar_days4 + " days ago (" + Math.floor(ar_years4) + " years)", g_font, color2, 5, 265, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
    gr.GdiDrawText("lossless = " + losslesscount + " (" + losslessproc + "%), lossy = " + lossycount + " (" + lossyproc + "%)", g_font, color2, 5, 285, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
gr.GdiDrawText("lossless compression = " + compressionperc + "%, avg = " + avgcompressionperc + "%, max = " + maxcompressionperc + "%, min = " + mincompressionperc + "%, ran = " + rancompressionperc + "%", g_font, color2, 5, 305, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
    gr.GdiDrawText("active playlist = " + fb.GetPlaylistName(fb.ActivePlaylist) + " (" + fb.ActivePlaylist + "/" + fb.PlaylistCount + ")", g_font, color2, 5, 325, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
    gr.GdiDrawText("playing playlist = " + fb.GetPlaylistName(fb.PlayingPlaylist) + " (" + fb.PlayingPlaylist + "/" + fb.PlaylistCount + ")", g_font, color2, 5, 345, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
}



function on_playback_time(time) {
    on_playback_time2++;
var dt = new Date(on_playback_time2 * 1000);
    seconds = dt.getUTCSeconds();
    minutes = dt.getUTCMinutes();
    hours = dt.getUTCHours();
    days = Math.floor(on_playback_time2 / 86400);
    if (on_playback_new_track2 >= 1) {
        avgtracktime = Math.round(on_playback_time2 / on_playback_new_track2);
    }
playbacktimeperc = fb.PlaybackTime*100/fb.PlaybackLength;
playbacktimeperc = Math.round(playbacktimeperc);
   
window.Repaint();
}



function on_playback_new_track() {
    on_playback_new_track2++;

    rating = fb.TitleFormat("%rating%");
    rating = rating.Eval();
    rating = parseInt(rating);
    rating2 += rating;
rating3 += (rating * rating);
if (on_playback_new_track2 === 1) {
minrating = rating;
maxrating = rating;
}
avgrating = rating2 / on_playback_new_track2;
avgrating = Math.round(avgrating * 100) / 100;
minrating = Math.min(minrating,rating);
maxrating = Math.max(maxrating,rating);
ranrating = maxrating - minrating;
devrating = Math.sqrt((on_playback_new_track2 * rating3) - (rating2 * rating2)) / on_playback_new_track2;
    devrating = Math.round(devrating * 100) / 100;

    playcount = fb.TitleFormat("%play_count%");
    playcount = playcount.Eval();
    playcount = parseInt(playcount);
    playcount2 += playcount;
playcount4 += playcount;
    playcount3 += (playcount * playcount);
if (on_playback_new_track2 === 1) {
minplaycount = playcount;
maxplaycount = playcount;
}
avgplaycount = playcount4 / on_playback_new_track2;
avgplaycount = Math.round(avgplaycount * 100) / 100;
minplaycount = Math.min(minplaycount,playcount);
maxplaycount = Math.max(maxplaycount,playcount);
ranplaycount = maxplaycount - minplaycount;
devplaycount = Math.sqrt((on_playback_new_track2 * playcount3) - (playcount2 * playcount2)) / on_playback_new_track2;
    devplaycount = Math.round(devplaycount * 100) / 100;

    date = fb.TitleFormat("%date%");
    date = date.Eval();
    date = parseInt(date);
    dt = new Date();
    year = dt.getFullYear();
    difyear = year - date;
    date2 = date2 + date;
    if (on_playback_new_track2 >= 2) {
        avgdate = date2 / on_playback_new_track2;
        avgdate = Math.round(avgdate);
        difdate = year - avgdate;
    }

    today = new Date();
    var fpy = fb.TitleFormat("$year(%added%)").Eval();
    var fpm = fb.TitleFormat("$sub($month(%added%),1)").Eval();
    var fpd = fb.TitleFormat("$day_of_month(%added%)").Eval();
    var fday = new Date(fpy, fpm, fpd);
    var one_day = 1000 * 60 * 60 * 24;
    if (fday > 0) {
        ar_days = Math.floor((today.getTime() - fday.getTime()) / one_day);
        ar_years = ar_days / 365;
    }
    fpy = fb.TitleFormat("$year(%first_played%)").Eval();
    fpm = fb.TitleFormat("$sub($month(%first_played%),1)").Eval();
    fpd = fb.TitleFormat("$day_of_month(%first_played%)").Eval();
    fday = new Date(fpy, fpm, fpd);
    one_day = 1000 * 60 * 60 * 24;
    if (fday > 0) {
        ar_days2 = Math.floor((today.getTime() - fday.getTime()) / one_day);
        ar_years2 = ar_days2 / 365;
    } else {
        ar_days2 = 0;
    }

    fpy = fb.TitleFormat("$year(%last_played%)").Eval();
    fpm = fb.TitleFormat("$sub($month(%last_played%),1)").Eval();
    fpd = fb.TitleFormat("$day_of_month(%last_played%)").Eval();
    fday = new Date(fpy, fpm, fpd);
    one_day = 1000 * 60 * 60 * 24;
    if (fday > 0) {
        ar_days3 = Math.floor((today.getTime() - fday.getTime()) / one_day);
        ar_years3 = ar_days3 / 365;
    } else {
        ar_days3 = 0;
    }

    fpy = fb.TitleFormat("$year(%last_modified%)").Eval();
    fpm = fb.TitleFormat("$sub($month(%last_modified%),1)").Eval();
    fpd = fb.TitleFormat("$day_of_month(%last_modified%)").Eval();
    fday = new Date(fpy, fpm, fpd);
    one_day = 1000 * 60 * 60 * 24;
    if (fday > 0) {
        ar_days4 = Math.floor((today.getTime() - fday.getTime()) / one_day);
        ar_years4 = ar_days4 / 365;
    } else {
        ar_days4 = 0;
    }

    var lossless = fb.Titleformat("$info(encoding)").Eval();
    if (lossless === "lossless") {
        losslesscount++;
    } else {
        lossycount++;
    }

    losslessproc = Math.round(losslesscount * 1000 / (lossycount + losslesscount)) / 10;
    lossyproc = Math.round(lossycount * 1000 / (lossycount + losslesscount)) / 10;

var bitratex = fb.TitleFormat("%bitrate%").Eval();
bitratex = parseInt(bitratex);
var samplerate = fb.TitleFormat("%samplerate%").Eval();
samplerate = parseInt(samplerate);
var bitspersample = fb.TitleFormat("$info(bitspersample)").Eval();
bitspersample = parseInt(bitspersample);
var channels = fb.TitleFormat("$info(channels)").Eval();
channels = parseInt(channels);
compressionperc = (bitratex*100000)/(samplerate*bitspersample*channels);
compressionperc = Math.round(compressionperc);
compressionperc2 = compressionperc2 + compressionperc;
    avgcompressionperc = compressionperc2 / on_playback_new_track2;
    avgcompressionperc = Math.round(avgcompressionperc * 100) / 100;
if (on_playback_new_track2 === 1) {
mincompressionperc = compressionperc;
maxcompressionperc = compressionperc;
}
mincompressionperc = Math.min(mincompressionperc,compressionperc);
maxcompressionperc = Math.max(maxcompressionperc,compressionperc);
rancompressionperc = maxcompressionperc - mincompressionperc;

    bitrate = fb.Titleformat("%bitrate%").Eval();
    bitrate = parseInt(bitrate);
    bitrate2 += bitrate;
    avgbitrate = bitrate2 / on_playback_new_track2;
    avgbitrate = Math.round(avgbitrate * 100) / 100;
if (on_playback_new_track2 === 1) {
minbitrate = bitrate;
maxbitrate = bitrate;
}
bitrate3 += (bitrate * bitrate);
minbitrate = Math.min(minbitrate,bitrate);
maxbitrate = Math.max(maxbitrate,bitrate);
ranbitrate = maxbitrate - minbitrate;
devbitrate = Math.sqrt((on_playback_new_track2 * bitrate3) - (bitrate2 * bitrate2)) / on_playback_new_track2;
    devbitrate = Math.round(devbitrate * 100) / 100;


    bfilesize = fb.Titleformat("%filesize%").Eval();
    bfilesize = parseInt(bfilesize);
    filesize = readablizeBytes(bfilesize);
    bfilesize2 += bfilesize;
    filesize2 = readablizeBytes(bfilesize2);
    bavgfilesize = bfilesize2 / on_playback_new_track2;
    bavgfilesize = Math.round(bavgfilesize * 100) / 100;
    avgfilesize = readablizeBytes(bavgfilesize);

length = fb.Titleformat("%length%").Eval();
    length_seconds = fb.Titleformat("%length_seconds%").Eval();
    length_seconds = parseInt(length_seconds);
    length_seconds2 = length_seconds2 + length_seconds;
    avglength_seconds = length_seconds2 / on_playback_new_track2;
    avglength_seconds = Math.round(avglength_seconds * 100) / 100;
    avgfilesize = readablizeBytes(bavgfilesize);

totaltracks = fb.Titleformat("%totaltracks%").Eval();
totaltracks = parseInt(totaltracks,10);
totaltracks2 += totaltracks;
avgtotaltracks = totaltracks2 / on_playback_new_track2;
avgtotaltracks = Math.round(avgtotaltracks * 100) / 100;
if (on_playback_new_track2 === 1) {
mintotaltracks = totaltracks;
maxtotaltracks = totaltracks;
}
mintotaltracks = Math.min(mintotaltracks,totaltracks);
maxtotaltracks = Math.max(maxtotaltracks,totaltracks);
rantotaltracks = maxtotaltracks - mintotaltracks;

tracknumber = fb.Titleformat("%tracknumber%").Eval();
tracknumber = parseInt(tracknumber,10);
tracknumber2 += tracknumber;
avgtracknumber = tracknumber2 / on_playback_new_track2;
avgtracknumber = Math.round(avgtracknumber * 100) / 100;
if (on_playback_new_track2 === 1) {
mintracknumber = tracknumber;
maxtracknumber = tracknumber;
}
mintracknumber = Math.min(mintracknumber,tracknumber);
maxtracknumber = Math.max(maxtracknumber,tracknumber);
rantracknumber = maxtracknumber - mintracknumber;

    window.Repaint();
}


function on_playback_stop() {
    ar_days = 0;
    ar_days2 = 0;
    ar_days3 = 0;
    ar_days4 = 0;
    ar_years = 0;
    ar_years2 = 0;
    ar_years3 = 0;
    ar_years4 = 0;
    date = 0;
    difyear = 0;
    playcount = "NaN";
    rating = "NaN";
bitrate = 0;
filesize = 0;
length = 0;
length_seconds = 0;
playbacktimeperc = 0;
compressionperc = 0;
tracknumber = 0;
totaltracks = 0;
    window.Repaint();
}



function on_item_played() {
    playcount++;
    playcount4++;

if (on_playback_new_track2 === 1) {
minplaycount = playcount;
maxplaycount = playcount;
}
avgplaycount = playcount4 / on_playback_new_track2;
avgplaycount = Math.round(avgplaycount * 100) / 100;
minplaycount = Math.min(minplaycount,playcount);
maxplaycount = Math.max(maxplaycount,playcount);
ranplaycount = maxplaycount - minplaycount;

ar_years3 = 0;
ar_days3 = 0;
    window.Repaint();
}

function on_playlist_switch() {
    window.Repaint();   
}

function on_colors_changed() {
    color = dui ==1 ? window.GetColorDUI(2) : RGB(200,0,0);
    color2 = dui ==1 ? window.GetColorDUI(0) : window.GetColorCUI(0);
    window.Repaint();
}

function on_font_changed() {
    g_font = dui == 1 ? window.GetFontDUI(0) : window.GetFontCUI(0);
    window.Repaint();
}

ADD: lossless compression in %
ADD: track number, total tracks
« Letzte Änderung: 26. Februar 2010, 09:58:58 von grimes »
Joseph Mallord William Turner (1775-1851) - Die kämpfende Temeraire (1838)

Bubi

  • Stammposter
  • *
  • Beiträge: 178
Was isn dein Average Rating im Screenshot von #25, grimes?
« Letzte Änderung: 26. Februar 2010, 09:58:07 von grimes »

grimes

  • * Tutorialschreiber *
  • Administrator
  • *
  • Beiträge: 2294
Das ist einfach:
Hat der erste gespielte song 5 sterne und der zweite nur 3 sterne, so ist der Durchschnitt (average) 4 Sterne.
Im Beispiel von #24 beträgt die durchschnittliche Anzahl der Sterne 4,6 (gemittelt über 15 songs)
Ich interpretiere: ich habe saugeile Musik gehört :D
Joseph Mallord William Turner (1775-1851) - Die kämpfende Temeraire (1838)

Bubi

  • Stammposter
  • *
  • Beiträge: 178
Das ist der Durchschnitt der gespielten Songs?

Schade :(

grimes

  • * Tutorialschreiber *
  • Administrator
  • *
  • Beiträge: 2294
Seit WSH Panel Mod 1.2.1 werden global callbacks asynchron angerufen.

Zitat
CHG: Global callbacks are invoked asynchronously now.

Dies ermöglicht es folgende Skripte zu vereinfachen:

Seek

//Seek by grimes
//fb2k 1.0+, WSH Panel Mod 1.3.0+ required
//DUI/CUI ready


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

var seek = 10;
var delta = 0;
var dui = window.InstanceType;

var g_font = gdi.Font("Segoe UI", 16, 0);
var g_font2 = gdi.Font("Segoe UI", 20, 0);
var g_font3 = gdi.Font("Segoe UI", 12, 0);
//var color = RGB(200,0,0);
var color = dui == 1 ? window.GetColorDUI(3) : RGB(200,0,0);
//var color2 = RGB(0,0,0);
var color2 = dui == 1 ? window.GetColorDUI(0) : window.GetColorCUI(0);

function on_paint(gr){
gr.FillSolidRect(0, 0, window.Width, window.Height, dui ==1 ? window.GetColorDUI(1) : window.GetColorCUI(3));
    gr.DrawString("Seek", g_font2, color, 0, -80, window.Width, window.Height, 0x11005000);
gr.DrawString("Ahead by " + seek + " second(s).", g_font, color2, 0, -40, window.Width, window.Height, 0x11005000);
gr.DrawString("run = lbtn, set seektime = wheel", g_font3, color2, 0, 0, window.Width, window.Height, 0x11005000);
}
function on_mouse_lbtn_down(x,y){
if (!fb.IsPlaying){
fb.Play();
}
for (i = 0; i<seek; i++) { fb.RunMainMenuCommand("Ahead by 1 second"); }
for (i = 0; i<-seek; i++) { fb.RunMainMenuCommand("Back by 1 second"); }
}

function on_mouse_move(x,y){

}

function on_mouse_wheel(delta){
for (i = 0; i<delta; i++) { seek++;}
for (i = 0; i<-delta; i++) {
seek--;
}
window.Repaint();
}

function on_playback_stop(reason) {
//seek = 10;
window.Repaint();
}

function on_colors_changed() {
    color = dui ==1 ? window.GetColorDUI(2) : RGB(200,0,0);
    color2 = dui ==1 ? window.GetColorDUI(0) : window.GetColorCUI(0);
    window.Repaint();
}

function on_font_changed() {
    window.Repaint();
}



Loop

//Loop by grimes
//fb2k 1.0+, WSH Panel Mod 1.3.0+ required
//DUI/CUI ready


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

var delta = 0;
var time = 0;
var test = false;
var start = window.GetProperty("Start [s]: ", 0);
var end = window.GetProperty("End [s]: ", 10);
var preview = window.GetProperty("Preview mode? ", false);
var loop = end - start;
var loopmode = window.GetProperty("Loop/Preview enabled?", false);
var loopcount = 0;
var dui = window.InstanceType;

var g_font = gdi.Font("Segoe UI", 16, 0);
var g_font2 = gdi.Font("Segoe UI", 20, 0);
var g_font3 = gdi.Font("Segoe UI", 12, 0);
//var color = RGB(200,0,0);
var color = dui == 1 ? window.GetColorDUI(2) : RGB(200,0,0);
//var color2 = RGB(0,0,0);
var color2 = dui == 1 ? window.GetColorDUI(0) : window.GetColorCUI(0);

function on_paint(gr) {
    gr.FillSolidRect(0, 0, window.Width, window.Height, dui ==1 ? window.GetColorDUI(1) : window.GetColorCUI(3));
    if (loopmode) {
        gr.DrawString("Loop (true) " + loopcount + " x", g_font2, color, 0, -80, window.Width, window.Height, 0x11005000);
    }
    else {
        gr.DrawString("Loop (false) ", g_font2, color, 0, -80, window.Width, window.Height, 0x11005000);
    }
    gr.DrawString("Double click here to enable/disable loop", g_font3, color, 0, -40, window.Width, window.Height, 0x11005000);
    gr.DrawString("Start: " + start + " s  Loop: " + loop + " s  End: " + end + " s", g_font, color2, 0, 0, window.Width, window.Height, 0x11005000);
    if (preview){gr.DrawString("Preview mode (mbtn)", g_font, color2, 0, +40, window.Width, window.Height, 0x11005000);}
else {gr.DrawString("Loop mode (mbtn)", g_font, color2, 0, +40, window.Width, window.Height, 0x11005000);}
gr.DrawString("start++ = key, end++/end - - = wheel", g_font3, color2, 0, +80, window.Width, window.Height, 0x11005000);
}

function on_mouse_lbtn_dblclk(x, y) {
if (!loopmode) {
loopmode = true;
            window.NotifyOthers("loop", "true"); //true
}
else {
loopmode = false;
            window.NotifyOthers("loop", ""); // false
}
window.Repaint();
}

function on_mouse_mbtn_down(x, y) {
if(!preview) {preview = true;}
else {preview = false;}
window.Repaint();
}

function on_playback_new_track(metadb) {
if (loopmode) {
for (var i = 0; i < start; i++) {
fb.RunMainMenuCommand("Ahead by 1 second");
}
}
window.Repaint();
}


function on_key_down(vkey) {
    start++;
    if (start >= end) {
        end = start + 1;
    }
loop = end - start;
    window.Repaint();
}


function on_mouse_wheel(delta) {
    for (i = 0; i < delta; i++) {
end++;
loop = end - start;
    }
    for (i = 0; i < -delta; i++) {
        end--;
loop = end - start;
if (end <= start) {
start = end - 1;
loop = 1;

if (end <= 1 && start <= 0) {
start = 0;
end = 1;
loop = 1;
}
}
    }
    window.Repaint();
}



function on_playback_stop(reason) {
    test = false;
loopcount = 0;
    window.Repaint();
}



function on_playback_time(time) {
    time = Math.round(fb.PlaybackTime);
    if ((time > end || time < end - loop) &&  loopmode) {
        fb.play();
    }
    if (time >= end) {
        test = true;
    } else {
        test = false;
    }
if (test && loopmode) {
loopcount++;
window.Repaint();
for (i = 0; i < loop; i++) {
fb.RunMainMenuCommand("Back by 1 second");
}
if (preview) {
fb.Next();
loopmode = true;
for (var i = 0; i < start; i++) {
                fb.RunMainMenuCommand("Ahead by 1 second");
            }
}
}
window.Repaint();
}

function on_colors_changed() {
    color = dui ==1 ? window.GetColorDUI(2) : RGB(200,0,0);
    color2 = dui ==1 ? window.GetColorDUI(0) : window.GetColorCUI(0);
    window.Repaint();
}

function on_font_changed() {
    window.Repaint();
}



« Letzte Änderung: 28. Januar 2010, 21:15:40 von grimes »
Joseph Mallord William Turner (1775-1851) - Die kämpfende Temeraire (1838)