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: JScript Panel script discussion/help (Read 524125 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Re: JScript Panel script discussion/help

Reply #1775
orange to red gradient VU meter colors

Code: [Select]
rainbow_stops = [
[ 1.0, RGB(255, 0, 0) ],
[ 0.66, RGB(255, 60, 1) ],
[ 0.33, RGB(255, 128, 0) ],
[ 0.0, RGB(255, 160, 75) ]
];

how do you get it to show the full bars for screenshots have a tone that peaks or?

0 -1
You wrote it backwards.
SHURE SRH1840, SENNHEISER HD660S2, SENNHEISER HD620S, SENNHEISER HD 490 Pro Plus, beyerdynamic DT 1990 PRO, HiFiMAN Edition XS, HIFIMAN ANANDA, Bowers & Wilkins P7, FiiO FT5, FiiO FT1 Pro, 水月雨 (MOONDROP) 空鳴 - VOID, SONY WH1000XM5 (made a Upgrade/Balanced Cable by myself)

Re: JScript Panel script discussion/help

Reply #1776
orange to red gradient VU meter colors

Code: [Select]
rainbow_stops = [
[ 1.0, RGB(255, 0, 0) ],
[ 0.66, RGB(255, 60, 1) ],
[ 0.33, RGB(255, 128, 0) ],
[ 0.0, RGB(255, 160, 75) ]
];



how do you get it to show the full bars for screenshots have a tone that peaks or?

0 -1
You wrote it backwards.


 I have copied it from Case's code and only changed the numbers so I didn't  ;)

also it could be said this is the correct order since its not actually 0, 0,33 and 0,66 but minus 0 minus 0,33 and minus 0,66 and 1
PC - Teac UD-505 - Adam Audio A4V + Sub7 - DCA ÆON Open X - TinHifi P1 Max.
Samsung S23 Ultra 512GB - Galaxy Buds3 Pro.

Re: JScript Panel script discussion/help

Reply #1777
> also it could be said this is the correct order since its not actually 0, 0,33 and 0,66 but minus 0 minus 0,33 and minus 0,66 and 1

Thanks for this info.
SHURE SRH1840, SENNHEISER HD660S2, SENNHEISER HD620S, SENNHEISER HD 490 Pro Plus, beyerdynamic DT 1990 PRO, HiFiMAN Edition XS, HIFIMAN ANANDA, Bowers & Wilkins P7, FiiO FT5, FiiO FT1 Pro, 水月雨 (MOONDROP) 空鳴 - VOID, SONY WH1000XM5 (made a Upgrade/Balanced Cable by myself)

Re: JScript Panel script discussion/help

Reply #1778
0 -1
You wrote it backwards.

You have no idea what you're talking about.

also it could be said this is the correct order since its not actually 0, 0,33 and 0,66 but minus 0 minus 0,33 and minus 0,66 and 1

You have no idea what you're talking about.

It's perfectly fine and reasonable that you don't understand stuff any of this but don't pull stuff out of your anus just to pretend that you do.

All you need to know is that for horizontal bars in this script, 0.0 is LEFT and 1.0 is RIGHT. The order is irrelevant.

Re: JScript Panel script discussion/help

Reply #1779
Hi :)

I managed to set up the script the way I like it, the only big problem is that the lines for each song are huge, I think because of the size of the stars. Does anyone know how to resize it all?
I wish there was no space between one title and another, like in the photo I posted before
Thanks


Re: JScript Panel script discussion/help

Reply #1780
I can't help thinking this is what initiated the confusion:
how do you get it to show the full bars for screenshots have a tone that peaks or?
Perhaps English isn't the OP's native language?  The above needs at least some punctuation, before it becomes sensible:

"How do you get it to show the full bars, for screenshots?  Have a tone that peaks, or...?"

Fortunately, marc2k3 understood:

If you want to fake a full bar, add this to your panel temporarily.

Code: [Select]
function to_db() {
    return Math.random();
}
It's your privilege to disagree, but that doesn't make you right and me wrong.

Re: JScript Panel script discussion/help

Reply #1781
0 -1
You wrote it backwards.

You have no idea what you're talking about.

