Old 06-20-2022, 03:11 PM   #1801
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,691
Default

Hi Julian one question, when reaper is maximized:

Code:
retval, window_left, window_top, window_right, window_bottom = reaper.JS_Window_GetRect( reaper_hwnd )
why it reports some negative coordinates?


If I offset the window a bit to the right LEFT reports 0 but its like 5-10 pixels off the screen


Windows 10, QHD Monitor 2560x1440
Sexan is offline   Reply With Quote
Old 06-20-2022, 03:58 PM   #1802
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
Default

Quote:
Originally Posted by Sexan View Post
why it reports some negative coordinates?
https://devblogs.microsoft.com/oldne...04-00/?p=44543
Edgemeal is offline   Reply With Quote
Old 06-21-2022, 01:08 AM   #1803
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,691
Default

Oh ok, is something similar happening on OsX and Linux?
Sexan is offline   Reply With Quote
Old 06-23-2022, 08:25 AM   #1804
cohler
Banned
 
Join Date: Dec 2018
Posts: 642
Default Waveform display on a take with active volume envelope?

If you have a REAPER take with an active/armed volume envelope, is there some way to make REAPER display the waveform (peaks) as if the envelope was NOT active?

Also, if that is possible, is there a way to shade the waveform with a tint or overlay to give some visual reference that there is an active volume envelope on the take?
cohler is offline   Reply With Quote
Old 06-23-2022, 12:52 PM   #1805
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by cohler View Post
If you have a REAPER take with an active/armed volume envelope, is there some way to make REAPER display the waveform (peaks) as if the envelope was NOT active?
If you are referring to pre-FX Volume, there is a setting "Scale peaks by pre-fx volume/pan envelopes" that can be disabled.


Quote:
Originally Posted by cohler View Post
Also, if that is possible, is there a way to shade the waveform with a tint or overlay to give some visual reference that there is an active volume envelope on the take?
You can use the ReaScriptAPI extension to display overlays, but it might be easier to simply set the take color.
juliansader is offline   Reply With Quote
Old 06-23-2022, 01:13 PM   #1806
cohler
Banned
 
Join Date: Dec 2018
Posts: 642
Default

Quote:
Originally Posted by juliansader View Post
If you are referring to pre-FX Volume, there is a setting "Scale peaks by pre-fx volume/pan envelopes" that can be disabled.


You can use the ReaScriptAPI extension to display overlays, but it might be easier to simply set the take color.
No, I am referring to item take envelopes, not track envelopes. That setting has no effect on peak scaling caused by take envelopes.

For the shading, I want it to only be over one section of an item/take, so take color is useless for that.
cohler is offline   Reply With Quote
Old 06-24-2022, 05:01 PM   #1807
cohler
Banned
 
Join Date: Dec 2018
Posts: 642
Default

So how does one display overlays using JS_ReaScriptAPI?

And I presume then the answer is that there is no way to display takes with peaks (aka waveform display) unaffected by active take envelopes? If that is the case, this should definitely be added as a selectable feature.
cohler is offline   Reply With Quote
Old 06-29-2022, 12:49 PM   #1808
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by cohler View Post
So how does one display overlays using JS_ReaScriptAPI?
You can use the JS_Composite functions to overlay a LICE bitmap over a section of a target window. To see how it's done, I would suggest checking out amagalma's fantastic script "Toggle show editing guide line on item under mouse cursor". You can also browse this thread for more discussions about using the compositing functions.

If anything's unclear, please let us know!


Quote:
Originally Posted by cohler View Post
And I presume then the answer is that there is no way to display takes with peaks (aka waveform display) unaffected by active take envelopes? If that is the case, this should definitely be added as a selectable feature.
Good that you spotted this. I would regard it as a bug, and it should be reported. That setting should affect the take volume envelope too.
juliansader is offline   Reply With Quote
Old 06-29-2022, 05:13 PM   #1809
cohler
Banned
 
Join Date: Dec 2018
Posts: 642
Default

