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 523821 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

Re: JScript Panel script discussion/help

Reply #1926
It's standard installation. You specified the installation folder yourself, not the standard installation folder.
The configuration folder is as follows.

"C:\Users\UserName\AppData\Roaming\foobar2000-v2"

Launch foobar2000. Shift key + menu "File" > Browse configuration folder will open.
The foobar2000-v2 folder will open.

skins.7z
https://mega.nz/file/8L9XSRDJ#S1tH53eoNSbIMh8ujNKEXphb3uH7LehSeGXRl5F-eJo

Unzip the skins.7z file.
Place the skin folder as follows:
"foobar2000-v2"

Prepare JScript Panel 3 Panel and load "{deployed} AIMP Analog VU Meter.txt". JScript Panel 3 Panel context menu > Configure... >Tools > Import
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 #1927
my app data sorry it took me so long

Re: JScript Panel script discussion/help

Reply #1928
This is the configuration folder "foobar2000-v2" folder. Place the Skin folder you downloaded there. The Skin folder is included. Then, start foobar2000 and load the Script file ({deployed} AIMP Analog VU Meter.txt).





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 #1929
This is sounding harder than it is;  if you have used JSP3 before it's easy.

1.  First, download the latest script, version "1.0.12 QM 06-11-24," inside the rar posted here:  https://hydrogenaud.io/index.php?action=dlattach;topic=110516.0;attach=33430

2.  Create a folder for the skins anywhere on your PC, like "C:\beat_audio_vu_meter".  Extract the *.txt script from the rar, go to line 92 and change the path of the skins folder to where you made it, e.g.
Code: [Select]
var aimp_path = "c:\\beat_audio_vu_meter\\";
The latest "{deployed} AIMP Analog VU Meter....." rar file you downloaded above contains no skins but the earlier ones do, check the earlier posts from ilovefb2k, and drop in your skins folder the ones from those.

3.  Go into Layout Editing mode in fb2k, create a JSP3 panel, and add the meter script via the standard Configure/Tools/Import method.

4.  The first time it opens it will complain about not being able to find the default skin, but that happens only once.

5.  Use the context menu to select the skins, make settings adjustments, etc,

The {deployed} "AIMP Analog VU Meter_1.0.12_6Nov24" script has added user-adjustable alignment padding, and via the JSP3 "Properties" panel the ability to set RMS/Peak Decay Speed and RMS Gain.

Re: JScript Panel script discussion/help

Reply #1930
grr i can't find my appdata folder to import aimp folder so sorry

Re: JScript Panel script discussion/help

Reply #1931
skins.7z
https://mega.nz/file/8L9XSRDJ#S1tH53eoNSbIMh8ujNKEXphb3uH7LehSeGXRl5F-eJo

Unzip the skins.7z file.
Place the skin folder as follows:
"foobar2000-v2"

This is the configuration folder "foobar2000-v2" folder. Place the Skin folder you downloaded there. The Skin folder is included. Then, start foobar2000 and load the Script file ({deployed} AIMP Analog VU Meter.txt).
Everything is included.

Just place the "Skin" folder you downloaded and unzipped. It's easy.

This is a JScript Panel script. Once you have set the folder, all you have to do is load the script.
Please take your time and read carefully. Reading carefully is the best way to understand.
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 #1932
skins.7z
https://mega.nz/file/8L9XSRDJ#S1tH53eoNSbIMh8ujNKEXphb3uH7LehSeGXRl5F-eJo

Unzip the skins.7z file.
Place the skin folder as follows:
"foobar2000-v2"

This is the configuration folder "foobar2000-v2" folder. Place the Skin folder you downloaded there. The Skin folder is included. Then, start foobar2000 and load the Script file ({deployed} AIMP Analog VU Meter.txt).
Everything is included.

Just place the "Skin" folder you downloaded and unzipped. It's easy.

This is a JScript Panel script. Once you have set the folder, all you have to do is load the script.
Please take your time and read carefully. Reading carefully is the best way to understand.

And if one has a portable installation, now I understand why it gives me an error.

