Old 02-12-2015, 09:16 AM   #81
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

and if you add more simple things to #notes, try with just #notes="random string text".
X-Raym is offline   Reply With Quote
Old 02-12-2015, 09:42 AM   #82
matthewjumpsoffbuildings
Human being with feelings
 
Join Date: Mar 2013
Posts: 463
Default

what the hell its working now? i didnt change anything... bizarre.
__________________
[sun sprites] spotify facebook
matthewjumpsoffbuildings is offline   Reply With Quote
Old 02-12-2015, 09:48 AM   #83
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

I have a script like that, sometime it doesn't display the correct thing in the console. I just have to execute it again again without changing anything (it is just a script to display infos, it doest do anything in the project) and it works. Scripting mysteries

Nice that you progress with your script !
X-Raym is offline   Reply With Quote
Old 02-15-2015, 12:28 PM   #84
matthewjumpsoffbuildings
Human being with feelings
 
Join Date: Mar 2013
Posts: 463
Default

i have another question, its to do with the #string style variables. are they always global? or can i define them local to a function?

it seems if i have a #variable defined anywhere, it always exists in the global scope?

also, how do i do arrays in EEL? is it even possible?

finally, what is the most reliable way to store a reference to a track, that wont be affected if the track is renamed, reordered etc... something that stays consistent with each time the project is opened? GUID or something like that? i need to be able to re-insert the original items that were glued into the original track they came from when the unglue script is called...
__________________
[sun sprites] spotify facebook

Last edited by matthewjumpsoffbuildings; 02-15-2015 at 12:50 PM.
matthewjumpsoffbuildings is offline   Reply With Quote
Old 02-18-2015, 06:43 AM   #85
matthewjumpsoffbuildings
Human being with feelings
 
Join Date: Mar 2013
Posts: 463
Default

anyone?
__________________
[sun sprites] spotify facebook
matthewjumpsoffbuildings is offline   Reply With Quote
Old 02-18-2015, 07:00 AM   #86
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

Seatch for thread Basic Array and Table Management with Eel and for thread Reascript track selecting conundrum ... - Cockos Confederated Forums
Yes for global variables
I almost always insert their value in a local variable after, using match function. There is probably a better solution but it is the only with wich i didnt have trouble. And I played a lot with those with all my sbtitles scripts :P

Short help, sorry, I'm a phone right now.

EDIT: it was told to me that LUA table is more easy, but there is still the "global array" thing, so I don't know how it could be easier ^^

Note: If i remember well, your script use hidden track and items.
Do you think about useing Extate ?

Last edited by X-Raym; 02-18-2015 at 07:05 AM.
X-Raym is offline   Reply With Quote
Old 02-18-2015, 07:39 AM   #87
matthewjumpsoffbuildings
Human being with feelings
 
Join Date: Mar 2013
Posts: 463
Default

thanks man, ill check those out.

the projextstate api was what inspired me to revisit this code. i am currently using that to store the items. its just useful for other things to know the track the items originally came from. it seems using getobjstate and doing a match("TRACKID %d") should do the trick

one other thing while youre here :P do you know the easiest way to split a string in EEL? im storing all the items in the glue group as a big string in the extstate, and currently using ||| as a delimiter, but dont know how to get that big string back into individual pieces.

hell i also cant work out how to do a string replace... sorry man, i really am struggling getting this complex script ported to EEL
__________________
[sun sprites] spotify facebook

Last edited by matthewjumpsoffbuildings; 02-18-2015 at 07:59 AM.
matthewjumpsoffbuildings is offline   Reply With Quote
Old 02-18-2015, 08:30 AM   #88
FnA
Human being with feelings
 
FnA's Avatar
 
Join Date: Jun 2012
Posts: 2,173
Default

Quote:
Originally Posted by matthewjumpsoffbuildings View Post
it seems using getobjstate and doing a match("TRACKID %d") should do the trick
Where do you find that? I only see the SWS version...

Quote:
Originally Posted by matthewjumpsoffbuildings View Post
one other thing while youre here :P do you know the easiest way to split a string in EEL? im storing all the items in the glue group as a big string in the extstate, and currently using ||| as a delimiter, but dont know how to get that big string back into individual pieces.