Quote:
Originally Posted by juliansader View Post
You can use the JS_Composite functions to overlay a LICE bitmap over a section of a target window. To see how it's done, I would suggest checking out amagalma's fantastic script "Toggle show editing guide line on item under mouse cursor". You can also browse this thread for more discussions about using the compositing functions.

If anything's unclear, please let us know!




Good that you spotted this. I would regard it as a bug, and it should be reported. That setting should affect the take volume envelope too.
Thank you for the pointers on JS_Composite, LICE bitmaps and amagalma's scripts!

I will go ahead and report the take volume envelope bug as well.
cohler is offline   Reply With Quote
Old 07-19-2022, 06:53 AM   #1810
Raskal
Human being with feelings
 
Join Date: Jul 2022
Posts: 7
Default Get imported media directory path

Hi everyone.

First of all thanks to this big community for sharing the knowledge and allow people to teach themselves. And a big thanks to @juliansader for the awesome work on JS api.

After many months of practicing lua and learning from this wonderful forum I finaly get to post for the first time.

My question:

Basically i'm working on a tool that i want to use to create quick variations of many layers. My script basically duplicate items and pick randomly in the folder where is the original take and pick a different wav file.

Right now when I start my script i use a function that pops a window where I specify manually the exact folder path where I want the script to pick randomly a variation of my take.

I'm trying to make this step automatic and for that I need to figure a way to get or to store the original source path on an imported audio file. So when I run my script it knows the origin directory path of the selected take. Of course I still want my media to be copied in my local reaper session when imported. I'm facing a blocker where i couldn't find a way to do that. I tried different things :

- I tried to use JS function in de media explorer to store in a text file the path of selected media in the list view. It works but only when you are selecting media that are not in a database. Because when you are in a database the combobox return only the database name. It does not work as well when you drag and drop file directly on a reaper track.

- I tried a python script , a watchdog script ( kind of FileSystemWatcher) that is localised in my media folder in my local reaper session. My goal was to store in a text file all the origin directory path of audio files imported in my reaper project. I was able to make it works, but only if my script is hierarchically parent of my reaper session folder and of my mediabay folder. It does not work when files are imported from a different or external drive.

If anyone have a suggestion on the right way to do what i'm trying to achieve it will be realy helpful.

Thanks in advance for any suggestions.

Peace !
Raskal is offline   Reply With Quote
Old 07-21-2022, 10:37 AM   #1811
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Perhaps you can use GetMediaItemTake_Source to get the source of the take, and then GetMediaSourceFileName to get the path?
juliansader is offline   Reply With Quote
Old 07-24-2022, 09:50 AM   #1812
Raskal
Human being with feelings
 
Join Date: Jul 2022
Posts: 7
Default

Hi Julian

Thanks for your answer. I did try that but unfortunately the moment you importe a file in reaper it copies the file automatically in the local reaper session folder. So when I run this commands it returns the path of the source in my local reaper session and not the origin path

Thank you for your help
Raskal is offline   Reply With Quote
Old 07-24-2022, 11:02 AM   #1813
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
Default

Quote:
Originally Posted by Raskal View Post
Because when you are in a database the combobox return only the database name.
One possible workaround for that might be to temporarily switch the view to show full/leading paths, do your stuff, then restore the settings.
Have a look at the function MediaExplorer_GetSelectedAudioFiles(), show_full_path, show_leading_path,..
https://forum.cockos.com/showpost.ph...2&postcount=12
Edgemeal is offline   Reply With Quote
Old 07-24-2022, 11:10 AM   #1814
Raskal
Human being with feelings
 
Join Date: Jul 2022
Posts: 7
Default

Thanks Edgemeal

I finally ended up doing exactly that

It works but I was wondering if you know how I could prevent the ui to refresh for the moment I do my work switching the full/leading path in the media explorer ?

I tried preventuirefresh function but it didn’t work :/

Many thanks in advance
Raskal is offline   Reply With Quote
Old 07-24-2022, 11:56 AM   #1815
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
Default

Hmmm, the ListView doesn't flicker at all here (Win10). In Windows (vb.net) I send the WM_SETREDRAW msg to RichTextBox and it works great, but never tried it on ListView (.net has built-in solution).

