Old 05-23-2020, 10:43 AM   #1241
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 5,903
Default

something similar happens with the Xen_StartSourcePreview function

I use to play an audio file. And then you cannot delete that audio file until you close REAPER.

Another question: Is there a way to know what percentage of the audio has been played? Or at least when it has finished playing?

Maybe if there is a function to know when it has finished playing, it could also close the file for read.
heda is offline   Reply With Quote
Old 05-23-2020, 11:36 AM   #1242
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: Apr 2020
Location: Leipzig
Posts: 608
Default

Quote:
Originally Posted by heda View Post
Another question: Is there a way to know what percentage of the audio has been played? Or at least when it has finished playing?
Unfortunately no. You would need to retrieve the length of the file somehow and calculate it on your own.
But if I remember correctly, the preview-functions need the PCM_Source and this probably would need to be destroyed later. But I might be wrong.
__________________
Use you/she/her, when contacting me, please. Thanks :) Not mentoring via PMs, sorry.
Ultraschall-API - 1200 ReaScript functions for Reaper - Reaper Internals - Developerdocs4Reaper - Donate, if you wish
Meo-Ada Mespotine is offline   Reply With Quote
Old 05-24-2020, 11:25 AM   #1243
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 3,749
Default

@Julian, is there a way to "un-destroy" or re-create:

Code:
reaper.JS_LICE_Clear()
What I basically want to do is: when a key is pressed, show an object, when the key is released, hide it.
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you wish to donate for my scripts: please consider an organization like: animal shelter, doctors without borders, UNICEF, etc...

Last edited by _Stevie_; 05-24-2020 at 12:02 PM.
_Stevie_ is offline   Reply With Quote
Old 05-24-2020, 03:55 PM   #1244
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,198
Default

Could you elaborate a little on what you are trying to do?
juliansader is offline   Reply With Quote
Old 05-24-2020, 04:03 PM   #1245
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 3,749
Default

I think I have found a solution. I basically want to draw a vertical line, when I press a modifier like CTRL and then delete the line, when the modifier is released.

I'm deleting the line with:

Code:
reaper.JS_LICE_DestroyBitmap(line)
line = nil
and on CTRL press I do:

Code:
if cur_mouse_state&4 == 4 then
    if line == nil then
	line = reaper.JS_LICE_CreateBitmap(true, 1, 1)
	reaper.JS_LICE_Clear(line, 0x66FFFFFF)
    end
end
Or should I just use this instead?

Code:
reaper.JS_Composite(arrange_view, 0, 0, 0, 0, line, 0, 0, 1, 1, true)
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you wish to donate for my scripts: please consider an organization like: animal shelter, doctors without borders, UNICEF, etc...
_Stevie_ is offline   Reply With Quote
Old 05-25-2020, 08:25 AM   #1246
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 2,172
Default