Re: JScript Panel script discussion/help

Reply #1933
i get error after i apply i am very sorry

Re: JScript Panel script discussion/help

Reply #1934
grr i can't find my appdata folder to import aimp folder so sorry
By default in Windows the folder where foobar stores its the configuration data is hidden.
You need to enable show hidden files in Windows Explorer to be able to browse to the foobar configuration folder.

Re: JScript Panel script discussion/help

Reply #1935
And if one has a portable installation, now I understand why it gives me an error.
As far as I can see line 7 is obsolete since it  is the current file.
In line 92 you can set a different path if you don't like aimp_path = fb.ProfilePath + "skins\\viking\\images\\vnav_fb2k\\beat_audio_vu_meter\\"

Re: JScript Panel script discussion/help

Reply #1936
@ApacheReal
Is this an error about "{deployed} album_art [properties].txt"? How about this one?
It has nothing to do with the AIMP Analog VU Meter. The questioner already has it.

AIMP Analog VU Meter.7z
https://mega.nz/file/hblXxQqY#B8B4aMLlD3187_-yYvVrtrAblaxkYqnrD_hIbSW_kg8

@telboy1812
It's not an error, but rather the skin that is loaded first. Can't you press OK and select the skin by right-clicking?
It's already done.
Could you please show me the foobar2000 AIMP Analog VU Meter Panel?
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 #1937
grr i can't find my appdata folder to import aimp folder so sorry
By default in Windows the folder where foobar stores its the configuration data is hidden.
You need to enable show hidden files in Windows Explorer to be able to browse to the foobar configuration folder.
@Defender Thanks.
I have just described a simple way to do it.

Reply #1926: https://hydrogenaud.io/index.php/topic,110516.msg1053632.html#msg1053632

Launch foobar2000. Shift key + menu "File" > Browse configuration folder will open.
The foobar2000-v2 folder will open.
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 #1938
The Skin List is sorted by alphabet, so I put the ones that are easiest to read first.

7inch_3 gradient
7inch_3 transparent
7inch_3 vanilla
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 #1939
And if one has a portable installation, now I understand why it gives me an error.
As far as I can see line 7 is obsolete since it  is the current file.
In line 92 you can set a different path if you don't like aimp_path = fb.ProfilePath + "skins\\viking\\images\\vnav_fb2k\\beat_audio_vu_meter\\"

Thank you. I didn't want to waste time, because as you can see from the image, I'm busy on various modules with foo uei webview.


Re: JScript Panel script discussion/help

Reply #1940
@ilovefb2k : with your next AIMP Analog VU Meter script, is there any chance of adding:

1.  Vertical layout for separate L/R meters?

2.  Support for non-LVU AIMP analog skins that have "LEDs" and dual needles?  (skin attached)

Re: JScript Panel script discussion/help

Reply #1941
sorry for the long reply but not sure if I have the right idea or what line you are looking at but I do appropriate your help

Re: JScript Panel script discussion/help

Reply #1942
2 -1: sometimes the properties reset themselves :  I did utilize window.Reload(option), where option = false. this should not trigger any properties reset to default. i will check it over the weekend.
2-2: add separate padding options for right and for bottom :  Done. please find the script attached. There may be likely bugs cause i am in a rush.
4- It is fantastic that you can play around with that. I humbly raise an idea to calculate x0,y0 as per image attached. It should be easy for you to catch up.  
@ilovefb2k

2-1) Properties still reset sometimes.
2-2) Thanks for adding margin properties for top and bottom. I asked this just for consistency since I always set them to 0.

The alignment option works great. I always put it to Center. It rises an issue though. When the available height is greater than needed the vu meter is aligned correctly. However (after adjusting PivotPointX and PivotPointY) at high output the needle displays under the allotted space for the VU meter. and under the opaque L_2 png. See attached screenshot (needles in red to show the issue).

As you can see in the screenshot the original VU meter resizes automatically to use full available space.
Is this functionality you are going to look into as well?
I realize that angle calculations will become more complicated.