also it could be said this is the correct order since its not actually 0, 0,33 and 0,66 but minus 0 minus 0,33 and minus 0,66 and 1

You have no idea what you're talking about.

It's perfectly fine and reasonable that you don't understand stuff any of this but don't pull stuff out of your anus just to pretend that you do.

All you need to know is that for horizontal bars in this script, 0.0 is LEFT and 1.0 is RIGHT. The order is irrelevant.
No stuff is pulled from my Anus, it is fine you know things but don't pull unneeded rudeness out your own anus thanks.
PC - Teac UD-505 - Adam Audio A4V + Sub7 - DCA ÆON Open X - TinHifi P1 Max.
Samsung S23 Ultra 512GB - Galaxy Buds3 Pro.

Re: JScript Panel script discussion/help

Reply #1782
I can't help thinking this is what initiated the confusion:
how do you get it to show the full bars for screenshots have a tone that peaks or?
Perhaps English isn't the OP's native language?  The above needs at least some punctuation, before it becomes sensible:

"How do you get it to show the full bars, for screenshots?  Have a tone that peaks, or...?"

Fortunately, marc2k3 understood:

If you want to fake a full bar, add this to your panel temporarily.

Code: [Select]
function to_db() {
    return Math.random();
}


exactly  :D
PC - Teac UD-505 - Adam Audio A4V + Sub7 - DCA ÆON Open X - TinHifi P1 Max.
Samsung S23 Ultra 512GB - Galaxy Buds3 Pro.

Re: JScript Panel script discussion/help

Reply #1783
This playlist manager is bundled with the component itself ....

https://jscript-panel.github.io/gallery/smooth-playlist-manager/

is better looking without weird yellow/red bits, obeys your UI colours by default and has a whole bunch of features detailed below the image on that page.

But the item count is not optional.

but how do you create folders and subfolders?
And then I don't see all the options to change size, visible or hidden elements.

Re: JScript Panel script discussion/help

Reply #1784
Hi All,
I have just  created a script to add 'value' to foo_youtube component by providing it with a song list.