Quote:
Originally Posted by juliansader View Post
The opacity problem (which caused the huge opaque blocks in my MIDI scripts) and the stretching problem (which caused your guidelines and Sexan's areas to disappear, since they both make use of single-pixel bitmaps that are stretched into lines or rextangles) are both fixed.

Stevie did report lots of flickering, unfortunately. I'm not sure what the cause of the flickering is, whether other users will report the same problem, or whether any further improvements in Metal are in the works.

It seems that the drawing is fixed but it can't do transparency. Here is a gif made by user Ideosound testing my "Distinguish visually the ripple editing modes" script. The rectangles should appear transparent
amagalma is offline   Reply With Quote
Old 05-25-2020, 08:34 AM   #1247
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,198
Default

The Metal upgrades is currently only in the dev versions, but will likely be released in v6.12.
juliansader is offline   Reply With Quote
Old 05-25-2020, 08:36 AM   #1248
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 3,643
Default

Hey Julian,

Hope you are well!

Just having a minor issue with JS_LICE_FillCircle.

I'm using COPYALPHA mode to add alpha pixels to an existing bitmap - but it doesn't seem to work the same as FillRect. In fact - I cannot get the alpha byte to do anything.

I've tested with the latest version (and the previous version I was using) - and behavior is the same - FillCircle seems to ignore the alpha byte.

It's entirely possible I'm just doing it wrong - but I'm passing in exactly the same color value into each Fill API call - and other than dimensions - they have the same parameters set.

I took a quick look at the code - and the only thing I noticed that was different between the two functions - is that FillRect is casting the color value to a LICE_pixel when calling the LICE_FillRect function - whereas the FillCircle is not casting the value at all. I've no idea if this may be why the two don't seem to work the same. Some of the other Fill functions also do not cast the color parameter - but I've not tested these.

Any ideas? Thanks
__________________
Projects - Reascripts - Lua:
LBX Stripper | LBX Chaos Engine | LBX Floating FX Positioner | LBX SRD Smart Knobs
Donate via Paypal
lb0 is offline   Reply With Quote
Old 05-25-2020, 08:37 AM   #1249
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,198
Default

Quote:
Originally Posted by _Stevie_ View Post
I think I have found a solution. I basically want to draw a vertical line, when I press a modifier like CTRL and then delete the line, when the modifier is released.

I'm deleting the line with:

...

and on CTRL press I do:

...

Or should I just use this instead?

Code:
reaper.JS_Composite(arrange_view, 0, 0, 0, 0, line, 0, 0, 1, 1, true)
Destroying, re-Creating and re-Compositing do a lot more work than simply hiding the line, so if you are frequently toggling the line on and off, hiding (as in your last snippet) is preferable.
juliansader is offline   Reply With Quote
Old 05-25-2020, 08:45 AM   #1250
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 2,172
Default

Quote:
Originally Posted by juliansader View Post
The Metal upgrades is currently only in the dev versions, but will likely be released in v6.12.

He was testing with a dev build
amagalma is offline   Reply With Quote
Old 05-25-2020, 09:08 AM   #1251
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 3,749
Default

Quote:
Originally Posted by juliansader View Post
Destroying, re-Creating and re-Compositing do a lot more work than simply hiding the line, so if you are frequently toggling the line on and off, hiding (as in your last snippet) is preferable.
That's very good info, thanks Julian!

And btw, did some more tests under macOS (with metal enabled) and there are really no more issues.
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you wish to donate for my scripts: please consider an organization like: animal shelter, doctors without borders, UNICEF, etc...
_Stevie_ is offline   Reply With Quote
Old 05-25-2020, 09:43 AM   #1252
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 3,643
Default

Quote:
Originally Posted by lb0 View Post
Hey Julian,

Hope you are well!

Just having a minor issue with JS_LICE_FillCircle.

I'm using COPYALPHA mode to add alpha pixels to an existing bitmap - but it doesn't seem to work the same as FillRect. In fact - I cannot get the alpha byte to do anything.

I've tested with the latest version (and the previous version I was using) - and behavior is the same - FillCircle seems to ignore the alpha byte.

It's entirely possible I'm just doing it wrong - but I'm passing in exactly the same color value into each Fill API call - and other than dimensions - they have the same parameters set.

I took a quick look at the code - and the only thing I noticed that was different between the two functions - is that FillRect is casting the color value to a LICE_pixel when calling the LICE_FillRect function - whereas the FillCircle is not casting the value at all. I've no idea if this may be why the two don't seem to work the same. Some of the other Fill functions also do not cast the color parameter - but I've not tested these.

Any ideas? Thanks
Ah - I may just be doing something stupid... Ignore this for now. Sorry!
__________________
Projects - Reascripts - Lua:
LBX Stripper | LBX Chaos Engine | LBX Floating FX Positioner | LBX SRD Smart Knobs
Donate via Paypal
lb0 is offline   Reply With Quote
Old 05-25-2020, 10:19 AM   #1253
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,198
Default

Quote:
Originally Posted by amagalma View Post
He was testing with a dev build
He mentioned that he is using the latest "release build", so I'm not sure that he was using a dev build.

In previous versions of ReaScriptAPI, the WDL/swell function StretchBlt was used to blit onto the window, but since stretching doesn't work with Metal, nothing appeared onscreen. In the most recent version of ReaScriptAPI, no stretching is applied if Metal is enabled *and* the bitmap is partly offscreen (as is the case in his example), so the bitmap will appear onscreen -- but the transparency bug means that the bitmaps will be fully opaque.
juliansader is offline   Reply With Quote
Old 05-25-2020, 10:20 AM   #1254
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,198
Default

Quote:
Originally Posted by _Stevie_ View Post
And btw, did some more tests under macOS (with metal enabled) and there are really no more issues.
Yay! I will mention this to Justin.
juliansader is offline   Reply With Quote
Old 05-25-2020, 12:24 PM   #1255
Levitanus
Human being with feelings
 
Join Date: Nov 2015
Location: Novosibirsk, Russia
Posts: 27
Default

Julian, thanks for awesome new SetParent! I have question about window styling: is it possible to make somehow the child window be out of the parent (gfx) border? I assume Reaper does this, but when I try to set different styles to child or parent gfx (to be sure it is not "WS_CLIPSIBLINGS"), I got positive return value of SetStyle, but nothing changed visually...


The second question general about unicode. What are relations of extension within it? I found several problems loading PNG from\within Python. And still, only way I found to make it almost stable — send filename as ascii, which can lead to problems on many Windows reaper installations (if store script inside Reaper resource folder in APPDATA).
Also, I've not tested yet LICE_DrawText etc, but I'm afraid of their relations with unicode...

For example, now I load PNG this way:
Code:
def _load(self, filename: str, encoding: str) -> JS.VoidPtr:
    fallback = 'ascii'

    for i in range(10):
        if i >= 5:
            encoding = fallback
        ptr = JS.LICE_LoadPNG(filename, encoding)
        if int(ptr) != 0:
            return ptr
    raise ResourceLoadError(
        "can't load PNG from file {} with encoding {}".format(
            filename, encoding
        )
    )

Last edited by Levitanus; 05-25-2020 at 12:43 PM.
Levitanus is offline   Reply With Quote
Old 05-25-2020, 12:43 PM   #1256
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 3,643
Default

Hi again Julian,

I've done some more testing and there is something not quite right between the FillRect and FillCircle function calls.



In the image - the rectangle and circle are called with the same 'color' and 'alpha' parameters.

I am setting color for each to 0x7F (so essentially half transparent.

the alpha parameter is 1 for both (draw with full opacity - but it should be using the alpha part of the color parameter).

Both are using COPYALPHA mode.

As you can see - the rectangle is drawn correctly - with transparency. But the circle is not.

Is there any benefit to utilizing the alpha part of the color parameter as opposed to the actual alpha parameter itself?

Should I just use the alpha parameter instead? What I'm trying to do is cut transparent holes in an existing bitmap - which I cannot do using a colour mask as the bitmap could be anything and I only want transparent holes in specific places.

I've tried both ways - using just the alpha parameter, and also the alpha part of the color parameter. The problem I have is that I can create partially transparent holes using the alpha parameter - but not fully transparent as the higher I set the alpha the less transparent it becomes - but using 0 - it doesn't do anything (completely transparent). Thus I tried the COPYALPHA method - then noticed that doesn't seem to work consistently. But I'm not sure I'll get any different results anyway using this...

Of course - I could just create my own (slow) pixel by pixel drawing routines to cut the holes - but was after something a bit quicker!

I'll continue to play with it - see if I can find a solution - but wondered if you know any better than me what to try...

Any ideas? Cheers!

EDIT:

Interestingly - I got FillCircle to punch a fully transparent hole by setting the color alpha byte to 0, and alpha parameter to 1 (using COPYALPHA mode)

This doesn't work with FillRect. But I guess there are other functions for processing rectangles - so maybe I'll try some of those.

EDIT2:

Solved my problem using 2 instances of FillTriangle to draw the transparent rectangles
__________________
Projects - Reascripts - Lua:
LBX Stripper | LBX Chaos Engine | LBX Floating FX Positioner | LBX SRD Smart Knobs
Donate via Paypal

Last edited by lb0; 05-25-2020 at 01:04 PM.
lb0 is offline   Reply With Quote
Old 05-25-2020, 01:04 PM   #1257
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 2,172
Default

Quote:
Originally Posted by juliansader View Post
He mentioned that he is using the latest "release build", so I'm not sure that he was using a dev build.

In previous versions of ReaScriptAPI, the WDL/swell function StretchBlt was used to blit onto the window, but since stretching doesn't work with Metal, nothing appeared onscreen. In the most recent version of ReaScriptAPI, no stretching is applied if Metal is enabled *and* the bitmap is partly offscreen (as is the case in his example), so the bitmap will appear onscreen -- but the transparency bug means that the bitmaps will be fully opaque.
Oh yes, you are right! Sorry!

Another question regarding transparency/alpha between Windows and macOS. When using JS_LICE_Clear with a color and then JS_Composite to draw over the trackview, in order to get the same visual color and transparency, different values must be entered for Windows and macOS.

Code:
red, green, blue, alpha = 255, 255, 127, 35
wa = alpha/255 -- Windows alpha
OSXcolor_trackview = ((blue&0xFF)|((green&0xFF)<<8)|((red&0xFF)<<16)|((alpha&0xFF)<<24))
WINcolor_trackview = (((math.floor(blue*wa))&0xFF)|(((math.floor(green*wa))&0xFF)<<8)|(((math.floor(red*wa))&0xFF)<<16)|(0x01<<24))
OSXcolor_trackview = string.format("0x%08X", OSXcolor_trackview)
WINcolor_trackview = string.format("0x%08X", WINcolor_trackview)
Code:
macOS color: 0x23FFFF7F
Windows color: 0x01232311
Is this expected or is it a bug?
amagalma is offline   Reply With Quote
Old 05-25-2020, 01:26 PM   #1258
Levitanus
Human being with feelings
 
Join Date: Nov 2015
Location: Novosibirsk, Russia
Posts: 27
Default

Quote:
Originally Posted by Levitanus View Post
The second question general about unicode.
Sorry, not relevant: I found, that I've calculated size of the string buffer by unencoded string representation...
Levitanus is offline   Reply With Quote
Old 05-25-2020, 02:20 PM   #1259
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,198
Default

Quote:
Originally Posted by amagalma View Post
Is this expected or is it a bug?
This is expected. As mentioned in the help docs, the WDL/swell functions for blitting to window HDCs perform alpha multiplication on the fly, whereas the Windows function doesn't. The script therefore unfortunately has to do alpha pre-multiplication itself. I considered adding automatic alpha multiplication to JS_Composite on WindowsOS, but that would require two-step blitting for every bitmap in each paint cycle, which would exacerbate flickering on WindowsOS.
juliansader is offline   Reply With Quote
Old 05-26-2020, 06:48 AM   #1260
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 2,172
Default

Thanks Julian! Is there any link to these docs?
amagalma is offline   Reply With Quote
Old 05-26-2020, 08:18 AM   #1261
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,198
Default

Quote:
Originally Posted by amagalma View Post
Thanks Julian! Is there any link to these docs?
I'm just referring to the standard API help documentation that you are very familiar with: In the IDE, click "API Help", or run the action "Open ReaScript documentation".

BTW, a few pages back we mentioned the possibility of communicating reaper.arrays among scripts using gmem. Unfortunately, it didn't work as well I expected: API help docs: double* parameter and reaper.array.
juliansader is offline   Reply With Quote
Old 05-26-2020, 08:40 AM   #1262
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 2,172
Default

Thanks! Hmm, I didn't pay attention it seems..

...
No, unfortunately you can't .. I quote my findings from that post:
Quote:
Originally Posted by amagalma View Post
EDIT. I did various tests and it seems that only reaper objects can be shared. What we get in ReaScript are pointers to these objects, so any script that has the pointers to these objects in memory can access them. But it is not the same with lua tables and even reaper.arrays. Getting the handle of these may retrieve the pointer to these objects, which can be shared between different scripts, but it seems that one lua script cannot access the lua objects of the other, even if it has the pointers, because these objects are private to the script.
Reaper objects are private to Reaper.. So any reaper script can access them and sharing them between scripts is waaaaaay faster than using ProjExtStates or ExtStates.
amagalma is offline   Reply With Quote
Old 05-26-2020, 04:53 PM   #1263
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,198
Default

Even though the double* parameter cannot be used to pass a reaper.array to an extension, it can be done using a void* type, as done in the function JS_Window_ArrayAllTop.

I do not know how to return an array from an extension to a script that didn't create the array, though. Returning a double* creates a userdata object, but REAPER doesn't interpret it as a reaper.array.

However, scripts can easily access other script's reaper.arrays, even without a reaper.array object, since a reaper.array is simply an array of doubles (except the first 64bits, which give the size and used size as 32bit integers). For example, if you convert the reaper.array userdata to a number address (using tonumber or JS_Window_AddressFromHandle) and pass this address to another script, the second script can read the array double-by-double using JS_Double, or read the entire array with JS_String and unpack the doubles with string.unpack. (I'm not sure if it will be faster than ExtStates, though.)
juliansader is offline   Reply With Quote
Old 05-26-2020, 05:48 PM   #1264
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 290
Default

Quote:
Originally Posted by amagalma View Post
I confirm. Should this happen? It's like we have used file = io.open() in lua and then forgot to file:close()
@juliansader

Is this expected?
dsyrock is offline   Reply With Quote
Old 05-26-2020, 06:03 PM   #1265
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,198
Default

Quote:
Originally Posted by dsyrock View Post
@juliansader

Is this expected?
It is not expected. The function should only return the file name, without affecting the file in any way.

I noticed a similar phenomenon once, but I haven't been able to replicate it again, so I'm not actually sure that my original observation was actually due to JS_Dialog_BrowseForOpenFiles.

* In your case, is it only the file(s) returned by JS_Dialog_BrowseForOpenFiles that are affected, or also other files?

* When you cannot change the name of the locked file, what happens when you click on Windows Explorer's menu -> View -> Refresh? Does the refreshed file show the new name?
juliansader is offline   Reply With Quote
Old 05-26-2020, 08:29 PM   #1266
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: Apr 2020
Location: Leipzig
Posts: 608
Default

I lost track somehow, which is the latest release-version of JS-extension? Would like to include the latest functions into my ReaperDocs.
__________________
Use you/she/her, when contacting me, please. Thanks :) Not mentoring via PMs, sorry.
Ultraschall-API - 1200 ReaScript functions for Reaper - Reaper Internals - Developerdocs4Reaper - Donate, if you wish
Meo-Ada Mespotine is offline   Reply With Quote
Old 05-27-2020, 08:32 AM   #1267
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,198
Default

