Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Q&A, Tips, Tricks and Howto

Reply
 
Thread Tools Display Modes
Old 09-18-2023, 11:15 AM   #1
CPacaud
Human being with feelings
 
Join Date: Nov 2022
Location: Québec, QC, Canada
Posts: 24
Default Selecting MIDI items containing a note under edit cursor

Hey!

I'm looking for an action that would do something along the lines of this script:
https://forums.cockos.com/showthread.php?t=212275

...but would only select the MIDI items under the edit cursor that contain a note at the location of the edit cursor.

Is that possible? I included a piece of Paint art to illustrate what I mean :P

Thanks !
Attached Images
File Type: png Sans titre.png (8.7 KB, 52 views)
CPacaud is offline   Reply With Quote
Old 09-18-2023, 04:47 PM   #2
boolin
Human being with feelings
 
Join Date: Oct 2018
Posts: 187
Default

not exactly what you requested, however perhaps you'll be able to make some headway with this one...

Script: BirdBird_Select notes aligned with mouse (Vertical).lua

the command works within the midi editor (haven't tried from tcp)

if you don't see this command in the action list, make sure you have midi selected (top right of action list window)

if you still don't see it, you may need to install via reapack.

hth. cheers.
boolin is offline   Reply With Quote
Old 09-18-2023, 06:28 PM   #3
dangguidan
Human being with feelings
 
Join Date: Jan 2019
Location: China
Posts: 649
Default

It shouldn't be difficult to implement this using scripts, but I'm a bit curious about what functionality is being implemented?
__________________
My script sharing sources are mostly about MIDI editing.
https://github.com/zaibuyidao/YS_Rea...main/index.xml
dangguidan is offline   Reply With Quote
Old 09-18-2023, 06:55 PM   #4
dangguidan
Human being with feelings
 
Join Date: Jan 2019
Location: China
Posts: 649
Default

Create a new script in the action list and paste the following code.
Code:
CursorPos = reaper.GetCursorPosition()
reaper.SelectAllMediaItems(0, false)
itemidx = 0
item = reaper.GetMediaItem(0, itemidx)
while item do
    take = reaper.GetTake(item, 0)
    if reaper.TakeIsMIDI(take) then
        reaper.MIDI_DisableSort(take)
        noteidx = 0
        retval, notecnt, ccevtcnt, textsyxevtcnt = reaper.MIDI_CountEvts(take)
        PPQPos = reaper.MIDI_GetPPQPosFromProjTime(take, CursorPos)
        while noteidx < notecnt do
            retval, selected, muted, startppqpos, endppqpos, chan, pitch, vel = reaper.MIDI_GetNote(take, noteidx)
            if startppqpos <= PPQPos and endppqpos > PPQPos then
                reaper.SetMediaItemSelected(item, true)
                break
            end
            noteidx = noteidx + 1
        end
        reaper.MIDI_Sort(take)
    end
    itemidx = itemidx + 1
    item = reaper.GetMediaItem(0, itemidx)
end
__________________
My script sharing sources are mostly about MIDI editing.
https://github.com/zaibuyidao/YS_Rea...main/index.xml
dangguidan is offline   Reply With Quote
Old 09-18-2023, 07:22 PM   #5
CPacaud
Human being with feelings
 
Join Date: Nov 2022
Location: Québec, QC, Canada
Posts: 24
Default

Wow, looking forward to trying this out tomorrow morning!

It's to help me manage working with a fairly large orchestral template, working with a single MIDI editor view showing multiple tracks/items at the same time. Sometimes I have sections with only a few instruments playing out of a complete orchestral template, and it can be hard to identify which notes shown are from which track/instrument - especially when there are doublings (overlapping notes from different tracks/instruments). If I can select from a specific location, from the currently shown track/items only the ones with notes under the cursor, that would leave me with only the used instruments selected and I figure it becomes a viable workflow to identify what's going on in a specific section of the piece.

Thanks boolin and dangguidan! I should get back here with some news about the results tomorrow.
CPacaud is offline   Reply With Quote
Old 09-19-2023, 04:26 AM   #6
mccrabney
Human being with feelings
 
mccrabney's Avatar
 
Join Date: Aug 2015
Posts: 3,662
Default

excellent script request, this will be so useful on big projects, especially when we come back to them after a long time away...thanks to both requester and implementer
__________________
mccrabney scripts: MIDI edits from the Arrange screen ala jjos/MPC sequencer
|sis - - - anacru| isn't what we performed: pls no extra noteons in loop recording
| - - - - - anacru|sis <==this is what we actually performed.
mccrabney is offline   Reply With Quote
Old 09-19-2023, 07:45 AM   #7
CPacaud
Human being with feelings
 
Join Date: Nov 2022
Location: Québec, QC, Canada
Posts: 24
Default

Well, holy crap. This is a game-changer. I've yet to spend serious time working with it, but at first glance this seems like it does exactly what I was talking about. Thank you SO MUCH dangguidan! I'll have a look at the rest of your script repository, too.
CPacaud is offline   Reply With Quote
Old 10-09-2023, 08:43 AM   #8
CPacaud
Human being with feelings
 
Join Date: Nov 2022
Location: Québec, QC, Canada
Posts: 24
Default

This has been a lifesaver for the last few weeks.

I went ahead and mashed together a new variation of dangguidan's script using parts of another script (dsyrock_Select items under edit cursor) to select all MIDI items under cursor, regardless of if they have notes or not - this way I can alternate between "everything" (just MIDI items) and just the items with notes.

I needed to do this because I can have video tracks on top of everything that would screw up some operations I do that checks the length of my current item selection.

Feel free to tell me if something's wrong in there, but it seems to be working as intended so far.

Code:
CursorPos = reaper.GetCursorPosition()
reaper.SelectAllMediaItems(0, false)
itemidx = 0
item = reaper.GetMediaItem(0, itemidx)
while item do
    item_pos=reaper.GetMediaItemInfo_Value(item, "D_POSITION")
    item_length=reaper.GetMediaItemInfo_Value(item, "D_LENGTH")
    take = reaper.GetTake(item, 0)
    if reaper.TakeIsMIDI(take) then
        reaper.MIDI_DisableSort(take)
        if item_pos<=CursorPos and item_pos+item_length>CursorPos then
          reaper.SetMediaItemSelected(item, true)
        end
        reaper.MIDI_Sort(take)
    end
    itemidx = itemidx + 1
    item = reaper.GetMediaItem(0, itemidx)
end
CPacaud 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 03:11 PM.


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