Another nice feature of the original VU meter is that you can adjust sensibility my using control mousewheel. which would be a great feature instead of entering a fixed value in properties.

Thx
Def
Hi @Defender,
Thank you for your feedback.
I have tried some approaches tonight to get the skin stretching (as @oops does with vu_vis_meter 'unlock aspect ratio') but ended up with almost nothing but a small progress. How hard we have tried,  we could consume a lot of CPU power. I will have more details later on in the hope that someone will help.

Regarding your feedback:
1- Properties still reset sometimes: We removed the window.Reload() method but alert users to restart fb2k.
2- Adding margin properties for top and bottom: It is very nice to know that. I have just refactored the script as I did it in a rush last time.
3- The needle displays under the allotted space for the VU meter: I also noted this early on, as a weird tail. This is a set combined of INI, background, and cover, and it is there because I do not fully understand the algorithm drawing the needle curve. For now, we have to erase the needle's 'tail' a little bit. I tried, and it worked. Well-noted this point. As you pointed out, a stretching layout will address this problem, and I tried to add that feature to the script. Please refer to my next post for more detail.
4- Adjust sensitivity by using the control mouse wheel: As needle decay speed is dictated by AIMP VU Meter's INI file, I would leave it as it is supposed to be, in my humble opinion. User input is needed only if the MobilityNegative option is missing from INI.

Regards and wish you a nice weekend.
@ilovefb2k

Re: JScript Panel script discussion/help

Reply #1943
skins.7z
https://mega.nz/file/8L9XSRDJ#S1tH53eoNSbIMh8ujNKEXphb3uH7LehSeGXRl5F-eJo

Unzip the skins.7z file.
Place the skin folder as follows:
"foobar2000-v2"

This is the configuration folder "foobar2000-v2" folder. Place the Skin folder you downloaded there. The Skin folder is included. Then, start foobar2000 and load the Script file ({deployed} AIMP Analog VU Meter.txt).
Everything is included.

Just place the "Skin" folder you downloaded and unzipped. It's easy.

This is a JScript Panel script. Once you have set the folder, all you have to do is load the script.
Please take your time and read carefully. Reading carefully is the best way to understand.
Hi @Air KEN ,
It is very nice of you, thank you.
wish you a nice weekend.
@ilovefb2k

Re: JScript Panel script discussion/help

Reply #1944
@ilovefb2k : with your next AIMP Analog VU Meter script, is there any chance of adding:

1.  Vertical layout for separate L/R meters?

2.  Support for non-LVU AIMP analog skins that have "LEDs" and dual needles?  (skin attached)
hi @sveakul,
these features are very nice, we will surely consider them in the next update.
thank your for your nice suggestions and positive feedbacks so far.
it is true that, we alone can go fast, but we together can go further.
regards
@ilovefb2k.

Re: JScript Panel script discussion/help

Reply #1945
Spoiler (click to show/hide)
hi @sveakul,
thank you for your feedback. It is just an attempt for us to play around and tune it to suit our specific look & feel. e.g. we may construct ourself a fb2k theme/skin and let this help us in manipulating  a VU Meter.
It is in no way can compared with well-coded,  beautiful and rich-feature one of @oops' or the 32x version.

hi @Defender,
yeah, you are totally right.    

wish you both a nice day.
@ilovefb2k


Spoiler (click to show/hide)
[/spoiler]
Hi @Air KEN and @all,
As per some feedback and suggestions , please find the JSP3 "AIMP Analog VU Meter" update attached, version named "1.0.1 QM 05-11-24" for convenient reference.

This update addresses some points:
- High CPU load.
- Covering some very special cases, which were not easy to find a skin for, but they are there, finally. We also attached some for your quick loading:
   + The needle is upside down. Technically, the y_needle coordinates can be in (>=0) or outside (<0) the background area.
   + The needle is horizontal.
   We find it very interesting as, to some extent, we could not think of such skins existing early on. Wow, what creativity from us as an audio lovers community.