Quote:
Originally Posted by lb0 View Post
Hi again Julian,

I've done some more testing and there is something not quite right between the FillRect and FillCircle function calls.
Thanks for the report! This is definitely a bug, and I will try to see if it can be fixed.
juliansader is offline   Reply With Quote
Old 05-27-2020, 06:13 PM   #1268
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 3,643
Default

Quote:
Originally Posted by juliansader View Post
Thanks for the report! This is definitely a bug, and I will try to see if it can be fixed.
Awesome - thank you Julian.

No hurry from me though - I found a solution in the end to use GradRect instead as this allowed me to use the 0xAA value from the color parameter - and just not apply any gradient.

But yeah - it seems that FillRect ignores (at least) the 0xAA part of the color param when adding ALPHA to the blend mode (or something like that - I did so many tests on the different available LICE calls I can't remember the exact details now - but if you would like me to confirm my thoughts - I'll test again).

Basically - FillRect didn't seem to work the same as FillCircle/FillTriangle/GradRect etc, and I was unable to use it in the same way as the other functions (where the other functions did exactly what I wanted).

And thanks for all your continued work on this - the extension (as I've probably said before) is simply indispensable to me now.


EDIT:

Hmmm. Seems gradrect also doesn't quite work how I wanted - it seems to mimic FillRect. Not sure why I thought it was working - back to using 2x Triangles - but this isn't perfect as if you use a non 100% transparency - some pixels where the two trangles cross over on the diagonal end up more transparent than the rest of the rectangle area. It's not a big problem really - just thought I'd mention that the rectangle functions so far seem to work a little different than the circle function. (Unless I'm doing something wrong - which is entirely possible - but I've tested fairly thoroughly - gone through confusion and out the other side thinking it's still not as expected)
__________________
Projects - Reascripts - Lua:
LBX Stripper | LBX Chaos Engine | LBX Floating FX Positioner | LBX SRD Smart Knobs
Donate via Paypal

Last edited by lb0; 05-30-2020 at 04:05 PM.
lb0 is offline   Reply With Quote
Old 05-27-2020, 07:11 PM   #1269
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 290
Default

Quote:
Originally Posted by juliansader View Post
It is not expected. The function should only return the file name, without affecting the file in any way.

I noticed a similar phenomenon once, but I haven't been able to replicate it again, so I'm not actually sure that my original observation was actually due to JS_Dialog_BrowseForOpenFiles.

* In your case, is it only the file(s) returned by JS_Dialog_BrowseForOpenFiles that are affected, or also other files?

* When you cannot change the name of the locked file, what happens when you click on Windows Explorer's menu -> View -> Refresh? Does the refreshed file show the new name?
It's not the file being locked, but the FOLDER that contain the file.

In my case, I use JS_Dialog_BrowseForOpenFiles to load E:\bak\test.wav, then the folder E:\bak is locked(cann't change it's name, cann't delete it), but E:\bak\test.wav is fine.
dsyrock is offline   Reply With Quote
Old 05-28-2020, 04:19 AM   #1270
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 2,172
Default

Quote:
Originally Posted by juliansader View Post
However, scripts can easily access other script's reaper.arrays, even without a reaper.array object, since a reaper.array is simply an array of doubles (except the first 64bits, which give the size and used size as 32bit integers). For example, if you convert the reaper.array userdata to a number address (using tonumber or JS_Window_AddressFromHandle) and pass this address to another script, the second script can read the array double-by-double using JS_Double, or read the entire array with JS_String and unpack the doubles with string.unpack. (I'm not sure if it will be faster than ExtStates, though.)

This is interesting!! And nice to know that can be done! However, in practice a reaper.array is not of very much use. One can gmem_write all the references to the objects he wants to pass directly to the memory, and it would be a lot faster than putting the references into a reaper.array and pass its reference to the other script and then go into all this hassle to get it back. But things are completely different with lua tables, which can have a hash part and include other tables inside them. If one could pass a (complex) lua table from one script to another, then this would be really great! Passing a simple array (be it a reaper.array or a lua table/array) would be slower than directly writing the object references with gmem.
amagalma is offline   Reply With Quote
Old 05-28-2020, 05:07 AM   #1271
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 2,172
Default

A small test:
Code:
array = reaper.new_array({25,"hello",12,-7})

-- making a copy
array_address = reaper.JS_Window_AddressFromHandle( array )
copy_of_array = reaper.JS_Window_HandleFromAddress( array_address )
-- in the IDE it can be seen that they refer to same object

-- BUT...
array_sz = array.get_alloc() -- = 4
-- copy_of_array_sz = copy_of_array.get_alloc() -- doesn't work
-- we get "attempt to index a userdata value" error

retval, buf = reaper.JS_String( array, 0, 1000 ) -- ???
first_entry = reaper.JS_Double( array, 1 ) -- returns 25! works!
second_entry = reaper.JS_Double( array, 2 ) -- returns 0 instead of "hello"

-- let's try with the copy
copy_retval, copy_buf = reaper.JS_String( copy_of_array, 0, 1000 ) -- ???
copy_first_entry = reaper.JS_Double( copy_of_array, 1 ) -- returns 25! works too!!
copy_second_entry = reaper.JS_Double( copy_of_array, 2 ) -- returns 0 instead of "hello"

How can it work with strings? As JS_Double seems to return only numbers and JS_String doesn't seem to return anything useful.. Furthermore, the handle we get is to the same object(array = copy_of_array) but copy_of_array does not behave like an array (see above). This is what happens with lua tables too but doesn't happen with the rest of reaper objects (items, takes, tracks etc). How can we overcome this?

Last edited by amagalma; 05-28-2020 at 05:25 AM.
amagalma is offline   Reply With Quote
Old 05-28-2020, 06:05 AM   #1272
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 9,729
Default

Quote:
Originally Posted by amagalma View Post
If one could pass a (complex) lua table from one script to another, then this would be really great!
I imagine it could work serializing the table first, pass the table string to the other script and un-serialize? (never tried myself..)

e.g. http://lua-users.org/wiki/PickleTable
nofish is offline   Reply With Quote
Old 05-28-2020, 08:13 AM   #1273
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 2,172
Default

It wouldn't work because gmem can store only numbers. If the table had to be serialised and then unserialised, then better to use ext states.
amagalma is offline   Reply With Quote
Old 05-31-2020, 12:01 PM   #1274
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: Apr 2020
Location: Leipzig
Posts: 608
Default

What is currently the minimum Reaper-requirement for JS-extension?

Edit: There's a typo in the Lua-description of JS_WriteJPG where there's a , missing between filename and LICE_IBitmap
boolean reaper.JS_LICE_WriteJPG(string filename, LICE_IBitmap bitmap, integer quality, unsupported forceBaseline)

Lua and Eel: the parameters forceBaseline and forceBaselineOptional should be of type boolean but are shown as unsupported instead.

BTW: what is the default setting of forceBaseline when called with nil? True or false?

Edit2: JS_Composite has also unsupported datatype for autoUpdate which I assue shall be optional boolean instead.
Do I get it right, that all parameters for src and dst of JS_Composite have been exchanged? So dst comes first now, where it used to be src first before?
__________________
Use you/she/her, when contacting me, please. Thanks :) Not mentoring via PMs, sorry.
Ultraschall-API - 1200 ReaScript functions for Reaper - Reaper Internals - Developerdocs4Reaper - Donate, if you wish

Last edited by Meo-Ada Mespotine; 05-31-2020 at 12:24 PM.
Meo-Ada Mespotine is offline   Reply With Quote
Old 05-31-2020, 01:01 PM   #1275
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,198
Default

Thanks for going through the API help in such detail.


Quote:
Originally Posted by Meo-Ada Mespotine View Post
What is currently the minimum Reaper-requirement for JS-extension?
Currently still 5.974. Was this when ValidatePtr with "HWND" was introduced? I'll have to check.


Quote:
Originally Posted by Meo-Ada Mespotine View Post
Edit: There's a typo in the Lua-description of JS_WriteJPG where there's a , missing between filename and LICE_IBitmap
boolean reaper.JS_LICE_WriteJPG(string filename, LICE_IBitmap bitmap, integer quality, unsupported forceBaseline)
That's a formatting error in help parser. I should probably change "LICE_IBitmap" to simply "identifier", which gets formatted correctly.


Quote:
Originally Posted by Meo-Ada Mespotine View Post
Lua and Eel: the parameters forceBaseline and forceBaselineOptional should be of type boolean but are shown as unsupported instead.
This is an old bug: please bump the thread https://forums.cockos.com/showthread.php?t=216234.


Quote:
Originally Posted by Meo-Ada Mespotine View Post
BTW: what is the default setting of forceBaseline when called with nil? True or false?
False. I will add this in the API help of the next update.


Quote:
Originally Posted by Meo-Ada Mespotine View Post
Edit2: JS_Composite has also unsupported datatype for autoUpdate which I assue shall be optional boolean instead.
Correct.


Quote:
Originally Posted by Meo-Ada Mespotine View Post
Do I get it right, that all parameters for src and dst of JS_Composite have been exchanged? So dst comes first now, where it used to be src first before?
Only the names were swapped around (since they were incorrect in previous versions), so scripts don't need to be changed. The window is the destination, and the bitmap is the source.
juliansader is offline   Reply With Quote
Old 05-31-2020, 02:01 PM   #1276
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: Apr 2020
Location: Leipzig
Posts: 608
Default

Ok,thanks.

One more question: what is the purpose of JS_LICE_ArrayAllBitmaps? And as it needs reaper-arrays, it's probably only useful in Lua, correct?
__________________
Use you/she/her, when contacting me, please. Thanks :) Not mentoring via PMs, sorry.
Ultraschall-API - 1200 ReaScript functions for Reaper - Reaper Internals - Developerdocs4Reaper - Donate, if you wish
Meo-Ada Mespotine is offline   Reply With Quote
Old 06-07-2020, 10:39 AM   #1277
Levitanus
Human being with feelings
 
