Old 08-27-2020, 10:05 AM   #81
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

thx as always for the help here mespotine

I will give a +1 one the thread
daniellumertz is offline   Reply With Quote
Old 08-27-2020, 10:30 AM   #82
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

Quote:
Originally Posted by daniellumertz View Post
each time i execute the script I posted above ( which is many as I am triggering it using mouse wheel to increase / decrease the track height ) it create a ReaScipt:Run
I call defer like this and don't see any ReaScipt:Run messages. BTW only need to call UpdateArrange if you actually changed something, try...

Code:
is_new_value,filename,sectionID,cmdID,mode,resolution, val = reaper.get_action_context()
if is_new_value then
  x, y = reaper.GetMousePosition()
  track, _ = reaper.GetTrackFromPoint(x,y) 
  if track then
    old_height = reaper.GetMediaTrackInfo_Value(track,"I_TCPH")
    if val > 0 then
      reaper.SetMediaTrackInfo_Value(track, "I_HEIGHTOVERRIDE", (old_height+15))
    else
      reaper.SetMediaTrackInfo_Value(track, "I_HEIGHTOVERRIDE", (old_height-15))   
    end
    reaper.TrackList_AdjustWindows(false)
    reaper.UpdateArrange()    
  end 
end
reaper.defer(function () end)
EDIT Opps, last line was missing ")" at the end!

Last edited by Edgemeal; 08-27-2020 at 11:02 AM. Reason: FIX TYPO! reaper.defer(function () end)
Edgemeal is offline   Reply With Quote
Old 08-27-2020, 01:16 PM   #83
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Couldn't this potentially open up the new instance-dialog, when run to often in a row?
Try make an action which runs the script dozens of times in a row. If I'm wrong with my assumption, this would bring a new detail to how defer works.
__________________
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-27-2020, 01:54 PM   #84
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

yey thanks!!! works very well here!! I see what I missed, I will give a closer study to defer for future scripts

@Mespotine I tried here but couldn't result in the dialog... And I executed it rolling really fast my MW using the logitech hyper scroll hahaha
daniellumertz is offline   Reply With Quote
Old 08-27-2020, 02:35 PM   #85
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
Couldn't this potentially open up the new instance-dialog, when run to often in a row?
Try make an action which runs the script dozens of times in a row. If I'm wrong with my assumption, this would bring a new detail to how defer works.
Sure if I use keyboard shortcut and hold the key down, but spinning mouse wheel as fast as I can the dialog never popped up.
Even if dialog does pop up, just terminate + remember and it should never pop up again, saved in kb.ini as you know.

Last edited by Edgemeal; 08-27-2020 at 02:40 PM.
Edgemeal is offline   Reply With Quote
Old 08-27-2020, 02:53 PM   #86
sonictim
Human being with feelings
 
sonictim's Avatar
 
Join Date: Feb 2020
Location: Los Angeles
Posts: 463
Default Multiple Command Icons

I'm writing a script that has 3 states Off, version 1, version 2. I'd love for my icon I'm using in the tool bar to reflect each state differently, similar to how the Ripple Edit Icon changes based on which mode you have set. How do I accomplish this?

I've been able to figure out SetToggleCommandState, and I have 3 states... 0, 1, 2 that it cycles between. But is there a different method I should use? And how do I get the icon to change based on its state? Currently, it just shows OFF, ON, ON as I cycle.

Thanks!
sonictim is offline   Reply With Quote
Old 08-27-2020, 02:58 PM   #87
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

No, there are only two states settable via Api, while a third one, arm toolbar button, can only be done via right click, afaik.
__________________
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-27-2020, 03:14 PM   #88
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
while a third one, arm toolbar button, can only be done via right click, afaik.
Code:
reaper.ArmCommand(integer cmd, string sectionname)
Edgemeal is offline   Reply With Quote
Old 08-27-2020, 03:39 PM   #89
sonictim
Human being with feelings
 
sonictim's Avatar
 
Join Date: Feb 2020
Location: Los Angeles
Posts: 463
Default