Spoiler (click to show/hide)
Hi @Defender , @sveakul, @Air KEN and @all,
A week has gone by too fast, like the wind. Please find the updated JSP3 'AIMP Analog VU Meter' script attached, named version '1.0.13 DT-K 08-Nov-24' for convenient reference, details as following:
Just one feature was added: unlock aspect ratio, as per @Defender's suggestion.

A free night weekend allowed me to play around with this feature, which I also think is a must-try if we want the script to move on to 'animation' VU Meters, which contain pre-calculated data/images per needle angle.
Please note that once this option is on, CPU load may be boosted up to Mars and won't come back, so fasten your computer's belt for a safe trip.

What happens behind the scenes:
The script will create around 200 x 2 channels = 400 needle images (we may tune this number per the hard-coded variable stepCache, for now), which are number of screenshots of needles per angle along the meter range, then load them into 'heap' memory. We will instantly note an increase in RAM consumption in less than 1 second, then it will return to normal.
Later on, we just retrieve each needle image by its index-converted angle as real-time calculated.


To do this, we have to do a trick, just jotting it down here for those who want to make it better:
-Step 1: Allocate memory for hundreds of images.
-Step 2: Draw needles, 1 needle per 1 image, per 1 angle. This takes about 1 ms each.
-Step 3: Garbage collection. As we allocate stack memory, we have to clear it ourselves or soon end up crashing. This will also take more than 1 ms each, which is time-consuming.

So, we have to make an async task, which will transfer the clearance job (step 3) to another thread, and we can move on. In principle, we can reuse some async methods of JSP3 to do this job in a very 'strange' manner. For example:
Code: [Select]
fb.AddLocationsAsync(window_id, [""]);
on_locations_added(task_id, handle_list) { do clearing job, which is not related to this native function}
Or, simply, leave this mess for
Code: [Select]
window.SetTimeout({do clearing job}, 1) 
=> We move on, and this method, on another thread, will do the clearing job after 1 ms and not bother us.

As such, we will experience a frozen-screen instance (not core audio engine) for a very short time. To save CPU power, just do this one time per current panel size until we move to another skin. Consequently, the resolution will not be nice if we enlarge the panel size, or we will have to switch forward and back just 1 skin to update the needle images caching for the current panel size.
If something seems wrong (e.g. needles are not on show), then a 'hard reset' via context menu [shift +right click] will bring back default setting and may help.
And that is all. Wish you all the very best and a very nice weekend.

Regards,
@ilovefb2k

Re: JScript Panel script discussion/help

Reply #1946
Just one feature was added: unlock aspect ratio, as per @Defender's suggestion.
@ilovefb2k

Just a quick reaction. It works fine and is the way I am going to use it.

To clarify ... I don't want to stretch the VU meter (BIN or yours) more than either a maximum horizontal scaling or a maximum vertical scaling so I recalculate the VU meter coordinates using these maximum scaling factors. If that means there's either some horizontal or vertical space left I display a bezel around the VU meter, which I don't do with my transparent skin that I made for your script since it doesn't look better. For reference I attached the relevant code for calculating VU coordinates.
I now applied this code also to your script. As you can see your VU meter looks slightly larger than the original BIN. Reason for that is that I slightly cut the original bezel from the BIN before making the remaining bezel transparent.
Code: [Select]
	// plug.x - initial VU panel x-coordinate
// plug.y - initial VU panel y-coordinate
// plug.w - initial VU panel width
// plug.h - initial VU panel height

$ifgreater($get(dbg.vu),0, $puts(dbg1,STEP|1:|plug.xywh=$get(plug.x).$get(plug.y).$get(plug.w).$get(plug.h)) ,)

// VU panel standard settings
$puts(vu.x_fact,                400) // VU default proportion - X
$puts(vu.y_fact,                100) // VU default proportion - Y
$puts(vu.acc,                   $mul(%on.accent.vu%,%def.accent%)) // VU - Accent padding
$puts(vu.acc_limit,             $muldiv(0,%scale%,100)) // Limit to trigger  accent padding - 0= Always full on, otherwise either horizontal only or vertical only