//------------ CREDIT -----------------//
Credit goes to:
- @Wil-B (https://github.com/Wil-B) for the fantastic 'Find-and-Play' app, along with the 'Biography' and 'Library-Tree' scripts based on Spider Monkey Panel. The 'Find-and-Play' inspired me to explore [YouTube searching]. However I've tried, @Wil-B's scripts still set the benchmark.
- @Marc2003 (https://github.com/jscript-panel) for the excellent [JScript Panel 3] component. @Marc2003 actively updates this component with new features, bug fixes, and beautiful, tidy sample scripts.
# This script uses some API (web service) keys from @Wil-B and @marc2003 for trial purposes. Even though these keys are bundled with their public scripts, we should show and treat them with respect.

//---------- ABOUT this JSP3_foo_youtube_addon script ----------------------//
@1_ Sole Purpose:
- YouTube search for songs or any information.
- For others to improve and tailor to their needs (as usual, I've left many comments for easy reference).

@2_ Prerequisites:
- foo_youtube component: https://www.foobar2000.org/components/view/foo_youtube; https://fy.3dyd.com/  to play YouTube videos.
- and/or yt-dlp.exe (for YouTube search): Get it from here [https://github.com/yt-dlp/yt-dlp] if you want to search YouTube using yt-dlp.exe.
 (yt_dlp.exe located under this path : {fb2k_Profile_Path}\skins\external_helper\yt-dlp.exe).

@3_ How It Works:
- Users need to feed foo_youtube with a structured list of songs that is friendly with the [foo_youtube] component. This builds a playlist from track locations (similar to foo_tags).
- Where can we get the song list?
  + Manually: Users input text to search directly on youtube.com (not limited to audio tracks).
  + Still manually: Users input an artist name (1), last.fm verifies this name and returns that artist's song list from its database (2), and then youtube.com searches for this data (artist + song title).
  + Automatically: Get the list from somewhere.
    - Possible online 'databases':
      * MusicBrainz (musicbrainz.org)
      * lastFM (last.fm, ws.audioscrobbler.com): We prefer this database as last.fm seems to be YouTube's ally.
        > Top trending tracks
        > Artist's top tracks classified by locale, years, genre, etc.
      * Official Charts (officialcharts.com)

@4_ How We Interact with This Script:
- Context menu via right-click.

@5_ Why YouTube Music:
- We may not get 'high-res' audio tracks from youtube.com, BUT:
  - It's a huge store for audio tracks, especially the [YouTube Music] streaming platform.
  - Videos often contain audio tracks.
  - Some/many audio tracks were/are uploaded by artists, 'semi-artists,' and are only available on this platform (especially single versions).
  - Trending.
  . . .
  Let's dive in!

@6_ Limitations:
- YouTube searching may return irrelevant results, such as other artists' audio tracks, instead of the ones we're looking for.
  How to improve:
  + Firstly, let YouTube return an audio track list, and then we search for the 'best' or good match based on our judgment (this will slow things down).
  + Alternatively, we can grab only the first/top audio track from the pool list, hoping that YouTuBe (Google) returns the best match ranked at the top (faster approach).
- User interface/UI: Not very user-friendly.
- Bugs: this is just departure , version  [1.0.0 QM] 22Aug2024.

Wish you all  the best.
ilovefb2k

Re: JScript Panel script discussion/help

Reply #1785
Ooh, what's that at the bottom. :P



edit: obviously I stole the code. It's from foosion's Direct2D oscilloscope.  :))


Re: JScript Panel script discussion/help

Reply #1786
Text Display + Album Art + Rating

delete

function on_playback_seek() {
   seekbar.playback_seek();
}

if no crash.

Re: JScript Panel script discussion/help

Reply #1787
That bug is now fixed in the latest release. Thanks.

Re: JScript Panel script discussion/help

Reply #1788
Here's a super-quick conversion of the VU-meter script changed to use the new audio interface in JScript Panel 3.6.6.
Code: [Select]
// ==PREPROCESSOR==
// @name "JSP3 VU Meter"
// ==/PREPROCESSOR==

var timer_SetInterval = 30; //ms
var VUMeterFb2k = false; // true: foobar2000 VU Meter style; false: free style

var font,font_t = "";
var g_text = "";
var ww = 0, wh = 0;
var colours = {
  text : 0,
  background : 0,
  highlight : 0,
}

var color_1;
var color_2;
var color = [];
var step = 20; // more is less space between bars (cpu powers consumed)  and vice versa.
var minDB = -60; //dB as Foobar2000' s built - in VU Meter
var db = [];

var ColourTypeCUI = {
  text: 0,
  selection_text: 1,
  inactive_selection_text: 2,
  background: 3,
  selection_background: 4,
  inactive_selection_background: 5,
  active_item_frame: 6
};


var ColourTypeDUI = {
  text: 0,
  background: 1,
  highlight: 2,
  selection: 3
};

var FontTypeCUI = {
  items : 0,
  labels : 1,
};

var FontTypeDUI = {
  defaults : 0,
  tabs : 1,
  lists : 2,
  playlists : 3,
  statusbar : 4,
  console : 5,
};


function update_colours() {
  if (window.IsDefaultUI) {
    colours.text = window.GetColourDUI(ColourTypeDUI.text);
    colours.highlight = window.GetColourDUI(ColourTypeDUI.highlight);
    colours.background = window.GetColourDUI(ColourTypeDUI.background);
  } else {
    colours.text = window.GetColourCUI(ColourTypeCUI.text);
    colours.background = window.GetColourCUI(ColourTypeCUI.background);
    colours.highlight = blendColours(colours.text, colours.background, 0.4);
  }

  //custom colours override
  //  colours.text = RGB(255,255,255);
  //  colours.highlight = RGB(0,0,250);
  //  colours.background = RGB(0,0,0);

  color_1 = colours.text; //  or any color  RGB(250,250,250);
  color_2 = colours.highlight; // or any color RGB(0,0,0);

  color = [];

  for (var i = 0; i <= step; i++) {
    color.push(blendColours(color_1, color_2, (i / step)));
    db.push((minDB / step) * (step - i))
  }

}

function update_font() {
  if (window.IsDefaultUI) {
    font = window.GetFontDUI(FontTypeDUI.defaults);
  } else {
    font = window.GetFontCUI(FontTypeCUI.items);
  }

  // adjust size
  font_t = font;
  var obj = JSON.parse(font_t);
  obj.Size -= 4;
  font_t = JSON.stringify(obj);
}

update_colours();
update_font();

function on_colours_changed() {
  update_colours();
  window.Repaint();
}

function on_mouse_lbtn_up(x, y) {
  window.ShowConfigure();
}

function on_size() {
  ww = window.Width;
  wh = window.Height;
}

//------------- just an implementation /////////////

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)); }
function toRGB(col) {
  var a = col - 0xFF000000;
  return [a >> 16, a >> 8 & 0xFF, a & 0xFF];
}