Quote:
No, there are only two states settable via Api, while a third one, arm toolbar button, can only be done via right click, afaik.
You can set the command state to any number you like, so it has multiple states. I've already tried this and have it working..

I'm mostly trying to figure out how the ripple icon is able to have different icons depending on what mode you have it in. I would love to create something similar for my script.
sonictim is offline   Reply With Quote
Old 08-27-2020, 04:10 PM   #90
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Quote:
Originally Posted by sonictim View Post
I'm mostly trying to figure out how the ripple icon is able to have different icons depending on what mode you have it in. I would love to create something similar for my script.
I have only some thoughts to offer..
Toolbar text can't be changed dynamically (currently) afaik so that approach won't work for indicating the three states so I think the only potential chance is using images (icons) for the toolbar.
When unpacking e.g. Reaper 6 default theme there are icons named
toolbar_ripple_all.png
toolbar_ripple_off.png
toolbar_ripple_one.png

But again, as toolbars buttons can only be assigned one icon currently afaik I see no way to do what you want unfortunately.
Maybe worth a feature request?
nofish is offline   Reply With Quote
Old 08-27-2020, 04:28 PM   #91
sonictim
Human being with feelings
 
sonictim's Avatar
 
Join Date: Feb 2020
Location: Los Angeles
Posts: 463
Default Thank You

Thanks No Fish! I will post a feature request
sonictim is offline   Reply With Quote
Old 08-30-2020, 09:55 PM   #92
explodingPSYCH
Human being with feelings
 
Join Date: Sep 2015
Posts: 302
Default Preventing edit cursor move with custom mouse modifier script?

I am attempting to use a custom action with a mouse modifier on Media Item -> Left Click. The action is working, but I do not want the edit cursor to move when I left click the media item. I've tried a few combinations of existing actions, including "Undo edit cursor move" which sometimes works, but also makes the cursor jump around in a buggy way.

I figured there could be a way around this via scripting to reset the state of the edit cursor after running my action, by doing the following:

Code:
local prevPos = reaper.GetCursorPosition()
reaper.ShowConsoleMsg(prevPos .. "\n")
-- Call custom action
local commandID = reaper.NamedCommandLookup("_e6fa877dd54230498383d2a5065cc768")
reaper.Main_OnCommand(commandID, 0)
local currPos = reaper.GetCursorPosition()
reaper.ShowConsoleMsg(currPos .. "\n")
if currPos ~= prevPos then
  reaper.SetEditCurPos(prevPos, false, false)
end
However based on the console output it seems like the edit cursor position automatically changes before my script is called, because prevPos and currPos both return the position where I clicked.

Is there is any way via scripting to execute a custom action when clicking a media item, without moving the Edit Cursor?

I can see that selecting an item without moving the edit cursor is technically possible in Reaper, because one of the built-in options for the Media Item -> Left Click mouse modifiers is Select Item, which does not move the edit cursor.
explodingPSYCH is offline   Reply With Quote
Old 08-31-2020, 02:28 AM   #93
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Quote:
Originally Posted by explodingPSYCH View Post
I am attempting to use a custom action with a mouse modifier on Media Item -> Left Click. The action is working, but I do not want the edit cursor to move when I left click the media item. I've tried a few combinations of existing actions, including "Undo edit cursor move" which sometimes works, but also makes the cursor jump around in a buggy way.

I figured there could be a way around this via scripting to reset the state of the edit cursor after running my action, by doing the following:

Code:
local prevPos = reaper.GetCursorPosition()
reaper.ShowConsoleMsg(prevPos .. "\n")
-- Call custom action
local commandID = reaper.NamedCommandLookup("_e6fa877dd54230498383d2a5065cc768")
reaper.Main_OnCommand(commandID, 0)
local currPos = reaper.GetCursorPosition()
reaper.ShowConsoleMsg(currPos .. "\n")
if currPos ~= prevPos then
  reaper.SetEditCurPos(prevPos, false, false)
end
However based on the console output it seems like the edit cursor position automatically changes before my script is called, because prevPos and currPos both return the position where I clicked.