// VU panel specific padding
$puts(vu.l_pad,                 0) // VU - Left padding
$puts(vu.r_pad,                 $get(vu.l_pad)) // VU - Right padding
$puts(vu.t_pad,                 0) // VU - Top    padding
$puts(vu.b_pad,                 $get(vu.t_pad)) // VU - Bottom padding

// VU panel specific width and scaling settings
$puts(vu.w_min,                 $muldiv(  250,%scale%,100)) // VU minimum width - when less width available do not display VUmeter
$puts(vu.w_max,                 $muldiv(10000,%scale%,100)) // VU maximum width - set very high to use full available width
$puts(vu.w_scale,               $max(175, 100)) // VU maximum width  scale percentage related to original vu dimensions vu.x_fact en vu.y_fact. Minimum value 100
$puts(vu.h_scale,               $max(150, 100)) // VU maximum height scale percentage related to original vu dimensions vu.x_fact en vu.y_fact. Minimum value 100

// Calculate initial VU height and width using available width/height and above settings
$puts(vu.w,                     $sub($min($get(vu.w_max),$get(plug.w)),$get(vu.l_pad),$get(vu.r_pad)))
$puts(vu.h,                     $sub($get(plug.h),$get(vu.t_pad),$get(vu.b_pad)))
$puts(vu.h,                     $min($get(vu.h), $muldiv($muldiv($get(vu.w),$get(vu.y_fact),$get(vu.x_fact)), $get(vu.h_scale), 100)))
$puts(vu.w,                     $min($get(vu.w), $muldiv($muldiv($get(vu.h),$get(vu.x_fact),$get(vu.y_fact)), $get(vu.w_scale), 100)))

// Calculate final VU coordinates adjusted for padding and painted accent
$ifgreater($get(vu.w_min),$get(vu.w),
$puts(vu.w,                 0)
,
$puts(vu.y,                 $add($get(plug.y), $div($sub($get(plug.h),$get(vu.h)),2))) // Vcenter alignment
$puts(vu.x,                 $add($get(plug.x), $div($sub($get(plug.w),$get(vu.w)),2))) // Hcenter alignment

$ifgreater($get(dbg.vu),0, $puts(dbg2,STEP|2:|||vu.xywh=$get(vu.x).$get(vu.y).$get(vu.w).$get(vu.h)) ,)

// Paint accent and adjust VU coordinates accordingly
$ifgreater($get(vu.acc),0,
$ifgreater($get(vu.acc_limit),0,
$puts(vu.x_pad,     $sub($get(vu.x),$get(plug.x)))
$puts(vu.y_pad,     $sub($get(vu.y),$get(plug.y)))
$ifgreater($get(vu.acc_limit),$get(vu.x_pad),
$puts(vu.x_pad, 0)
,)
$ifgreater($get(vu.acc_limit),$get(vu.y_pad),
$puts(vu.y_pad, 0)
,)
,
$puts(vu.x_pad,     1)
$puts(vu.y_pad,     1)
)

$ifgreater($add($get(vu.x_pad),$get(vu.y_pad)),0,
// $drawrect($get(vu.x),  $get(vu.y),  $get(vu.w),  $get(vu.h),  %cola.at%,  %cola.at%)

$puts(i,0)
$ifgreater($get(vu.acc),$get(i), $drawrect($add($get(vu.x),$get(i)),  $add($get(vu.y),$get(i)),  $sub($get(vu.w),$mul($get(i),2)),  $sub($get(vu.h),$mul($get(i),2)),  0-0-0-0,  %cola.at%) $puts(i, $add($get(i),1)) ,)
$ifgreater($get(vu.acc),$get(i), $drawrect($add($get(vu.x),$get(i)),  $add($get(vu.y),$get(i)),  $sub($get(vu.w),$mul($get(i),2)),  $sub($get(vu.h),$mul($get(i),2)),  0-0-0-0,  %cola.at%) $puts(i, $add($get(i),1)) ,)

$ifgreater($get(vu.x_pad),0,
$puts(vu.x,     $add($get(vu.x), $get(vu.acc)))
$puts(vu.w,     $sub($get(vu.w), $mul($get(vu.acc),2)))
,)
$ifgreater($get(vu.y_pad),0,
$puts(vu.y,     $add($get(vu.y), $get(vu.acc)))
$puts(vu.h,     $sub($get(vu.h), $mul($get(vu.acc),2)))
,)
,)
,)
)