function blendColours(c1, c2, factor) { //@Marc2003
  var c1 = toRGB(c1);
  var c2 = toRGB(c2);
  var r = Math.round(c1[0] + factor * (c2[0] - c1[0]));
  var g = Math.round(c1[1] + factor * (c2[1] - c1[1]));
  var b = Math.round(c1[2] + factor * (c2[2] - c1[2]));
  return (0xff000000 | (r << 16) | (g << 8) | (b));
}

function on_paint(gr) {
  gr.FillRectangle(0, 0, ww, wh, colours.background);
    //
    LM = RMS_level1; // ~ VUMeter.LeftLevel;
    RM = RMS_level2; // ~ VUMeter.RightLevel;
    L = Peak_level1; // ~ VUMeter.LeftPeak;
    R = Peak_level2; // ~ VUMeter.RightPeak;

    var h = 20; // VUh_bar;
    var VUh_bar = 20; //
    var VU_x = 20; //VUx;
    var VUy = 5;
    var VUh_off = h + 5;
    var VUw = ww - 20;

    var yL = (VUy + h);
    var yLM = (VUy + h) + VUh_bar;
    var yRM = (VUy + h) + VUh_bar + VUh_off;
    var yR = (VUy + h) + VUh_bar + VUh_off + VUh_bar;

    var dbLM = PctToDB(LM),
    dbRM = PctToDB(RM),
    dbL = PctToDB(L),
    dbR = PctToDB(R);

    if (VUMeterFb2k) {// foobar2000 VUMeter style
        if (!(dbLM == 0 || dbLM == -Infinity)) {
            // 65 : -60db- 0dB (+ 5dB offset at the end beyond 0dB ) scale

            var wLM = Math.round(ww * ((100 + Number(dbLM)) / 65 - 40 / 65));
            var wRM = Math.round(ww * ((100 + Number(dbRM)) / 65 - 40 / 65));
            var wL = Math.round(ww * ((100 + Number(dbL)) / 65 - 40 / 65));
            var wR = Math.round(ww * ((100 + Number(dbR)) / 65 - 40 / 65));

            FillGradientRectangle(gr, VU_x, yLM, wLM, h - 1, 1, colours.text, colours.highlight);
            FillGradientRectangle(gr, VU_x, yRM, wRM, h - 1, 1, colours.text, colours.highlight);
            FillGradientRectangle(gr, VU_x, yL, wL, h - 1, 1, colours.text, colours.highlight);
            FillGradientRectangle(gr, VU_x, yR, wR, h - 1, 1, colours.text, colours.highlight);
        }
    } else { // free style
        h = 15;
        var offset = Math.floor((VUw - VU_x) / (step + 1)); //step+1 : number of bars and we need 1 more bar at the end
        var w = Math.floor((VUw - VU_x) / (step + 4)); // step+4 : width bar. we need some spaces between bars.

        for (var i = 0; i <= step; i++) {
            if (i > 0) {
                dbLM = PctToDB(LM),
                dbRM = PctToDB(RM),
                dbL = PctToDB(L),
                dbR = PctToDB(R);
            }

            gr.FillRectangle(VU_x + i * offset, yLM, w, h, dbLM >= db[i] ? color[i] : RGBA(0, 0, 0, 0));
            gr.FillRectangle(VU_x + i * offset, yRM, w, h, dbRM >= db[i] ? color[i] : RGBA(0, 0, 0, 0));

            if ((dbL > db[i] && dbL < db[i + 1])) {
                var wL = i * offset + offset / Math.abs(db[i + 1] - db[i]) * Math.abs(dbL - db[i]);
                gr.FillRectangle(VU_x, yL, wL, h, color[i]);
            }

            if ((dbR > db[i] && dbR < db[i + 1])) {
                var wR = i * offset + offset / Math.abs(db[i + 1] - db[i]) * Math.abs(dbR - db[i]);
                gr.FillRectangle(VU_x, yR, wR, h, color[i]);
            }
        }
    }

    // X-,Y-axis
    for (var i = (65 - 5) / 5, j = 0; i >= 0; i--, j++)
        gr.WriteText("-" + 5 * i + "dB", font_t, colours.text, VU_x / 2 + j * (ww - VU_x) / 13, yR + h + 10, ww, wh);

    gr.WriteText("FL", font_t, colours.text, 0, yLM, ww, wh);
    gr.WriteText("FL", font_t, colours.text, 0, yL, ww, wh);
    gr.WriteText("FR", font_t, colours.text, 0, yRM, ww, wh);
    gr.WriteText("FR", font_t, colours.text, 0, yR, ww, wh);

    FillGradientRectangle(gr, VU_x, yR + h + 5, ww, 1, 1, colours.text, colours.highlight);
}