Is there is any way via scripting to execute a custom action when clicking a media item, without moving the Edit Cursor?

I can see that selecting an item without moving the edit cursor is technically possible in Reaper, because one of the built-in options for the Media Item -> Left Click mouse modifiers is Select Item, which does not move the edit cursor.
Only possible with a background script, that constantly checks the editcursor position and stores the old position into an extstate, which in turn you can read out.
__________________
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 09-06-2020, 08:43 PM   #94
explodingPSYCH
Human being with feelings
 
Join Date: Sep 2015
Posts: 302
Default Zooming to content and maintaining zoom state when MIDI editor is open

Quote:
Originally Posted by Meo-Ada Mespotine View Post
Only possible with a background script, that constantly checks the editcursor position and stores the old position into an extstate, which in turn you can read out.
Thank you, this was helpful! I was finally able to get my "restore edit cursor" script working today by following this approach.

Now I am trying to tackle my problems with MIDI editor behavior:


Problem 1: How to get the correct handle for the currently active MIDI editor, when I am using one editor per track?

This came up because I am trying to use the Zoom to Content action in a script that opens the MIDI editor after clicking on a MIDI item. This only seems to work consistently for the last opened MIDI editor. I am using one MIDI editor per track. When I click on an item on a track that already has an editor, it is not showing up as the active/focused MIDI editor when I call reaper.MIDIEditor_GetActive(), even though the previously-opened editor window seems to be active.


Problem 2: Maintaining zoom state of previously edited MIDI items

Ideally I would like to be able to edit a MIDI item, open/edit another MIDI item in a different track, and still have the previous editor be zoomed into to the last place I was editing when I switch back to that editor. (Opening a midi editor per item seemed to help but that really started bogging down Reaper, performance wise.)

I played around with various reaper functions to get info about the active MIDI editor, items, etc. and searched the forums, but no success so far.

Is it possible to get/set the state of where a given MIDI editor is zoomed for a particular MIDI media item that I was editing?

Or maybe there is some other way to not lose my place when editing an item, after switching to another editor and back?
explodingPSYCH is offline   Reply With Quote
Old 09-09-2020, 08:45 AM   #95
explodingPSYCH
Human being with feelings
 
Join Date: Sep 2015
Posts: 302
Default

I think I found a solution to Problem 1 (a.k.a. How to get the correct handle for the currently active MIDI editor, when I am using one editor per track?)

If I use the following code I can get a pointer to the correct MIDI editor for the item I just selected, even when multiple editors are open per track:

Code:
local item = reaper.GetSelectedMediaItem(0,0)
if item == nil then return end
local take = reaper.GetActiveTake(item)
if take == nil then return end
if not reaper.TakeIsMIDI(take) then return end

local takename = reaper.GetTakeName(take)
local takewindow = reaper.JS_Window_Find("MIDI take: ".. takename, true)
reaper.ShowConsoleMsg("takename: " .. takename .. "\n")
if takewindow ~= nil then
  title = reaper.JS_Window_GetTitle(takewindow)
  reaper.ShowConsoleMsg("Found window title: " .. title .. "\n")
end
I'm still trying to figure out how to consistently retain the zoom of the item from when I last edited (Problem 2 in my previous message).
explodingPSYCH is offline   Reply With Quote
Old 09-10-2020, 10:20 AM   #96
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 565
Default

Is there any way to set the value of the master play rate more than 4 by script? CSurf_OnPlayRateChange only allows to set the value from 0.25 to 4.
dsyrock is offline   Reply With Quote
Old 09-10-2020, 10:26 AM   #97
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

I think 4 is the maximum in general.

You can do

Code:
playrate=8
A=reaper.SNM_SetDoubleConfigVar("playrate", playrate)
but this will not update the value in the playrate-slider.

Up to 1200, maybe higher is possible, but probably only useful for bats

"The preserving pitch"-setting will only be accepted up until 8x. Anything higher will become higher pitched, no matter what.
__________________
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 09-10-2020, 10:47 AM   #98
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

