|
|
|
07-08-2020, 05:19 AM
|
#41
|
Human being with feelings
Join Date: Jul 2010
Location: Slovakia
Posts: 2,588
|
+ 1
|
|
|
08-11-2020, 03:25 PM
|
#42
|
Human being with feelings
Join Date: Dec 2017
Location: Brazil
Posts: 2,011
|
bumpppp, it seems to be very handy for many here
|
|
|
11-01-2020, 04:02 AM
|
#43
|
Human being with feelings
Join Date: Jul 2019
Posts: 7
|
+1, got stuck without these too
|
|
|
04-04-2021, 11:52 AM
|
#44
|
Human being with feelings
Join Date: Aug 2010
Posts: 396
|
+1
Really need a get/set for editing a visible items in the MIDI editor.
|
|
|
04-13-2021, 09:30 PM
|
#45
|
Human being with feelings
Join Date: Dec 2017
Location: Brazil
Posts: 2,011
|
I made this that might help some here.
https://forum.cockos.com/showthread....91#post2431991
The idea I got from the classic Multitool from JS :P If you have any bugs or nitpicks please report!
This Return a list of editable Takes in piano roll based if Selection is linked to editability. If is on will return all MIDI takes selected, if it is off it will return the MIDI take active.
|
|
|
05-28-2021, 10:39 AM
|
#46
|
Human being with feelings
Join Date: Jul 2010
Location: Slovakia
Posts: 2,588
|
Bump.
|
|
|
05-30-2021, 04:07 AM
|
#47
|
Human being with feelings
Join Date: Aug 2015
Posts: 3,672
|
good to see so many familiar names and familiar requests here - sometimes i feel like the only one trying to edit multiple midi items at the same time
|
|
|
05-31-2021, 04:31 AM
|
#48
|
Human being with feelings
Join Date: May 2019
Location: Berlin
Posts: 2,202
|
100% support this request!
Here's a short function to get the visible takes for anyone that might need it.
Code:
function MIDIEditor_GetVisibleTakes(hwnd)
local editor_take = reaper.MIDIEditor_GetTake(hwnd)
if not reaper.ValidatePtr(editor_take, 'MediaItem_Take*') then return end
-- Cycle through visible MIDI items until the first one is reached
local vis_takes = {editor_take}
-- Activate next visible MIDI item
reaper.MIDIEditor_OnCommand(hwnd, 40500)
local active_take = reaper.MIDIEditor_GetTake(hwnd)
while active_take ~= editor_take do
vis_takes[#vis_takes + 1] = active_take
-- Activate next visible MIDI item
reaper.MIDIEditor_OnCommand(hwnd, 40500)
active_take = reaper.MIDIEditor_GetTake(hwnd)
end
return vis_takes
end
|
|
|
05-31-2021, 05:11 AM
|
#49
|
Human being with feelings
Join Date: Jul 2010
Location: Slovakia
Posts: 2,588
|
Quote:
Originally Posted by FeedTheCat
100% support this request!
Here's a short function to get the visible takes for anyone that might need it.
|
Does this run fast enough? I remember trying to mess with these commands but it took forever to cycle through with notation editor open. I did not try with a regular midi editor.
|
|
|
05-31-2021, 05:31 AM
|
#50
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Quote:
Originally Posted by FeedTheCat
100% support this request!
Here's a short function to get the visible takes for anyone that might need it.
|
Thanks for the function!
(A side-effect of the function is that all visible items become editable.)
|
|
|
05-31-2021, 07:47 AM
|
#51
|
Human being with feelings
Join Date: May 2019
Location: Berlin
Posts: 2,202
|
Quote:
Originally Posted by bFooz
Does this run fast enough? I remember trying to mess with these commands but it took forever to cycle through with notation editor open. I did not try with a regular midi editor.
|
Haven't tested it enough to tell. The new functions I posted below should be though.
Quote:
Originally Posted by juliansader
(A side-effect of the function is that all visible items become editable.)
|
Ahh yeah obviously... was wondering where the catch is. I was reading this thread today and remembered a weird behavior I observed when making my multi-edit script, which could potentially be exploited to determine if items are visible/editable in the MIDI editor.
(I was trying to code this exploit when I discovered the action to activate the next visible item and thought I found a much simpler solution, hehe )
I'll try to formulate that behavior in steps:
1. Your editor is already open
2. 'Selection is linked to visibility' is disabled
3. You enable 'Selection is linked to visibility' via SNM_SetIntConfigVar
4. You run "Open in built-in MIDI editor"
5. Items that have a visible state in the MIDI editor, are now also selected in arrange.
Attached are two functions that try to exploit this behavior. MIDIEditor_GetVisibleItems and MIDIEditor_GetEditableItems.
One drawback that I'm aware of is that they use the command "Open in built-in MIDI editor" on the already active item, which will make REAPER zoom to the active item horizontally. But if that's the only drawback I should definitely be able to restore the zoom level using some code I had written for my MIDI editor magic project.
Can't tell if there's more drawbacks. Maybe someone wants to test them? If they work, it might also be possible to reverse the functionality and set item state to visible/editable.
Code:
function MIDIEditor_GetVisibleItems(hwnd)
local editor_take = reaper.MIDIEditor_GetTake(hwnd)
if not reaper.ValidatePtr(editor_take, 'MediaItem_Take*') then return end
reaper.PreventUIRefresh(1)
-- Save current item selection
local sel_items = {}
for i = 0, reaper.CountSelectedMediaItems(0) - 1 do
sel_items[#sel_items + 1] = reaper.GetSelectedMediaItem(0, i)
end
-- Get current MIDI editor settings
local config = reaper.SNM_GetIntConfigVar('midieditor', 0)
local editor_type = config % 4
local behavior_type = config & 20
local editability = config & 512
local visibility = config & 1024
local new_config = config
-- Set 'One MIDI Editor per project'
new_config = new_config - editor_type + 1
-- Set behavior for opening MIDI items to 'Open all selected MIDI items'
new_config = new_config - behavior_type
-- Disable 'Selection is linked to visibility'
new_config = new_config - editability
-- Enable 'Selection is linked to visibility'
new_config = new_config - visibility
reaper.SNM_SetIntConfigVar('midieditor', new_config)
-- Set current editor item to be the only selected item
reaper.SelectAllMediaItems(0, false)
local editor_item = reaper.GetMediaItemTake_Item(editor_take)
reaper.SetMediaItemSelected(editor_item, true)
-- Cmd: Open in built-in MIDI editor
reaper.Main_OnCommand(40153, 0)
-- Save current item selection
local vis_items = {}
for i = 0, reaper.CountSelectedMediaItems(0) - 1 do
vis_items[#vis_items + 1] = reaper.GetSelectedMediaItem(0, i)
end
reaper.SNM_SetIntConfigVar('midieditor', config)
-- Restore previous item selection
reaper.SelectAllMediaItems(0, false)
for _, item in ipairs(sel_items) do
reaper.SetMediaItemSelected(item, true)
end
reaper.PreventUIRefresh(-1)
return vis_items
end
function MIDIEditor_GetEditableItems(hwnd)
local editor_take = reaper.MIDIEditor_GetTake(hwnd)
if not reaper.ValidatePtr(editor_take, 'MediaItem_Take*') then return end
reaper.PreventUIRefresh(1)
-- Save current item selection
local sel_items = {}
for i = 0, reaper.CountSelectedMediaItems(0) - 1 do
sel_items[#sel_items + 1] = reaper.GetSelectedMediaItem(0, i)
end
-- Get MIDI editor settings
local config = reaper.SNM_GetIntConfigVar('midieditor', 0)
local editor_type = config % 4
local behavior_type = config & 20
local editability = config & 512
local visibility = config & 1024
-- Change MIDI editor settings
local new_config = config
-- Set 'One MIDI Editor per project'
new_config = new_config - editor_type + 1
-- Set behavior for opening MIDI items to 'Open all selected MIDI items'
new_config = new_config - behavior_type
-- Enable 'Selection is linked to editability'
new_config = new_config - editability
-- Disable 'Selection is linked to visibility'
new_config = new_config - visibility + 1024
reaper.SNM_SetIntConfigVar('midieditor', new_config)
-- Set current editor item to be the only selected item
reaper.SelectAllMediaItems(0, false)
local editor_item = reaper.GetMediaItemTake_Item(editor_take)
reaper.SetMediaItemSelected(editor_item, true)
-- Cmd: Open in built-in MIDI editor
reaper.Main_OnCommand(40153, 0)
-- Save current item selection
local vis_items = {}
for i = 0, reaper.CountSelectedMediaItems(0) - 1 do
vis_items[#vis_items + 1] = reaper.GetSelectedMediaItem(0, i)
end
reaper.SNM_SetIntConfigVar('midieditor', config)
-- Restore previous item selection
reaper.SelectAllMediaItems(0, false)
for _, item in ipairs(sel_items) do
reaper.SetMediaItemSelected(item, true)
end
reaper.PreventUIRefresh(-1)
return vis_items
end
Last edited by FeedTheCat; 05-31-2021 at 08:45 AM.
Reason: Changed function names (they now take hwnd as parameter))
|
|
|
05-31-2021, 02:01 PM
|
#52
|
Human being with feelings
Join Date: May 2019
Location: Berlin
Posts: 2,202
|
Alright guys, I kept going with this...
In just about 300 unnecessary lines of code (please devs, add it natively!) you get the following functions:
table[MediaItem*] MIDIEditor_GetAllVisibleItems(HWND hwnd)
table[MediaItem*] MIDIEditor_GetAllEditableItems(HWND hwnd)
boolean MIDIEditor_IsItemVisible(HWND hwnd, MediaItem* item)
boolean MIDIEditor_IsItemEditable(HWND hwnd, MediaItem* item)
MIDIEditor_SetItemVisible(HWND hwnd, MediaItem* item, boolean is_visible)
MIDIEditor_SetItemsVisible(HWND hwnd, table[MediaItem*] items, boolean is_visible)
MIDIEditor_SetItemEditable(HWND hwnd, MediaItem* item, boolean is_editable)
MIDIEditor_SetItemsEditable(HWND hwnd, table[MediaItem*] items, boolean is_editable)
Edit: Added MIDIEditor_SetActiveItem(HWND hwnd, MediaItem* item)
I only tested it on Linux, but so far it all seems to work fairly well. When working on a lot of items consider using the table[MediaItem*] variants, as they will perform considerably better.
For anyone interested, the functions are in the attachment below.
Last edited by FeedTheCat; 08-06-2021 at 05:20 AM.
|
|
|
06-01-2021, 11:15 AM
|
#53
|
Human being with feelings
Join Date: Aug 2010
Posts: 396
|
Quote:
Originally Posted by FeedTheCat
Alright guys, I kept going with this...
In just about 300 unnecessary lines of code (please devs, add it natively!) you get the following functions:
table[MediaItem*] MIDIEditor_GetAllVisibleItems(HWND hwnd)
table[MediaItem*] MIDIEditor_GetAllEditableItems(HWND hwnd)
boolean MIDIEditor_IsItemVisible(HWND hwnd, MediaItem* item)
boolean MIDIEditor_IsItemEditable(HWND hwnd, MediaItem* item)
MIDIEditor_SetItemVisible(HWND hwnd, MediaItem* item, boolean is_visible)
MIDIEditor_SetItemsVisible(HWND hwnd, table[MediaItem*] items, boolean is_visible)
MIDIEditor_SetItemEditable(HWND hwnd, MediaItem* item, boolean is_editable)
MIDIEditor_SetItemsEditable(HWND hwnd, table[MediaItem*] items, boolean is_editable)
I only tested it on Linux, but so far it all seems to work fairly well. When working on a lot of items consider using the table[MediaItem*] variants, as they will perform considerably better.
For anyone interested, the functions are in the attachment below.
|
OOOOHHHH. This is Huge!! Thank you!!!! I'll check these out on OSX sometime this week.
|
|
|
06-01-2021, 11:50 AM
|
#54
|
Human being with feelings
Join Date: Dec 2017
Location: Brazil
Posts: 2,011
|
thanks a lot FTC I will be using for sure, I wonder the differences between mine option https://forum.cockos.com/showthread....91#post2431991. If you approach is faster... Haven't got much time to look into the code
|
|
|
06-01-2021, 12:56 PM
|
#55
|
Human being with feelings
Join Date: May 2019
Location: Berlin
Posts: 2,202
|
Quote:
Originally Posted by benmrx
OOOOHHHH. This is Huge!! Thank you!!!! I'll check these out on OSX sometime this week.
|
Nice, let me know if it works Unfortunately it's not a "clean" solution, might be quite error-prone as the logic is overly complex, so not really sure how usable of a solution it actually is...
Quote:
Originally Posted by daniellumertz
|
Hehe, actually... your approach should definitely be a lot faster than mine. The difference is that my functions work without selection being linked to visibility/editability (also with one MIDI editor per item/track etc.). My functions actually don't even work with those options enabled, oops I'll patch it and upload again..
Edit: Ok, file updated. When visibility/editability is linked to item selection by setting, the functions simply get/set item selection.
Last edited by FeedTheCat; 06-01-2021 at 01:31 PM.
|
|
|
06-07-2021, 06:59 AM
|
#56
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,067
|
Quote:
Originally Posted by FeedTheCat
When visibility/editability is linked to item selection by setting, the functions simply get/set item selection.
|
That's basically what I use as my approach, since it seemed to me the most straight forward way to do it.
|
|
|
07-06-2021, 05:15 PM
|
#57
|
Human being with feelings
Join Date: Sep 2020
Posts: 149
|
bump +1
|
|
|
08-05-2021, 01:20 AM
|
#58
|
Human being with feelings
Join Date: Jul 2010
Location: Slovakia
Posts: 2,588
|
Just a bump again.
|
|
|
08-05-2021, 05:52 AM
|
#59
|
Human being with feelings
Join Date: Jul 2010
Location: Slovakia
Posts: 2,588
|
Quote:
Originally Posted by FeedTheCat
Alright guys, I kept going with this...
|
Hi FTC, thanks for the code!
One thing I found for myself previously is that the funcion
Code:
reaper.SelectAllMediaItems(0, false)
generates an unnecessary undo point, so its better to unselect all items in a loop. You use it on several places.
Code:
--reaper.SelectAllMediaItems(0, false)
for i=0, reaper.CountMediaItems(0)-1 do
local item = reaper.GetMediaItem( 0, i )
reaper.SetMediaItemSelected( item, false )
end
|
|
|
08-05-2021, 11:19 AM
|
#60
|
Human being with feelings
Join Date: May 2019
Location: Berlin
Posts: 2,202
|
Quote:
Originally Posted by bFooz
Hi FTC, thanks for the code!
One thing I found for myself previously is that the funcion
Code:
reaper.SelectAllMediaItems(0, false)
generates an unnecessary undo point, so its better to unselect all items in a loop. You use it on several places.
|
Ah thank you, never noticed that. I updated the code in the previous post. I also changed some other stuff that should speed it up quite a bit if JS_ReaScriptAPI is installed.
|
|
|
08-06-2021, 02:47 AM
|
#61
|
Human being with feelings
Join Date: Jul 2010
Location: Slovakia
Posts: 2,588
|
I also notice that one variant is missing - to select a particular item within the editor, to change the active context as devs call it. But don't know if that's easily done or not (for me it was not, I've tried several methods, even one with Autohotkey, but none was satisfactory.)
This would be useful for notation editor where all items are already visible in lanes/tracks and all are already already editable by activating the option "All items are editable in notation view". But actions and scripts which work within the active context still works only within one single selected item.
Last edited by bFooz; 08-06-2021 at 02:54 AM.
|
|
|
08-06-2021, 02:58 AM
|
#62
|
Human being with feelings
Join Date: Jul 2010
Location: Slovakia
Posts: 2,588
|
Quote:
Originally Posted by FeedTheCat
Ah thank you, never noticed that. I updated the code in the previous post. I also changed some other stuff that should speed it up quite a bit if JS_ReaScriptAPI is installed.
|
Some debugging - the time selection is left after running "MIDIEditor_GetAllVisibleItems()".
|
|
|
08-06-2021, 03:17 AM
|
#63
|
Human being with feelings
Join Date: May 2019
Location: Berlin
Posts: 2,202
|
Quote:
Originally Posted by bFooz
Some debugging - the time selection is left after running "MIDIEditor_GetAllVisibleItems()".
|
Hehe, just noticed myself, was about to upload a quickfix
|
|
|
08-06-2021, 05:32 AM
|
#64
|
Human being with feelings
Join Date: May 2019
Location: Berlin
Posts: 2,202
|
Added the function MIDIEditor_SetActiveItem(HWND hwnd, MediaItem* item)
Now we're up to 400 lines of unnecessary code...
It lets you set the active item MIDI editor item, without messing with editability/visibility (and hopefully other settings).
Quote:
Originally Posted by bFooz
This would be useful for notation editor where all items are already visible in lanes/tracks and all are already already editable by activating the option "All items are editable in notation view". But actions and scripts which work within the active context still works only within one single selected item.
|
Changing the active item/take is quite slow with this function (~20ms). It's also really slow with internal MIDI editor actions like "Activate next MIDI item" though, so I don't think this can be improved upon much. Which probably makes it infeasible to iterate over a lot of items and perform actions in each context.
|
|
|
08-06-2021, 06:14 AM
|
#65
|
Human being with feelings
Join Date: Jul 2010
Location: Slovakia
Posts: 2,588
|
Quote:
Originally Posted by FeedTheCat
Changing the active item/take is quite slow with this function (~20ms). It's also really slow with internal MIDI editor actions like "Activate next MIDI item" though, so I don't think this can be improved upon much. Which probably makes it infeasible to iterate over a lot of items and perform actions in each context.
|
Thanks, this looks good!
You usually want to perform actions on selected events, so you get visible items, from them find all that have selected events and work on them only. 20ms is heaven.
But there is a problem in the notation editor which I came across previously and reported here a here related
https://forum.cockos.com/showthread....68#post2442868
https://forum.cockos.com/showthread....70#post2442870
and that's that the scroll position and zoom level flyes unexpectedly. I have not found a cure for it yet. It does not react even on "reaper.JS_Window_SetScrollPos()".
|
|
|
12-26-2021, 08:35 AM
|
#66
|
Human being with feelings
Join Date: Jul 2010
Location: Slovakia
Posts: 2,588
|
Bump.
|
|
|
01-31-2023, 06:53 AM
|
#67
|
Human being with feelings
Join Date: Aug 2011
Posts: 522
|
Hello! I am trying to use these funtions from FTC but i cant make it.
I copied all of the functions to my script and then did:
Code:
hwnd = reaper.MIDIEditor_GetActive()
item = reaper.MIDIEditor_GetTake( hwnd )
MIDIEditor_SetItemEditable(hwnd, item, false)
i was hoping to see the little Lock change on the Midi Editor but i just couldnt. What am i doing wrong?
BTW the only thing i want to do is to keep the editable in sync wth the active clip in the MIDI editor. So that when i use the action "activate next visible midi item" i only select the notes of that clip and not the ones which dont belong to the active clip. Not sure if there is any other way to do that without using these funtions on a script?
Thanks!
|
|
|
01-31-2023, 07:27 AM
|
#68
|
Human being with feelings
Join Date: May 2019
Location: Berlin
Posts: 2,202
|
Quote:
Originally Posted by reapero
Hello! I am trying to use these funtions from FTC but i cant make it.
I copied all of the functions to my script and then did:
Code:
hwnd = reaper.MIDIEditor_GetActive()
item = reaper.MIDIEditor_GetTake( hwnd )
MIDIEditor_SetItemEditable(hwnd, item, false)
i was hoping to see the little Lock change on the Midi Editor but i just couldnt. What am i doing wrong?
BTW the only thing i want to do is to keep the editable in sync wth the active clip in the MIDI editor. So that when i use the action "activate next visible midi item" i only select the notes of that clip and not the ones which dont belong to the active clip. Not sure if there is any other way to do that without using these funtions on a script?
Thanks!
|
Afaict the functions expect an item, but you're giving them a take. Try this instead:
Code:
hwnd = reaper.MIDIEditor_GetActive()
take = reaper.MIDIEditor_GetTake(hwnd)
item = reaper.GetMediaItemTake_Item(take)
MIDIEditor_SetItemEditable(hwnd, item, false)
|
|
|
01-31-2023, 08:58 AM
|
#69
|
Human being with feelings
Join Date: Aug 2011
Posts: 522
|
Of course..duh! Thanks FeedTheCat!
|
|
|
10-21-2023, 10:51 PM
|
#70
|
Human being with feelings
Join Date: Oct 2023
Posts: 20
|
Bump!
Also, thank you so much @FeedTheCat for your functions, they allowed me to port over some behavior from Cubase and seem to work great so far. Only mild irritation is that whenever I use them, the MIDI editor slightly zooms in, but I guess that's due to the 'hacky' way you had to do things?
Only more reason for this to become a native feature.
|
|
|
10-27-2023, 03:43 AM
|
#71
|
Human being with feelings
Join Date: May 2019
Location: Berlin
Posts: 2,202
|
Quote:
Originally Posted by Laki
Bump!
Also, thank you so much @FeedTheCat for your functions, they allowed me to port over some behavior from Cubase and seem to work great so far. Only mild irritation is that whenever I use them, the MIDI editor slightly zooms in, but I guess that's due to the 'hacky' way you had to do things?
Only more reason for this to become a native feature.
|
Yes, unfortunately this is very hacky... You can probably get rid of the slight zoom by adjusting the "factor" variable in line 125.
|
|
|
10-30-2023, 07:35 AM
|
#72
|
Human being with feelings
Join Date: Oct 2023
Posts: 20
|
Quote:
Originally Posted by FeedTheCat
Yes, unfortunately this is very hacky... You can probably get rid of the slight zoom by adjusting the "factor" variable in line 125.
|
I'll give that a try, thanks!
|
|
|
10-30-2023, 08:04 AM
|
#73
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
|
This has been partly implemented meanwhile with MIDIEditor_EnumTakes() to get visible/editable takes.
Last edited by nofish; 10-30-2023 at 02:42 PM.
|
|
|
11-10-2023, 03:20 AM
|
#74
|
Human being with feelings
Join Date: Dec 2019
Location: sthlm, swe
Posts: 150
|
Quote:
Originally Posted by _Stevie_
Another bump
|
+1
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 03:47 AM.
|