$ifgreater($get(dbg.vu),0, $puts(dbg3,STEP|3:|||vu.xywh=$get(vu.x).$get(vu.y).$get(vu.w).$get(vu.h)) ,)

// vu.x - final VU x-coordinate
// vu.y - final VU y-coordinate
// vu.w - final VU width - do not show/display VU panel when value is 0
// vu.h - final VU height

One thing I noticed is that your skin does not look as sharp as the original BIN, which is very noticeable with larger sized VU meters.
Do you use an internal smaller rendered image before rescaling and displaying to the allotted panel?
EDIT: Sorry, just noticed you already mentioned this.

Re: JScript Panel script discussion/help

Reply #1947
Spoiler (click to show/hide)
hi @sveakul,
thank you for your feedback. It is just an attempt for us to play around and tune it to suit our specific look & feel. e.g. we may construct ourself a fb2k theme/skin and let this help us in manipulating  a VU Meter.
It is in no way can compared with well-coded,  beautiful and rich-feature one of @oops' or the 32x version.

hi @Defender,
yeah, you are totally right.    

wish you both a nice day.
@ilovefb2k


Spoiler (click to show/hide)
[/spoiler]
Hi @Air KEN and @all,
As per some feedback and suggestions , please find the JSP3 "AIMP Analog VU Meter" update attached, version named "1.0.1 QM 05-11-24" for convenient reference.

This update addresses some points:
- High CPU load.
- Covering some very special cases, which were not easy to find a skin for, but they are there, finally. We also attached some for your quick loading:
   + The needle is upside down. Technically, the y_needle coordinates can be in (>=0) or outside (<0) the background area.
   + The needle is horizontal.
   We find it very interesting as, to some extent, we could not think of such skins existing early on. Wow, what creativity from us as an audio lovers community.
Spoiler (click to show/hide)
Hi @Defender , @sveakul, @Air KEN and @all,
A week has gone by too fast, like the wind. Please find the updated JSP3 'AIMP Analog VU Meter' script attached, named version '1.0.13 DT-K 08-Nov-24' for convenient reference, details as following:
Just one feature was added: unlock aspect ratio, as per @Defender's suggestion.

A free night weekend allowed me to play around with this feature, which I also think is a must-try if we want the script to move on to 'animation' VU Meters, which contain pre-calculated data/images per needle angle.
Please note that once this option is on, CPU load may be boosted up to Mars and won't come back, so fasten your computer's belt for a safe trip.

What happens behind the scenes:
The script will create around 200 x 2 channels = 400 needle images (we may tune this number per the hard-coded variable stepCache, for now), which are number of screenshots of needles per angle along the meter range, then load them into 'heap' memory. We will instantly note an increase in RAM consumption in less than 1 second, then it will return to normal.
Later on, we just retrieve each needle image by its index-converted angle as real-time calculated.


To do this, we have to do a trick, just jotting it down here for those who want to make it better:
-Step 1: Allocate memory for hundreds of images.
-Step 2: Draw needles, 1 needle per 1 image, per 1 angle. This takes about 1 ms each.
-Step 3: Garbage collection. As we allocate stack memory, we have to clear it ourselves or soon end up crashing. This will also take more than 1 ms each, which is time-consuming.

So, we have to make an async task, which will transfer the clearance job (step 3) to another thread, and we can move on. In principle, we can reuse some async methods of JSP3 to do this job in a very 'strange' manner. For example:
Code: [Select]
fb.AddLocationsAsync(window_id, [""]);
on_locations_added(task_id, handle_list) { do clearing job, which is not related to this native function}
Or, simply, leave this mess for
Code: [Select]
window.SetTimeout({do clearing job}, 1) 
=> We move on, and this method, on another thread, will do the clearing job after 1 ms and not bother us.