function clear_meter() {
  RMS_level1 = 0;
  RMS_level2 = 0;
  Peak_level1 = 0;
  Peak_level2 = 0;
  prev_time = 0;
  window.Repaint();
}

function on_playback_new_track(handler) {
  VUMeter();
}

function on_playback_stop(reason) {
  if (reason != 2) { // not starting another track
    offVUMeterTimer();
    clear_meter();
  }
}

function on_playback_pause(state) {
  state ? offVUMeterTimer() : onVUMeterTimer();
}

var RMS_level1 = RMS_level2 = Peak_level1 = Peak_level2 = 0; // RMS and Peak level of each 2 channels.
var timer_SetInterval_id = null;
var prev_time = 0;

function on_script_unload() {
}

function PctToDB(num) {
    // input : num [0-1]
    // output: dB [-100,0]
    return ((2000 * Math.log(num) / Math.LN10) / 100).toFixed(2);
}

function onVUMeterTimer() {
  if (!fb.IsPlaying || fb.IsPaused) return;

  if (timer_SetInterval_id === null) {
    timer_SetInterval_id = window.SetInterval(function() {
      if (fb.PlaybackTime) {
        var cur_time = fb.PlaybackTime;
        var chunk = fb.GetAudioChunk(cur_time - prev_time);
        if (chunk) {
          prev_time = cur_time;
          var data = chunk.Data.toArray();
          if (data) {
            var ch_count = chunk.ChannelCount;
            var frame_len = chunk.SampleCount;
            var ch2_idx = 1;
            if (ch_count < 2) ch2_idx = 0;
            var sum1 = 0;
            var sum2 = 0;
            var peak1 = 0;
            var peak2 = 0;
            for (var i = 0; i < data.length; i += ch_count) {
              var l = data[i];
              var r = data[i + ch2_idx];
              if (l > peak1) peak1 = l;
              if (r > peak2) peak2 = r;
              sum1 += l * l;
              sum2 += r * r;
            }
            RMS_level1 = Math.sqrt(sum1/frame_len);
            RMS_level2 = Math.sqrt(sum2/frame_len);
            Peak_level1 = peak1;
            Peak_level2 = peak2;
          }
        }
      }

      //(window.RepaintRect(x, y, w, h);
      window.Repaint();
    }, timer_SetInterval);
  }
}

function offVUMeterTimer() {
  if (timer_SetInterval_id) window.ClearInterval(timer_SetInterval_id);
  timer_SetInterval_id = null;
}

onVUMeterTimer();

function VUMeter() {
  offVUMeterTimer(); //turn off timer
  var handle = fb.IsPlaying ? fb.GetNowPlaying() : false;
  if (!handle) return;

  // set VUMeter timer tiktok
  onVUMeterTimer();
}