https://docs.microsoft.com/en-us/win...i/wm-setredraw

EDIT, My guess is REAPER devs enabled double buffering for the ListView (on Win OS) because resizing columns also doesn't flicker and by defualt the LV control will flicker really bad when doing that if not set.

Last edited by Edgemeal; 07-24-2022 at 12:02 PM. Reason: TYPO
Edgemeal is offline   Reply With Quote
Old 07-24-2022, 12:02 PM   #1816
Raskal
Human being with feelings
 
Join Date: Jul 2022
Posts: 7
Default

Thanks for your answer Edgemeal.

I’m gonna look at that. Gonna give it a try.

Thank you
Raskal is offline   Reply With Quote
Old 07-24-2022, 12:11 PM   #1817
Raskal
Human being with feelings
 
Join Date: Jul 2022
Posts: 7
Default

Just a last quick question.

Is there a way to call a c++ script from reascript Lua ?

Many thanks in advance
Raskal is offline   Reply With Quote
Old 07-24-2022, 12:15 PM   #1818
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
Default

Quote:
Originally Posted by Raskal View Post
Thanks for your answer Edgemeal.

I’m gonna look at that. Gonna give it a try.

Thank you
Good luck, and let us know if it works.

FWIW my .net code just to get an idea of how I used it on RichEditBox..

note: WM_SETREDRAW = 0xB

Code:
    Public Sub LockRedraw(ctl As Control) ' lock drawing
        SendMessage(ctl.Handle, WM_SETREDRAW, 0, 0)
    End Sub

    Public Sub UnLockRedraw(ctl As Control) ' unlock drawing and invalidate control
        SendMessage(ctl.Handle, WM_SETREDRAW, 1, 0)
        ctl.Invalidate()
    End Sub
Edgemeal is offline   Reply With Quote
Old 07-24-2022, 12:19 PM   #1819
Raskal
Human being with feelings
 
Join Date: Jul 2022
Posts: 7
Default

Thank you so much. I will let you know if I succeed
Raskal is offline   Reply With Quote
Old 07-27-2022, 12:33 PM   #1820
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,630
Default

Quote:
Originally Posted by Raskal View Post
Just a last quick question.

Is there a way to call a c++ script from reascript Lua ?

Many thanks in advance
You mean, C++-sourcecode to run it?
If yes, then, no, as they are completely different beasts and not compatible this way.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 08-07-2022, 12:36 AM   #1821
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,902
Default

Hi !


Is there a way to get all element of a listview rather than looping through each items ? with table withs tons of entry, the get list item function can become quite slow.


Thx !

EDIT: maybe JS_ListView_GetItemText is a bit faster ?
Well, not instant (4s) in my case (100 000) but should be acceptable.

Last edited by X-Raym; 08-07-2022 at 02:17 AM.
X-Raym is offline   Reply With Quote
Old 08-07-2022, 09:03 AM   #1822
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,902
Default Loop in ListView header

Hi,


I posted a question regarding ListView headers in a dedicated thread here:
https://forum.cockos.com/showthread....36#post2584236


Thx !
X-Raym is offline   Reply With Quote
Old 08-08-2022, 02:17 AM   #1823
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,902
Default

As explained by amagalma here, we miss a Header_GetItemText function. :S

This would be a nice addition for window parsing
X-Raym is offline   Reply With Quote
Old 08-08-2022, 01:32 PM   #1824
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Unfortunately, AFAIK, Header_GetItem has not yet been implemented in WDL/swell.
juliansader is offline   Reply With Quote
Old 08-08-2022, 03:24 PM   #1825
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,902
Default

@juliansader
Thx for expertise,


Not sure where I would need to ask for this ? Dont seems the github isssue tracks is very active.
X-Raym is offline   Reply With Quote
Old 08-18-2022, 06:18 AM   #1826
McSound
Human being with feelings
 
McSound's Avatar
 
Join Date: Jun 2021
Location: Moscow, Russia
Posts: 282
Default

Is there any chance that JS_VKeys_GetDown is slightly faster than JS_VKeys_GetState? I tried to catch Ctrl+Z shortcut in defer loop and 'State' sometimes misses my very quick presses of Ctrl+Z and 'Down' function seems to catch it every time.