As such, we will experience a frozen-screen instance (not core audio engine) for a very short time. To save CPU power, just do this one time per current panel size until we move to another skin. Consequently, the resolution will not be nice if we enlarge the panel size, or we will have to switch forward and back just 1 skin to update the needle images caching for the current panel size.
If something seems wrong (e.g. needles are not on show), then a 'hard reset' via context menu [shift +right click] will bring back default setting and may help.
And that is all. Wish you all the very best and a very nice weekend.

Regards,
@ilovefb2k

quick edit ,
please ignore the script in the previous post.
use the attached herein instead.
update: addressing a special case where the needles are horizontal.
regards
@ilovefb2k

Re: JScript Panel script discussion/help

Reply #1948
quick edit ,
please ignore the script in the previous post.
use the attached herein instead.
update: addressing a special case where the needles are horizontal.
regards
This last script does not show a VU meter for me.

Re: JScript Panel script discussion/help

Reply #1949
Just one feature was added: unlock aspect ratio, as per @Defender's suggestion.
@ilovefb2k

Just a quick reaction. It works fine and is the way I am going to use it.

To clarify ... I don't want to stretch the VU meter (BIN or yours) more than either a maximum horizontal scaling or a maximum vertical scaling so I recalculate the VU meter coordinates using these maximum scaling factors. If that means there's either some horizontal or vertical space left I display a bezel around the VU meter, which I don't do with my transparent skin that I made for your script since it doesn't look better. For reference I attached the relevant code for calculating VU coordinates.
I now applied this code also to your script. As you can see your VU meter looks slightly larger than the original BIN. Reason for that is that I slightly cut the original bezel from the BIN before making the remaining bezel transparent.
Code: [Select]
	// plug.x - initial VU panel x-coordinate
// plug.y - initial VU panel y-coordinate
// plug.w - initial VU panel width
// plug.h - initial VU panel height

$ifgreater($get(dbg.vu),0, $puts(dbg1,STEP|1:|plug.xywh=$get(plug.x).$get(plug.y).$get(plug.w).$get(plug.h)) ,)

// VU panel standard settings
$puts(vu.x_fact,                400) // VU default proportion - X
$puts(vu.y_fact,                100) // VU default proportion - Y
$puts(vu.acc,                   $mul(%on.accent.vu%,%def.accent%)) // VU - Accent padding
$puts(vu.acc_limit,             $muldiv(0,%scale%,100)) // Limit to trigger  accent padding - 0= Always full on, otherwise either horizontal only or vertical only

// VU panel specific padding
$puts(vu.l_pad,                 0) // VU - Left padding
$puts(vu.r_pad,                 $get(vu.l_pad)) // VU - Right padding
$puts(vu.t_pad,                 0) // VU - Top    padding
$puts(vu.b_pad,                 $get(vu.t_pad)) // VU - Bottom padding

// VU panel specific width and scaling settings
$puts(vu.w_min,                 $muldiv(  250,%scale%,100)) // VU minimum width - when less width available do not display VUmeter
$puts(vu.w_max,                 $muldiv(10000,%scale%,100)) // VU maximum width - set very high to use full available width
$puts(vu.w_scale,               $max(175, 100)) // VU maximum width  scale percentage related to original vu dimensions vu.x_fact en vu.y_fact. Minimum value 100
$puts(vu.h_scale,               $max(150, 100)) // VU maximum height scale percentage related to original vu dimensions vu.x_fact en vu.y_fact. Minimum value 100

// Calculate initial VU height and width using available width/height and above settings
$puts(vu.w,                     $sub($min($get(vu.w_max),$get(plug.w)),$get(vu.l_pad),$get(vu.r_pad)))
$puts(vu.h,                     $sub($get(plug.h),$get(vu.t_pad),$get(vu.b_pad)))
$puts(vu.h,                     $min($get(vu.h), $muldiv($muldiv($get(vu.w),$get(vu.y_fact),$get(vu.x_fact)), $get(vu.h_scale), 100)))
$puts(vu.w,                     $min($get(vu.w), $muldiv($muldiv($get(vu.h),$get(vu.x_fact),$get(vu.y_fact)), $get(vu.w_scale), 100)))