Join Date: Nov 2015
Location: Novosibirsk, Russia
Posts: 27
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
Ok,thanks.

One more question: what is the purpose of JS_LICE_ArrayAllBitmaps? And as it needs reaper-arrays, it's probably only useful in Lua, correct?
You can use it from python too: https://github.com/RomeoDespres/reap...f740c021d71be1
Levitanus is offline   Reply With Quote
Old 06-08-2020, 01:00 PM   #1278
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,198
Default

Quote:
Originally Posted by lb0 View Post
Awesome - thank you Julian.

No hurry from me though - I found a solution in the end to use GradRect instead as this allowed me to use the 0xAA value from the color parameter - and just not apply any gradient.
It seems to be a bug in LICE, and I submitted a report: WDL/LICE: FillRect applies alpha differently than FillCircle and other functions.
juliansader is offline   Reply With Quote
Old 06-08-2020, 04:53 PM   #1279
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 3,643
Default

Quote:
Originally Posted by juliansader View Post
It seems to be a bug in LICE, and I submitted a report: WDL/LICE: FillRect applies alpha differently than FillCircle and other functions.
Thanks for investigating and raising the bug report. Much appreciated - as I haven't yet found a perfect solution.
__________________
Projects - Reascripts - Lua:
LBX Stripper | LBX Chaos Engine | LBX Floating FX Positioner | LBX SRD Smart Knobs
Donate via Paypal
lb0 is offline   Reply With Quote
Old 06-13-2020, 09:39 AM   #1280
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: Apr 2020
Location: Leipzig
Posts: 608
Default

I'm currently trying to do a resize tcp-width-function and as a simple resize of the TCP-hwnd doesn't work(it messes up arrange, timeline and maintoolbar), I want to code a function, which actually drags the right-side of the tcp to the desired position.

Now my question: how can I send a mouse-message to a specific position in a hwnd? I can send it to buttons and such, but I would like to position it exactly to hit the border between arrange and tcp. How can I do that?
__________________
Use you/she/her, when contacting me, please. Thanks :) Not mentoring via PMs, sorry.
Ultraschall-API - 1200 ReaScript functions for Reaper - Reaper Internals - Developerdocs4Reaper - Donate, if you wish
Meo-Ada 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 11:19 PM.


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