Quote:
Originally Posted by daniellumertz View Post
This is a code to set playrate in semitones (you can also use float values like 0.5 "50 cents up")

Code:
reaper.Undo_BeginBlock()
reaper.ShowConsoleMsg("")
actual_rate = reaper.Master_GetPlayRate( 0 )
actual_rate_in_st =  12 * math.log(actual_rate,2)
retval, retvals_csv = reaper.GetUserInputs( "Rate in Semitones", 2, "Change Rate to, Acutal Rate in Semitones", "0,"..tostring(actual_rate_in_st) )
  if retval == false then return end
retvals_csv, _= retvals_csv:match("([^,]+),([^,]+)")
retvals_csv = tonumber(retvals_csv)
new_in_st = 2^(retvals_csv/12)
reaper.CSurf_OnPlayRateChange(new_in_st)
reaper.Undo_EndBlock( "Rate in Semitones" , -1 )
very simple : p


funfact:
discover that using the actions like
Item properties: Increase item rate by ~6% (one semitone)
You can estrapolate the limit of REAPER playrate = 10x
like using this increase it by +100x
Code:
 for i = 0 ,100 do
         reaper.Main_OnCommand( 40522, 0 )--increase by semitones
 end
some time back I did it this way:
daniellumertz is offline   Reply With Quote
Old 09-10-2020, 10:49 AM   #99
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 565
Default

Really helpful, thanks!
dsyrock is offline   Reply With Quote
Old 09-11-2020, 03:45 PM   #100
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

so I want to get all media item that are in some group.

I know I can

Code:
loop_group_id = reaper.GetMediaItemInfo_Value(loop_item, "I_GROUPID")
to get the group ID the media item is. with that I could loop through all items and make a table of those that are in the same group but isn't a better/faster way than that?

maybe it is stored in some chunk of the project?

exemple of looping all items

Code:
group_table = {}
project_i_count = reaper.CountMediaItems(0)
for i = 0, project_i_count-1 do
  loop_item_group = reaper.GetMediaItem(0, i)
  loop_group_id = reaper.GetMediaItemInfo_Value(loop_item_group, "I_GROUPID")
  if loop_group_id ~= 0 then
    if not group_table[loop_group_id] then group_table[loop_group_id] = {} end
    loop_n_group = #group_table[loop_group_id]
    group_table[loop_group_id][loop_n_group+1] = loop_item_group
  end