hell i also cant work out how to do a string replace... sorry man, i really am struggling getting this complex script ported to EEL
Just starting on strings myself. I think-match("*|||%{#blah}s", #str) will start at the end of the string. You know there is a limit on string length?
FnA is offline   Reply With Quote
Old 02-18-2015, 08:40 AM   #89
matthewjumpsoffbuildings
Human being with feelings
 
Join Date: Mar 2013
Posts: 463
Default

im using SNM_GetSetObjectState. The API doc for it says "The state chunk size is unlimited." but i guess i do need to convert to a standard EEL string at certain points, what is the limit on string length in EEL? and can i extend that limit somehow?

once you have a tracks state chunk, you can easily do a match() for the TRACKID string, and store the %d in a variable.

im not sure i understand your string split example.

the string will contain multiple items state chunks, eg:

<ITEM 1 bla bla>|||<ITEM 2 bla>|||<ITEM 3 bla bla bla>|||<ITEM 4>
__________________
[sun sprites] spotify facebook
matthewjumpsoffbuildings is offline   Reply With Quote
Old 02-18-2015, 08:44 AM   #90
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

@matthewjumpsoffbuildings
Don't be sorry, it is a pleasure to help, and we all here are happy to enhanced our favorite daw functionnalities together :P

So to anser you, you can effectively split strings with match functions and some kinf of regex, just as explained by FnA. It is a bit complicated, you will have test several things :P
In fact it don't split the strings, it scans it, and place into a variable the result of the scan filter.

I will let you know if I find a solution for this match.

Last edited by X-Raym; 02-18-2015 at 08:53 AM.
X-Raym is offline   Reply With Quote
Old 02-18-2015, 08:52 AM   #91
matthewjumpsoffbuildings
Human being with feelings
 
Join Date: Mar 2013
Posts: 463
Default

with the max string length problem, as i said it appears that the fastString doesnt have the same limit, but im thinking i will run into problems when trying to convert the fastString back into a normal EEL string... if a fastString is longer than the normal string max length is there a way to get it in smaller chunks, and to start at a certain offset of chars?
__________________
[sun sprites] spotify facebook
matthewjumpsoffbuildings is offline   Reply With Quote
Old 02-18-2015, 08:58 AM   #92
FnA
Human being with feelings
 
FnA's Avatar
 
Join Date: Jun 2012
Posts: 2,173
Default

I'm just a noob. It says in the docs that getobject state has a reduced read only feature. That's what I was hoping for for a different script. The length of MIDI item state string can be pretty long because of all the events in it.

Quote:
Originally Posted by spk77 View Post
...
Note: It's possible to store only 65536 bytes into named string variables in EEL. This shouldn't matter if you are using empty items. There are new functions in v5 to solve this problem.
I don't know if you need to pull them out in specific order? If not I theorize you could loop though and chop the string down(maybe with strsetlen), grabbing one at a time with strcpy_from or something. Like I said, just a noob.
FnA is offline   Reply With Quote
Old 02-18-2015, 09:02 AM   #93
matthewjumpsoffbuildings
Human being with feelings
 
Join Date: Mar 2013
Posts: 463
Default

hmm im thinking im going to have to switch this to Lua. there seems to be too many issues with strings, as well as the recursion issue im sure im going to bump into, with EEL.
__________________
[sun sprites] spotify facebook
matthewjumpsoffbuildings is offline   Reply With Quote
Old 02-19-2015, 09:45 AM   #94
matthewjumpsoffbuildings
Human being with feelings
 
Join Date: Mar 2013
Posts: 463
Default

im making a lot of progress with the Lua rewrite. however one big problem

i did a simple test

Code:
item = reaper.GetSelectedMediaItem(0, 0)

reaper.ULT_SetMediaItemNote(item, "test")
ran it on an empty item, nothing happened.

it seems like the ULT_SetMediaItemNote() function isnt working in Lua?

im using reaper 5 pre 13, with SWS 2.6.1 cause 2.6.2 isnt working with pre 13
__________________
[sun sprites] spotify facebook
matthewjumpsoffbuildings is offline   Reply With Quote
Old 02-19-2015, 09:47 AM   #95
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

Maybe try with pre-release 12 and last SWS 2.6.2
X-Raym is offline   Reply With Quote
Old 02-19-2015, 09:50 AM   #96
matthewjumpsoffbuildings
Human being with feelings
 
Join Date: Mar 2013
Posts: 463
Default

i rolled back to pre 12, no luck.

i then updated SWS to 2.6.2, still no luck

can you try and put those 2 lines in a 'test.lua' script and run it with a single empty item selected, and see if it works for you?
__________________
[sun sprites] spotify facebook
matthewjumpsoffbuildings is offline   Reply With Quote
Old 02-19-2015, 09:55 AM   #97
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

no results, for empty and non empty item
X-Raym is offline   Reply With Quote
Old 02-19-2015, 10:02 AM   #98
matthewjumpsoffbuildings
Human being with feelings
 
Join Date: Mar 2013
Posts: 463
Default

just found out that Get works. and also if you do a Set on an item that has notes, instead of just failing and leaving the original notes, it deletes all notes. but it doesnt trigger a UI refresh, so you have to zoom/scroll to see it
__________________
[sun sprites] spotify facebook
matthewjumpsoffbuildings is offline   Reply With Quote
Old 02-19-2015, 10:04 AM   #99
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

Quote:
but it doesnt trigger a UI refresh
or add UI refresh function in the script itself
X-Raym is offline   Reply With Quote
Old 02-19-2015, 10:05 AM   #100
matthewjumpsoffbuildings
Human being with feelings
 
Join Date: Mar 2013
Posts: 463
Default

sure but more importantly, it doesnt work, and deletes any existing notes while failing to set the new notes
__________________
[sun sprites] spotify facebook
matthewjumpsoffbuildings is offline   Reply With Quote
Old 02-19-2015, 09:39 PM   #101
matthewjumpsoffbuildings
Human being with feelings
 
Join Date: Mar 2013
Posts: 463
Default

im getting another weird problem with Lua, this time with the GetProjExtState() function. in the api docs it says this function requires 3 arguments, ReaProject proj, string extname, string key. however in use i find unless i add a fourth string parameter, an empty string, i get an error.

more importantly, if im simply storing a number in one of the keys, when i get it at a later time, it seems to always return 1. ive looked at the project xml inside the .RPP file and it says 2, but when i call GetProjExtState() i always get 1. im not sure if this is to do with that mystery 4th argument that isnt documented, or what.
__________________
[sun sprites] spotify facebook
matthewjumpsoffbuildings is offline   Reply With Quote
Old 02-20-2015, 01:31 AM   #102
matthewjumpsoffbuildings
Human being with feelings
 
Join Date: Mar 2013
Posts: 463
Default

do this simple test.lua
Code:
reaper.SetProjExtState(0, "TEST", 'test', 5)

state = reaper.GetProjExtState(0, "TEST", 'test', '')

reaper.ShowConsoleMsg(state)
it logs 1 for me, even though i have set it to 5. notice also the 4th argument for the GetProjExtState, the empty string. if i dont include that empty string i get an error
Code:
 bad argument #4 to 'GetProjExtState' (string expected, got no value)
even though the api docs dont mention needing this 4th argument
__________________
[sun sprites] spotify facebook
matthewjumpsoffbuildings is offline   Reply With Quote
Old 02-20-2015, 03:02 AM   #103
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

That's weid indeed.

In EEL? yopu have that 4th argument.
It is the variable name that store the desired value.
in your script, "state" returns 1 or 0 because it just tell us if GetProjectExtState was set for this key and value.

But to have the value back, it has to been store in a variable that is an argument of the function (in EEL, at least).

But it doesn't seem to work exactly like that in LUA
I don't know this language to much...

I hope I could help in some ways --'
X-Raym is offline   Reply With Quote
Old 02-20-2015, 03:04 AM   #104
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

try this

Code:
reaper.SetProjExtState(0, "TEST", "test", 5)

retval, valOut = reaper.GetProjExtState(0, "TEST", "test", "valOut")

reaper.ShowConsoleMsg(valOut)
X-Raym is offline   Reply With Quote
Old 02-20-2015, 03:26 AM   #105
matthewjumpsoffbuildings
Human being with feelings
 
Join Date: Mar 2013
Posts: 463
Default

oh damn the first value the function returns is kind of like a success/failure integer, the second value is the actual result...

still doesnt explain why the api docs say this
Code:
Lua: integer retval, string valOut reaper.GetProjExtState(ReaProject proj, string extname, string key)
see, no 4th string. EEL uses the 4th string to store the result, but in Lua the result is returned as the second return value, so it shouldnt be there. at least i can get it working now
__________________
[sun sprites] spotify facebook
matthewjumpsoffbuildings is offline   Reply With Quote
Old 02-20-2015, 03:29 AM   #106
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

my code is working :P
check above!

the two values that are return should be placed before the get function

the first value is the int fail/success, the second is your value, formated as string.
X-Raym is offline   Reply With Quote
Old 02-20-2015, 03:32 AM   #107
matthewjumpsoffbuildings
Human being with feelings
 
Join Date: Mar 2013
Posts: 463
Default

ye it is for me too. just saying that this also works

Code:
retval, valOut = reaper.GetProjExtState(0, "TEST", "test", "")
the fourth argument can be an empty string. and its not even mentioned in the api docs. it seems to be a leftover. it will still throw an error if not included, but it can be empty. kinda pointless
__________________
[sun sprites] spotify facebook
matthewjumpsoffbuildings is offline   Reply With Quote
Old 02-20-2015, 03:35 AM   #108
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

agreed. You should probably have to report it, as v5 is still in pre, maybe it can be corrected :P
X-Raym is offline   Reply With Quote
Old 02-20-2015, 03:35 PM   #109
matthewjumpsoffbuildings
Human being with feelings
 
Join Date: Mar 2013
Posts: 463
Default

tons of progress made... i have to say

FUCK ME LUA IS FAST!

holy SHIT.

i just did a test. i made a group 1, then used instances of that to make groups 2, 3 and 4. so lots of nesting.

i then duplicated instances of groups 3 and 4 (the ones with the most nesting) 3500 times

then i unglued, edited, and reglued group 1, the group all the others were based on, and expected reaper to crash like it would when i did this with python...

but no. save for the standard time it took for reaper to render the wav files for the glue, it took a fraction of a second to update the sources on 3500 instance.

i just wish this ULT_SetNotes thing would hurry and and be sorted. i reported it on the SWS github as well as the SWS prerelease thread, no response from either.
__________________
[sun sprites] spotify facebook
matthewjumpsoffbuildings is offline   Reply With Quote
Old 02-20-2015, 03:47 PM   #110
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

We want a demo
X-Raym is offline   Reply With Quote
Old 02-20-2015, 03:56 PM   #111
matthewjumpsoffbuildings
Human being with feelings
 
Join Date: Mar 2013
Posts: 463
Default

well its on my bitbucket here
https://bitbucket.org/matthewjumpsof...lua/?at=master

it needs all 3 scripts, but you only run Glue Group and Unglue Glue Group

however without the ULT Set Notes function its kinda useless, i have to manually add "glue_group_container:1" etc to the empty container before reglueing, otherwise it just creates a new glue group instead of updating the existing one

theres also a few issues to iron out other than that... right now its not really ready for use, more the result of a few sleepless days, lots of tidying and bugfixing left
__________________
[sun sprites] spotify facebook
matthewjumpsoffbuildings is offline   Reply With Quote
Old 02-20-2015, 04:36 PM   #112
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

So il will be a bit patient then.
Good luck with optimization!
X-Raym is offline   Reply With Quote
Old 02-21-2015, 10:23 AM   #113
matthewjumpsoffbuildings
Human being with feelings
 
Join Date: Mar 2013
Posts: 463
Default

that SWS ULT Set note function bug is really slowing me down. i opened and issue in the SWS github, no response for a couple of days. Also posted in the SWS prerelease thread, nothing. where should i post this so it gets sorted ASAP?
__________________
[sun sprites] spotify facebook
matthewjumpsoffbuildings is offline   Reply With Quote
Old 02-21-2015, 10:42 AM   #114
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 7,239
Default

Quote:
Originally Posted by matthewjumpsoffbuildings View Post
that SWS ULT Set note function bug is really slowing me down. i opened and issue in the SWS github, no response for a couple of days. Also posted in the SWS prerelease thread, nothing. where should i post this so it gets sorted ASAP?
I don't know Lua... :/ Yet

but in EEL I can get and set notes directly without that SWS function and it works in REAPER 4 too.
using the item's chunk xml and the GetSetItemState
in Lua you can do it too I guess, but I can't help you with Lua yet.
heda is offline   Reply With Quote
Old 02-21-2015, 10:52 AM   #115
matthewjumpsoffbuildings
Human being with feelings
 
Join Date: Mar 2013
Posts: 463
Default

ye im aware you can set notes manually by manipulating the state chunk, but i dont want to spend time writing/testing that code since the SWS native notes function exists, and is likely to be functional soon. i just want to know the best way to alert SWS devs of the issue and make sure its resolved ASAP
__________________
[sun sprites] spotify facebook
matthewjumpsoffbuildings is offline   Reply With Quote
Old 02-21-2015, 12:37 PM   #116
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 7,239
Default

Quote:
Originally Posted by matthewjumpsoffbuildings View Post
ye im aware you can set notes manually by manipulating the state chunk, but i dont want to spend time writing/testing that code since the SWS native notes function exists, and is likely to be functional soon. i just want to know the best way to alert SWS devs of the issue and make sure its resolved ASAP
I've made these functions in EEL for you. You may be able to translate them to Lua. I hope you can use them if you are in a hurry until SWS replies to you

Code:
function GetNote(item) (
	GetSetItemState(item, #str="");	
	match("*<NOTES?%{#note}s???IMGRESOURCEFLAGS*", #str);
	ShowConsoleMsg(#str);
	#note;
);


function SetNote(item,newnote) (
	GetSetItemState(item, #str="");	
	match("%s<NOTES?*", #str, #chunk);
	match("*???IMGRESOURCEFLAGS%s", #str, afternote);
	strcat(#chunk, "<NOTES\n|");
	strcat(#chunk, newnote);
	strcat(#chunk, "\n>\nIMGRESOURCEFLAGS");
	strcat(#chunk, afternote);
	GetSetItemState(item, #chunk);	
);


testing
Code:
// Get selected item's note
item = GetSelectedMediaItem(0, 0);
#str_note = GetNote(item);
ShowConsoleMsg(#str_note);
Code:
// Set selected item's note
item = GetSelectedMediaItem(0, 0);
SetNote(item, "testing set note\n|newline");
heda is offline   Reply With Quote
Old 02-22-2015, 10:15 AM   #117
matthewjumpsoffbuildings
Human being with feelings
 
Join Date: Mar 2013
Posts: 463
Default

thanks heda.

ive made some more improvements/bugfixes. i just did a test with 6 levels of nested groups (eg group 1 is in group 2-6, group 2 is in groups 3-6 and so on), with 23,000 (twenty three THOUSAND) instances. the calculations were super fast due to an improved approach to discovering which items need updating, the only thing that took a while was the basic loop through all 23,000 items to simply update the source of the wav file.

im thinking this particular function would be way faster in EEL instead of Lua.

is there a way to have a Lua script run a separate EEL script and pass it some parameters? cause im pretty sure for just looping through all the items in the project and doing a BR_UpdateTakeSource would be faster in EEL.
__________________
[sun sprites] spotify facebook
matthewjumpsoffbuildings is offline   Reply With Quote
Old 02-22-2015, 12:08 PM   #118
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 7,239
Default

Quote:
Originally Posted by matthewjumpsoffbuildings View Post
thanks heda.

is there a way to have a Lua script run a separate EEL script and pass it some parameters?
I have not tested it but in documentation it says you can use NamedCommandLookup().

reaper.Main_OnCommandEx(integer command, integer flag, ReaProject proj)

Performs an action belonging to the main action section. To perform non-native actions (ReaScripts, custom or extension plugins' actions) safely, see NamedCommandLookup().


but I don't know how I would pass parameters. Maybe creating a temporal file with the array of items, and then the EEL function would read the file and execute for each item in that file?
heda is offline   Reply With Quote
Old 02-22-2015, 12:13 PM   #119
matthewjumpsoffbuildings
Human being with feelings
 
Join Date: Mar 2013
Posts: 463
Default

hmm i didnt know you could use NamedCommandLookup() for ReaScripts, i thought it was just for dll extensions like SWS... cool.

im thinking i will just use SetProjExtState to store the data, and then delete it as soon as the EEL script is done. gonna test it out and see if its faster.
__________________
[sun sprites] spotify facebook
matthewjumpsoffbuildings is offline   Reply With Quote
Old 02-23-2015, 01:28 AM   #120
matthewjumpsoffbuildings
Human being with feelings
 
Join Date: Mar 2013
Posts: 463
Default

ugh another issue...

i want to be able to add a name to an empty item via ReaScript. i know you can do so by creating a new empty take and then naming that. the problem is this empty take is of the MIDI type, which is not what i need. the MIDI item type cannot be glued with other audio items, you have to convert the MIDI to an audio take first, but this is silly and will waste space creating empty audio files to fill the empty items just so i can give the empty item a name. is there another way to give an empty item a name via ReaScript that doesnt require me to create a new MIDI take, or a new empty audio take?

i guess the bigger problem here is the underlying code of Reaper, particularly how it deals with item names. there appears to be no such thing as an ITEM name, just the name of the currently active take. surely there should be a way to give the entire item a specific name, regardless of the active take?
__________________
[sun sprites] spotify facebook
matthewjumpsoffbuildings 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 02:18 PM.


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