Edit. Could someone explain me please, why fast pressed shortcut sometimes couldn’t be caught in defer loop while temperate press just works ok? Workaround?

Last edited by McSound; 08-18-2022 at 04:46 PM.
McSound is online now   Reply With Quote
Old 08-29-2022, 12:25 PM   #1827
jamesd256
Human being with feelings
 
jamesd256's Avatar
 
Join Date: Dec 2015
Location: Folkestone
Posts: 196
Default SDK methods available

Just getting going again coding in Reaper after quite a few years off, so please forgive my dumb questions while I speed up.

Does js_ReascriptAPI_extension expose a subset of stuff available in the extension SDK?

In particular I am interested in the Cockos VST extensions

https://www.reaper.fm/sdk/vst/vst_ext.php

The method is given by example for setting a named parameter (named_parameter_name) of a VST :

effVendorSpecific(effSetChunk,(VstIntPtr) named_parameter_name, buffer, 0.0)
Sets the string value for named_parameter_name, return 0xf00d if supported.

Trying to hack around with Relearn 2 which Benjamin reports can be controlled from outside via this approach, and receives a serialised state of the container to configure it.

If it's either much easier or the only way to go, I'm happy working with extensions/SDK approach, but would find scripting more fun
jamesd256 is offline   Reply With Quote
Old 08-30-2022, 01:47 PM   #1828
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by McSound View Post
Is there any chance that JS_VKeys_GetDown is slightly faster than JS_VKeys_GetState? I tried to catch Ctrl+Z shortcut in defer loop and 'State' sometimes misses my very quick presses of Ctrl+Z and 'Down' function seems to catch it every time.

Edit. Could someone explain me please, why fast pressed shortcut sometimes couldn’t be caught in defer loop while temperate press just works ok? Workaround?
Sorry for not replying sooner -- I didn't notice the edits.

GetDown and GetState use exactly the same underlying data, so they are equally fast.

Defer loops are executed about 30 times per second (and often slower), so if you press and release a shortcut key very quickly, you can do it in less time than one defer cycle.

GetState will miss keys that are clicked so quickly, because by the time the script queries the state, the state has reverted back to the original 0.
juliansader is offline   Reply With Quote
Old 08-31-2022, 02:57 AM   #1829
McSound
Human being with feelings
 
McSound's Avatar
 
Join Date: Jun 2021
Location: Moscow, Russia
Posts: 282
Default

Very helpful! Thanks juliansader!
McSound is online now   Reply With Quote
Old 09-07-2022, 03:49 PM   #1830
Malfunction
Human being with feelings
 
Malfunction's Avatar
 
Join Date: Sep 2020
Posts: 149
Default

reaper.JS_LICE_RotatedBlit(identifier destBitmap,integer dstx,integer dsty,integer dstw,integer dsth,identifier sourceBitmap,number srcx,number srcy,number srcw,number srch,number angle,number rotxcent,number rotycent,boolean cliptosourcerect,number alpha,string mode)

What does all dis crazy numbers mean?
Malfunction is offline   Reply With Quote
Old 09-08-2022, 03:28 AM   #1831
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Here is some documentation from the video processor function gfx_rotoblit, which may be similar:

integer srcidx
the source-image, that shall be blit as rotated image
float angle
the angle by width the image shall be rotated
optional integer x
the x-position in pixels, at which the blitting shall be put to
optional integer y
the y-position in pixels, at which the blitting shall be put to
optional integer w
the width in pixels of the rotated-blit-image; affects stretching of the image!
optional integer h
the height in pixels of the rotated-blit-image; affects stretching of the image!
optional integer srcx
the x-position in pixels in the source-image, from which to blit from
optional integer srcy
the y-position in pixels in the source-image, from which to blit from
optional integer w
the width in pixels of the source-image, from which to blit from; affects stretching of the image!
optional integer h
the height in pixels of the source-image, from which to blit from; affects stretching of the image!
optional integer cliptosrcrect=0
clips the source-image rectangle; 1, clip; 0, don't clip
optional integer centxoffs=0
adds an offset to the center of the image at x-position in pixels
optional integer centyoffs=0
adds an offset to the center of the image at x-position in pixels
juliansader is offline   Reply With Quote
Old 09-08-2022, 03:30 AM   #1832
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by jamesd256 View Post
Does js_ReascriptAPI_extension expose a subset of stuff available in the extension SDK?