end
-- The first number is for the group ID the second is the media item number in the group (both 1 based0
--group_table[1][1] -- is for the 1 group and the 1 media item
--group_table[2][1] -- is for the 2 group and the 1 media item
--group_table[1][5] -- is for the 1 group and the 5 media item

Last edited by daniellumertz; 09-11-2020 at 04:27 PM.
daniellumertz is offline   Reply With Quote
Old 09-11-2020, 07:18 PM   #101
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Nope, your way is the only way.

Chunking would be possible but is a lot more work and probably slower.
__________________
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 09-11-2020, 07:26 PM   #102
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

oh, ok, thanks for the reply

In the end I tested in a project with A LOT of items to see and it was fast, so I think it is okk
daniellumertz is offline   Reply With Quote
Old 09-14-2020, 12:07 PM   #103
jkooks
Human being with feelings
 
Join Date: May 2020
Posts: 190
Default

Quote:
Originally Posted by daniellumertz View Post
so I want to get all media item that are in some group.

This is one of the few things I end up using a Reaper native action for since it is typically cleaner/easier than looping through every item and it works for the majority of my scripts where I just need the grouped items for one "main" item, but I am not if one technique is faster than the other (I haven't done any bench-marking):

Code:
local items = {}
local editItem = reaper.GetSelectedMediaItem(0, 0) 

local group = reaper.GetMediaItemInfo_Value(editItem, "I_GROUPID")
if group > 0 then --trims multiple items if part of a group
	reaper.Main_OnCommand(40034, 0) --selects all items if the original is part of a group

	local itemCount = reaper.CountSelectedMediaItems(0)
	for i = 0, itemCount - 1 do
		items[i+1] = reaper.GetSelectedMediaItem(0, i)
	end
end
jkooks is offline   Reply With Quote
Old 09-15-2020, 04:43 PM   #104
Karl Phazer
Human being with feelings
 
Join Date: Oct 2013
Location: Finland
Posts: 12
Default

No 'how do I?" type of questions but..


1. Can someone explain why functions like GetTrackName return also a boolean when they 'succeed'? Isn't that a bit redundant since they could just return nil for the name (or whatever they are supposed to return) in such cases where they return false? And then why doesn't GetTrack return a boolean?

2. Just to make sure, Lua doesn't have i++ or i += 1 type expressions, right? Only way is to write i = i + 1?

3. Thanks to Mespotine, I now know that the watchlist in the Reaper IDE shows the global variables but what are the ones starting with "gfx". Better yet, can you point me to some place where this sort of stuff is explained?

4. Why is there something rather than nothing? (Anybody seen my coat?)

Thanks!
Karl Phazer is offline   Reply With Quote
Old 09-15-2020, 07:29 PM   #105
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Quote:
Originally Posted by Karl Phazer View Post
No 'how do I?" type of questions but..


1. Can someone explain why functions like GetTrackName return also a boolean when they 'succeed'? Isn't that a bit redundant since they could just return nil for the name (or whatever they are supposed to return) in such cases where they return false? And then why doesn't GetTrack return a boolean?
Just accept that. The ReaScript-API isn't designed to be beautiful. There are numerous such cases.

Quote:
2. Just to make sure, Lua doesn't have i++ or i += 1 type expressions, right? Only way is to write i = i + 1?
Correct.

Quote:
3. Thanks to Mespotine, I now know that the watchlist in the Reaper IDE shows the global variables but what are the ones starting with "gfx". Better yet, can you point me to some place where this sort of stuff is explained?
They are for graphics-functions. You can open a window using gfx.init() and draw into it. The gfx-variables contain some values like mouse-coordinates, window-dimensions, etc.

Quote:
4. Why is there something rather than nothing? (Anybody seen my coat?)

Thanks!
It's easier to live with something than in nothing hill ^^
__________________
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 09-15-2020, 08:54 PM   #106
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

Quote:
Originally Posted by jkooks View Post
This is one of the few things I end up using a Reaper native action for since it is typically cleaner/easier than looping through every item and it works for the majority of my scripts where I just need the grouped items for one "main" item, but I am not if one technique is faster than the other (I haven't done any bench-marking):

Code:
local items = {}
local editItem = reaper.GetSelectedMediaItem(0, 0) 

local group = reaper.GetMediaItemInfo_Value(editItem, "I_GROUPID")
if group > 0 then --trims multiple items if part of a group
	reaper.Main_OnCommand(40034, 0) --selects all items if the original is part of a group

	local itemCount = reaper.CountSelectedMediaItems(0)
	for i = 0, itemCount - 1 do
		items[i+1] = reaper.GetSelectedMediaItem(0, i)
	end
end
just saw this now. thanks for sharing!is a good way too. .
The script going through all the items, actually, surprised me as it was done very fast, even with thousands of dull midi items I used in the testing
daniellumertz is offline   Reply With Quote
Old 09-16-2020, 01:51 AM   #107
Karl Phazer
Human being with feelings
 
Join Date: Oct 2013
Location: Finland
Posts: 12
Default

Quote:
Quote:

1. Can someone explain why functions like GetTrackName return also a boolean when they 'succeed'? Isn't that a bit redundant since they could just return nil for the name (or whatever they are supposed to return) in such cases where they return false? And then why doesn't GetTrack return a boolean?
Just accept that. The ReaScript-API isn't designed to be beautiful. There are numerous such cases.
Sure, I'm not trying to point out flaws here but to find out if I'm missing something essential.

Could there be a situation where a track exists, has a name and everything but the function would still be unable to obtain its name?
Karl Phazer is offline   Reply With Quote
Old 09-16-2020, 06:22 AM   #108
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

I think in some API cases it is just redundant.
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 09-16-2020, 11:06 AM   #109
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 565
Default

Is there any example of how to use GetMediaItemTake_Peaks? All I found in here is:
https://forum.cockos.com/showthread.php?t=188427

But no matter how I ran this script, I only got an empty gui window.
dsyrock is offline   Reply With Quote
Old 09-17-2020, 04:08 AM   #110
sonictim
Human being with feelings
 
sonictim's Avatar
 
Join Date: Feb 2020
Location: Los Angeles
Posts: 463
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
Nope, your way is the only way.

Chunking would be possible but is a lot more work and probably slower.
As I'm relatively new to all this, I (probably incorrectly) assumed that chunking is usually a faster, though more complicated and dangerous, path for adjusting session data. Can you elaborate as to why chunking might be slower than using other methods so I can understand it better?

Thanks!
sonictim is offline   Reply With Quote
Old 09-17-2020, 04:15 PM   #111
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

Quote:
Originally Posted by sonictim View Post
As I'm relatively new to all this, I (probably incorrectly) assumed that chunking is usually a faster, though more complicated and dangerous, path for adjusting session data. Can you elaborate as to why chunking might be slower than using other methods so I can understand it better?

Thanks!
I'm new to this to especially using chunks, I will try to answer why I think this is true, but I might be wrong.
If you see the rpp.as a text, the groups items are not stored in an group or line or a part of it. They are with the other items info. So you would still have to go to every Item chunk looking for
Code:
GROUP %d
""the %d is any number"". This probably will end up using more functions for searching in the Chunk string.
daniellumertz is offline   Reply With Quote
Old 09-17-2020, 04:35 PM   #112
sonictim
Human being with feelings
 
sonictim's Avatar
 
Join Date: Feb 2020
Location: Los Angeles
Posts: 463
Default

Quote:
Originally Posted by daniellumertz View Post
I'm new to this to especially using chunks, I will try to answer why I think this is true, but I might be wrong.
If you see the rpp.as a text, the groups items are not stored in an group or line or a part of it. They are with the other items info. So you would still have to go to every Item chunk looking for
Code:
GROUP %d
""the %d is any number"". This probably will end up using more functions for searching in the Chunk string.
Yes, your case that definitely makes sense. I'm also inquiring in a more general sense. In most cases are chunks faster/slower than just making a bunch of API calls?

Is "get chunk" "modify chunk via string manipulation" "replace chunk" equal/faster/slower as as say "get item", get item info value, change item info value, set item info value"? That's probably an oversimplified example, but if I had to do something for 10000 items, I'd be curious to know which would be faster/more efficient.
sonictim is offline   Reply With Quote
Old 09-17-2020, 08:49 PM   #113
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

It depends on the size of the chunk.
The more fx you have, the bigger it is, the longer pattern matching takes.

With groupid, if you have Api-functions for that, they are usually faster, as they can give you the information directly, as they don't need to work with chunks but rather take the information directly from their internal datastructures.

In addition to that, it's not enough to get groupid, but you need to get the corresponding item guid as well to get the item associated with it(slower pattern matching).

So you have:
1 get statechunks
2 parse for guids and corresponding groupid
3 get the item by guid.

versus

1 get the item
2 get the groupid via api.

Doing it with grouped items selected speeds up things a little so it's a good idea. Recreating the old item-selection could slow things down a little.


PS: committing/setting statechunks is always slow and should be done only as often as absolutely necessary. The right committing strategy can be the difference between slow and fast.
__________________
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 09-25-2020, 11:32 PM   #114
Hypex
Human being with feelings
 
Join Date: Mar 2015
Location: Australia
Posts: 451
Default Count of selected media items in selected tracks?

I've thought of another one. Getting a count of selected media items in selected tracks on a per track basis. I don't see any function to do this. There is a count of selected tracks and count of selected items. I don't see a count of selected track items. And there can be tracks and items selected independent of each other. So having count of tracks with selected media items would also help. I think in this case a bit of programming may be required to build an array of selected items and sift through it to find the parent tracks. But some actions like moving to next track may help to isolate tracks.
Hypex is offline   Reply With Quote
Old 09-25-2020, 11:57 PM   #115
sonictim
Human being with feelings
 
sonictim's Avatar
 
Join Date: Feb 2020
Location: Los Angeles
Posts: 463
Default

Quote:
Originally Posted by Hypex View Post
I've thought of another one. Getting a count of selected media items in selected tracks on a per track basis. I don't see any function to do this. There is a count of selected tracks and count of selected items. I don't see a count of selected track items. And there can be tracks and items selected independent of each other. So having count of tracks with selected media items would also help. I think in this case a bit of programming may be required to build an array of selected items and sift through it to find the parent tracks. But some actions like moving to next track may help to isolate tracks.
I'm sorry, what are you trying to accomplish? Do you want to know the total number of selected items on a track? or do you want a list of tracks that have selected items? or both?
sonictim is offline   Reply With Quote
Old 09-26-2020, 04:07 AM   #116
Hypex
Human being with feelings
 
Join Date: Mar 2015
Location: Australia
Posts: 451
Default

Quote:
Originally Posted by sonictim View Post
I'm sorry, what are you trying to accomplish? Do you want to know the total number of selected items on a track? or do you want a list of tracks that have selected items? or both?

Yes. Actually, both. I've discovered a situation that can occur and am looking at how to solve it. For example, if some items have been selected, and I want to select all items on all the tracks they are selected on within a time selection. Now there is a handy action to select all items on selected tracks in current time selection.


But, in the case there are other tracks selected as well as the ones with the items, all the other selected tracks will have their items selected as well. Which isn't what I want. Because I just want to isolate those tracks that have selected items.



So, what I'm looking to accomplish after all this, is to simply select all items on tracks that have items selected. I've tested doing this from actions and found that deselecting tracks disables them from selecting items. So, a track must be activated as well, or no items on that track will be activated.


Is it a conundrum or an easy riddle to solve? :-)
Hypex is offline   Reply With Quote
Old 09-26-2020, 06:55 AM   #117
Colox
Human being with feelings
 
Join Date: Feb 2012
Location: Sweden
Posts: 1,206
Default

Is the programming concept commonly known as "Arrays" available also in EEL? or no?
If yes, is this what a "Stack" in JS is?

And if so, a Stack is described (in Cockos JSFX code ref) as being limited to 4096 "items". Is "items" to be seen as 4096 array IDs? So, can't save more than 4096 unique posts using a stack? or does "items" mean digits, or bits, or what?
__________________
There are only two kinds of people in the world: those who entertain, and those who are absurd.
- Britney Spears

Last edited by Colox; 09-26-2020 at 07:00 AM.
Colox is offline   Reply With Quote
Old 09-26-2020, 07:08 AM   #118
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Quote:
Originally Posted by Colox View Post
Is the programming concept commonly known as "Arrays" available also in EEL? or no?
If yes, is this what a "Stack" in JS is?

And if so, a Stack is described (in Cockos JSFX code ref) as being limited to 4096 "items". Is "items" to be seen as 4096 array IDs? So, can't save more than 4096 unique posts using a stack? or does "items" mean digits, or bits, or what?
Haven't read the JS doc but generally a stack is something different than an array, the difference being e.g. you don't have arbitrary access to all elements of the stack.
https://en.wikipedia.org/wiki/Stack_...act_data_type))

Last edited by nofish; 09-26-2020 at 07:14 AM.
nofish is offline   Reply With Quote
Old 09-26-2020, 08:23 AM   #119
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 565
Default

In Project Bay, you can select all the items that share the same source file (by turning on the mirror selection option) very quickly.

I'm trying to find a way to do the same thing in reascript WITHOUT iterating all the items in the project, but I can't find any build-in action or sws action can help. So any advice about it?
dsyrock is offline   Reply With Quote
Old 09-26-2020, 08:40 AM   #120
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

You need to iterate through all of them or you can't find out, which source they have to compare them against.

Or you try to guess, but this is usually not very precise
__________________
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
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:51 AM.


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