function FillGradientRectangle(gr, x, y, w, h, direction, colour1, colour2) { //@Marc2003
  var stops = [[0, colour1], [1, colour2]];
  var brush = {
      Start: [0, 0],
      Stops: stops
  };
  if (direction == 0)
      brush.End = [0, h];
  else
      brush.End = [w, 0];
  gr.FillRectangle(x, y, w, h, JSON.stringify(brush));
}

//EOF

Edit: tiny bit cleaned up version.
Hi Case--your first version of the VU Meter implementation made possible by marc2k3's new JSP code was here, using the same meter GUI as the original Ilovefb2k release.  Because the image scheme is classic, I am hoping that you wouldn't mind releasing a new version of the script?

The original has the problem of the 2 peak bars flickering out/disappearing when 0dB is reached or exceeded--have you found a way to fix that?  Also, it would be great if you could add the ability to adjust peak hold ms, and the ability to specify a maxdB level.  Thanks for any consideration!



Re: JScript Panel script discussion/help

Reply #1789
Case already rewrote it once. At this point, you're taking the piss.

Re: JScript Panel script discussion/help

Reply #1790
@eurekagliese

I made the final switch to 64 bit.

I noticed something strange about the radio stream.

The default custom track is automatically set in enable dynamic.

This all happens with m3u files from playlists.




 

Re: JScript Panel script discussion/help

Reply #1791
Case already rewrote it once. At this point, you're taking the piss.
My request was directed at Case.  By the way, the script in his post I quoted above is the only one where he used the original ilovefb2k format 4-bar meter, with the segmented RMS ones and solid peak.  I'm fully aware that he posted a second rewrite, which I have, but that one used the 2-bar RMS format with the peak as an end indicator line.  I won't trade insults with you, just state facts.

Re: JScript Panel script discussion/help

Reply #1792
It is possible to adapt this Digital Clock module for JS 3 scripts?

Re: JScript Panel script discussion/help

Reply #1793
For the Digital Clock + Calendar module, I have currently partially solved it with a version for
foo_uie_webview very simplified, manages only one language and one color:




Re: JScript Panel script discussion/help

Reply #1794
In the Thumbs sample I was unable to find, both in the loading modules and in the Thumbs module, the instruction that allows me to change the black color that I have under the various thumbs.



I have the entire skin in Dark Mode with the default UI setting, and I would like that black area under the thumbs to use the default UI setting.

Re: JScript Panel script discussion/help

Reply #1795
Feature request @mark2k3
Add genre and locale/country taggers to lastfm scripts. (Like in SMP Biography)
It would be nice to be able to fetch the fields from lastfm and write them into tags.

Also regarding the Lastfm + Bio script, perhaps adding Popular Now and removing the Tags: string would be nice.

Thank you.

Re: JScript Panel script discussion/help

Reply #1796
@eurekagliese

I made the final switch to 64 bit.

I noticed something strange about the radio stream.

The default custom track is automatically set in enable dynamic.

This all happens with m3u files from playlists.





Solved.

Line 1847 colour_index =1; change to colour_index = 0;

function on_playback_dynamic_info_track(type) {
   if (type == 0) {
      colour_index = 0;
      window.Repaint();
   } else {
      colour_index = 0;
      update_album_art(fb.GetNowPlaying())
   };
}

with the streaming radio, foobar2000 64 bit and exernal tag it is set by default in enable dynamc in automatic.

m3u in playlist, cover.* in folder dedicated to radio covers.

Re: JScript Panel script discussion/help

Reply #1797
@marc2k3 ,
I just realized that you stopped supporting Windows 7/8 hence window.CreateThemeManager has disappeared (v3.4.0).
I was using this a lot to draw buttons similarly to your former sample : "SimpleThemedButton + Tooltip".

Do you know any other way to create these buttons with the latest version of JScript ?

Thanks

Re: JScript Panel script discussion/help

Reply #1798
Replace DrawThemeBackground with DrawRectangle/FillRectangle/rounded variants. You can use utils.GetSysColour to get various default windows colours.

Re: JScript Panel script discussion/help

Reply #1799
Perfect, thanks !