Old 05-24-2019, 09:23 AM   #481
DaveKeehl
Human being with feelings
 
DaveKeehl's Avatar
 
Join Date: Nov 2015
Location: Switzerland
Posts: 1,763
Default

Hi, I just started coding some scripts in lua for reaper and I don't understand what HWND means (for example in reaper.GetMainHwnd). Can someone explain it to me?
DaveKeehl is offline   Reply With Quote
Old 05-24-2019, 09:26 AM   #482
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,202
Default

Quote:
Originally Posted by DaveKeehl View Post
Hi, I just started coding some scripts in lua for reaper and I don't understand what HWND means (for example in reaper.GetMainHwnd). Can someone explain it to me?
It's an object, that reflects a window or a gui-element in a window.

For instance GetMainHwnd returns the object of Reaper's main window(the one with the arrangeview in it) and you can manipulate it using appropriate functions.
If you use the most recent version of SWS and/or the js-extension, there are functions, who allow you to do that, like getting/changing position, title, scrollstate of the window, etc.

When I say, gui-element: not all Gui-elements in Reaper have a hwnd, only the ones that are system-dialogs/elements. For instance, all elements in the Render to File-dialog have hwnds, the solo button of a track has not(afaik)


Edit: try experimenting with JS_Window_SetTitle to get an idea.
https://mespotin.uber.space/Ultrasch...indow_SetTitle

Needs the js-extension-plugin, which you can get here: https://forum.cockos.com/showthread.php?t=212174
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 05-29-2019, 06:50 AM   #483
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 8,783
Default

Adding to mespotine,
https://docs.microsoft.com/en-us/cpp...d?view=vs-2019

So, a handle (specific type of pointer)* to a window.

*Though handle and pointer are not fully equivalent:
https://stackoverflow.com/questions/...things/1923646
nofish is offline   Reply With Quote
Old 05-31-2019, 07:30 AM   #484
sw_
Human being with feelings
 
Join Date: Oct 2018
Posts: 22
Default

How do I convert the volume and pan from GetTrackUIVolPan to a 0-127 CC value? In other words I'd like to convert the pan (-1 to 1) range to 0-127 and the tracks max and min volume to 0-127.

I get the internal values in the console, it's just that I have to reformat them before passing the values along with StuffMIDIMessage since that wound pass negative values. Please help ! I need this for my diy motorized fader to work.
sw_ is offline   Reply With Quote
Old 05-31-2019, 02:26 PM   #485
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 2,668
Default

Code:
round((floatValue + 1.0) * (127.0 / 2.0))

Last edited by cfillion; 05-31-2019 at 02:37 PM.
cfillion is offline   Reply With Quote
Old 06-01-2019, 08:32 AM   #486
sw_
Human being with feelings
 
Join Date: Oct 2018
Posts: 22
Default

Quote:
Originally Posted by cfillion View Post
Code:
round((floatValue + 1.0) * (127.0 / 2.0))
Amazing!! Thanks!! Do you by any chance know this?

How do I send a 14 bit midi message over midi? I only seem to be able to send up to 255 with stufffmidimessage.
sw_ is offline   Reply With Quote
Old 06-01-2019, 10:46 AM   #487
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Location: Croatia
Posts: 2,079
Default

TrackFX_GetInstrument() returns -1 if instrument is offline? Any simple way around this?
__________________
My contributions
Breeder is offline   Reply With Quote
Old 06-16-2019, 11:19 PM   #488
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 23
Default Help explaining code

Hi. Im having trouble understanding this bit of code. Its from Losers Waveshaping Distortion.

Mostly the second line "hdistr =....". How does the "100,.999" bit work? I get that It gives a value for "foo" to be calculated and then used in the formula. How would I enter these values in a regular calculator? Slider range is 0-100.

/thx

@slider
hdistr = min(slider1/100,.999);
foo = 2*hdistr/(1-hdistr);

@sample
spl0 = min(max(spl0,-1),1);
spl1 = min(max(spl1,-1),1);

spl0 = (1+foo)*spl0/(1+foo*abs(spl0));
spl1 = (1+foo)*spl1/(1+foo*abs(spl1));
danerius is offline   Reply With Quote
Old Yesterday, 12:16 AM   #489
Fabian
Human being with feelings
 