// Calculate final VU coordinates adjusted for padding and painted accent
$ifgreater($get(vu.w_min),$get(vu.w),
$puts(vu.w,                 0)
,
$puts(vu.y,                 $add($get(plug.y), $div($sub($get(plug.h),$get(vu.h)),2))) // Vcenter alignment
$puts(vu.x,                 $add($get(plug.x), $div($sub($get(plug.w),$get(vu.w)),2))) // Hcenter alignment

$ifgreater($get(dbg.vu),0, $puts(dbg2,STEP|2:|||vu.xywh=$get(vu.x).$get(vu.y).$get(vu.w).$get(vu.h)) ,)

// Paint accent and adjust VU coordinates accordingly
$ifgreater($get(vu.acc),0,
$ifgreater($get(vu.acc_limit),0,
$puts(vu.x_pad,     $sub($get(vu.x),$get(plug.x)))
$puts(vu.y_pad,     $sub($get(vu.y),$get(plug.y)))
$ifgreater($get(vu.acc_limit),$get(vu.x_pad),
$puts(vu.x_pad, 0)
,)
$ifgreater($get(vu.acc_limit),$get(vu.y_pad),
$puts(vu.y_pad, 0)
,)
,
$puts(vu.x_pad,     1)
$puts(vu.y_pad,     1)
)

$ifgreater($add($get(vu.x_pad),$get(vu.y_pad)),0,
// $drawrect($get(vu.x),  $get(vu.y),  $get(vu.w),  $get(vu.h),  %cola.at%,  %cola.at%)

$puts(i,0)
$ifgreater($get(vu.acc),$get(i), $drawrect($add($get(vu.x),$get(i)),  $add($get(vu.y),$get(i)),  $sub($get(vu.w),$mul($get(i),2)),  $sub($get(vu.h),$mul($get(i),2)),  0-0-0-0,  %cola.at%) $puts(i, $add($get(i),1)) ,)
$ifgreater($get(vu.acc),$get(i), $drawrect($add($get(vu.x),$get(i)),  $add($get(vu.y),$get(i)),  $sub($get(vu.w),$mul($get(i),2)),  $sub($get(vu.h),$mul($get(i),2)),  0-0-0-0,  %cola.at%) $puts(i, $add($get(i),1)) ,)

$ifgreater($get(vu.x_pad),0,
$puts(vu.x,     $add($get(vu.x), $get(vu.acc)))
$puts(vu.w,     $sub($get(vu.w), $mul($get(vu.acc),2)))
,)
$ifgreater($get(vu.y_pad),0,
$puts(vu.y,     $add($get(vu.y), $get(vu.acc)))
$puts(vu.h,     $sub($get(vu.h), $mul($get(vu.acc),2)))
,)
,)
,)
)

$ifgreater($get(dbg.vu),0, $puts(dbg3,STEP|3:|||vu.xywh=$get(vu.x).$get(vu.y).$get(vu.w).$get(vu.h)) ,)

// vu.x - final VU x-coordinate
// vu.y - final VU y-coordinate
// vu.w - final VU width - do not show/display VU panel when value is 0
// vu.h - final VU height

One thing I noticed is that your skin does not look as sharp as the original BIN, which is very noticeable with larger sized VU meters.
Do you use an internal smaller rendered image before rescaling and displaying to the allotted panel?
EDIT: Sorry, just noticed you already mentioned this.
Hi @Defender,
very nice look& feel, you made a clever change to the script.
skin does not look as sharp as the original BIN: yeah, i noted that also. the script created skin images based on the current panel size and will not look nice if we , even, enlarge the panel size after that. well-noted this.
thank you very much.
regards
@ilovefb2k