In particular I am interested in the Cockos VST extensions
It exposes the extension SDK, but unfortunately not the VST stuff.
juliansader is offline   Reply With Quote
Old 09-12-2022, 02:02 AM   #1833
jamesd256
Human being with feelings
 
jamesd256's Avatar
 
Join Date: Dec 2015
Location: Folkestone
Posts: 196
Default JS_LICE_DrawChar

Trying out JS_LICE_DrawChar, but it seems impossible with Lua:

Code:
reaper.JS_LICE_DrawChar(dest_bmp, 200,200, 40,0x000000, 1, '')

'reaper.JS_LICE_DrawChar' argument 4: unknown type char
The docs say argument 4 is an integer
jamesd256 is offline   Reply With Quote
Old 09-13-2022, 03:42 AM   #1834
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Thanks for the bug report! I will fix this for the next update. Try using DrawText in the meantime.
juliansader is offline   Reply With Quote
Old 09-25-2022, 07:55 AM   #1835
fripholm
Human being with feelings
 
Join Date: Jan 2011
Posts: 69
Default JS_LICE_FillPolygon packedX and packedY?

JS_LICE_FillPolygon

For a script I'm writing, I'm trying to wrap my head around above mentioned function. The description says 'packedX and packedY are two strings of coordinates, each packed as "<i4"'.

Googling for "packed as <i4" leaves me with reviews for german cars.

What does that mean? Can anyone point me in the right direction?
fripholm is offline   Reply With Quote
Old 09-25-2022, 02:08 PM   #1836
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

"<i4" refers to format strings for string.pack in Lua. Each coordinate is packed as a little-endian signed integer of 4 bytes.
juliansader is offline   Reply With Quote
Old 09-25-2022, 08:30 PM   #1837
fripholm
Human being with feelings
 
Join Date: Jan 2011
Posts: 69
Default

Quote:
Originally Posted by juliansader View Post
"<i4" refers to format strings for string.pack in Lua. Each coordinate is packed as a little-endian signed integer of 4 bytes.
Thanks, I've found this in the meantime as well.

According to those docs, one would assume that the following should work but it doesn't. In this case it seems that only the first value is packed into the string.

Code:
-- does not work

packedX = string.pack("<i4", x1, x2, x3, ...)
packedY = string.pack("<i4", y1, y2, y3, ...)
But after some fiddling I found this to be working:

Code:
packedX = string.pack("<i4", x1) .. string.pack("<i4", x2) .. string.pack("<i4", x3) .. [...])
packedY = string.pack("<i4", y1) .. string.pack("<i4", y2) .. string.pack("<i4", y3) .. [...])
Is there a more elegant way?
fripholm is offline   Reply With Quote
Old 09-26-2022, 02:11 AM   #1838
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

You can concatenate the format codes into a single string, with one code for each argument:
Code:
string.pack("<i4i4i4", x1, x2, x3)
(The endian option only needs to be given once at the beginning.)
juliansader is offline   Reply With Quote
Old 09-26-2022, 07:08 AM   #1839
fripholm
Human being with feelings
 
Join Date: Jan 2011
Posts: 69
Default

Quote:
Originally Posted by juliansader View Post
You can concatenate the format codes into a single string, with one code for each argument:
Code:
string.pack("<i4i4i4", x1, x2, x3)
(The endian option only needs to be given once at the beginning.)
Nice, much better. Thanks!
fripholm is offline   Reply With Quote
Old 10-09-2022, 08:29 PM   #1840
dangguidan
Human being with feelings
 
Join Date: Jan 2019
Location: China
Posts: 662
Default

reaper.JS_VKeys_GetState

Can I mask the detection key when entering the track name?
dangguidan 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 04:43 PM.


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