Fabian's Avatar
 
Join Date: Sep 2008
Location: Sweden
Posts: 5,296
Default

Quote:
Originally Posted by danerius View Post
Hi. Im having trouble understanding this bit of code. Its from Losers Waveshaping Distortion.

Mostly the second line "hdistr =....". How does the "100,.999" bit work? I get that It gives a value for "foo" to be calculated and then used in the formula. How would I enter these values in a regular calculator? Slider range is 0-100.

/thx

@slider
hdistr = min(slider1/100,.999);
foo = 2*hdistr/(1-hdistr);

@sample
spl0 = min(max(spl0,-1),1);
spl1 = min(max(spl1,-1),1);

spl0 = (1+foo)*spl0/(1+foo*abs(spl0));
spl1 = (1+foo)*spl1/(1+foo*abs(spl1));
I am not sure exactly what you are asking. Do you mean
Code:
min(slider1/100,.999)
It divides the value of slider1 by 100, then takes the minimum of that value and 0.999. Is this what you mean?

Or do you mean to ask why the value of foo is calculated the way it is? Of that, I have no idea, sorry.
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
Fabian is offline   Reply With Quote
Old Yesterday, 02:45 AM   #490
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 23
Default

Quote:
Originally Posted by Fabian View Post
I am not sure exactly what you are asking. Do you mean
Code:
min(slider1/100,.999)
It divides the value of slider1 by 100, then takes the minimum of that value and 0.999. Is this what you mean?

Or do you mean to ask why the value of foo is calculated the way it is? Of that, I have no idea, sorry.
Hi + massor med tack Both actually. But theyre kind of separate questions

I understand the 'slider1 divided by 100'. But is it adding .0999 to the result? Multiplying?

/thx
danerius is offline   Reply With Quote
Old Yesterday, 03:28 AM   #491
Fabian
Human being with feelings
 
Fabian's Avatar
 
Join Date: Sep 2008
Location: Sweden
Posts: 5,296
Default

Quote:
Originally Posted by danerius View Post
Hi + massor med tack Both actually. But theyre kind of separate questions

I understand the 'slider1 divided by 100'. But is it adding .0999 to the result? Multiplying?

/thx
Code:
min(x, y)
returns the smallest value of x and y.

So in the particular case of
Code:
min(slider1/100, 0.999)
when slider1 is 100, 0.999 will be returned, not 1. This is to not get a divide by zero on the next line
Code:
foo = 2*hdistr/(1-hdistr);
as hdistr is guaranteed to never be exactly 1.
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
Fabian is offline   Reply With Quote
Old Yesterday, 05:01 AM   #492
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 23
Default

Quote:
Originally Posted by Fabian View Post
Code:
min(x, y)
returns the smallest value of x and y.

So in the particular case of
Code:
min(slider1/100, 0.999)
when slider1 is 100, 0.999 will be returned, not 1. This is to not get a divide by zero on the next line
Code:
foo = 2*hdistr/(1-hdistr);
as hdistr is guaranteed to never be exactly 1.
Oh... Excellent. Got it now

Im guessing its best practice to include a minimum value?

/thx
danerius is offline   Reply With Quote
Old Yesterday, 05:52 AM   #493
Fabian
Human being with feelings
 
Fabian's Avatar
 
Join Date: Sep 2008
Location: Sweden
Posts: 5,296
Default

Quote:
Originally Posted by danerius View Post
Oh... Excellent. Got it now

Im guessing its best practice to include a minimum value?

/thx
Well... Not necessarily, it depends on what you want to do.

In this case it is definitely good. Divide by zero is something you absolutely want to avoid.
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
Fabian is offline   Reply With Quote
Old Yesterday, 06:32 AM   #494
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 23
Default

Quote:
Originally Posted by Fabian View Post
Well... Not necessarily, it depends on what you want to do.

In this case it is definitely good. Divide by zero is something you absolutely want to avoid.
Awesome. Thanks again
danerius is offline   Reply With Quote
Old Yesterday, 09:35 AM   #495
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,202
Default

Are extension-functions able to find out, in which script they run? Like get_action_context for C++ in ReaScripts or something?

And if yes, can they run automatically at script-startup, before the script is run actually?
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 05:41 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.