Go Back   Cockos Incorporated Forums > REAPER Forums > Dstruct's Casa De Nitpicks

Reply
 
Thread Tools Display Modes
Old 02-22-2020, 07:34 PM   #1
dangguidan
Human being with feelings
 
Join Date: Jan 2019
Posts: 149
Default Can the action of trimming notes be set to work on all editable items?

Can the action of trimming notes be set to work on all editable items?
Edit: trim right edge of note to edit cursor. This action is very common, but it can only work on the active item at present.
dangguidan is offline   Reply With Quote
Old 03-04-2020, 03:25 AM   #2
Stroudy
Human being with feelings
 
Join Date: Jul 2014
Posts: 420
Default

Quote:
Originally Posted by dangguidan View Post
Can the action of trimming notes be set to work on all editable items?
Edit: trim right edge of note to edit cursor. This action is very common, but it can only work on the active item at present.
Came here to say the same thing and find this is the most recent Nitpick! Amazing


For clarity, here are the actions I'm talking about:
Edit: Trim left edge of note to edit cursor - 40790
Edit: Trim right edge of note to edit cursor - 40791


Action will only work on the ACTIVE item, even when ALL items are editable like this:
Stroudy is offline   Reply With Quote
Old 03-25-2020, 08:01 AM   #3
dangguidan
Human being with feelings
 
Join Date: Jan 2019
Posts: 149
Default

I solved it with a script, but I need to select all the items that need to be edited.

Code:
editor=reaper.MIDIEditor_GetActive()
contselitem= reaper.CountSelectedMediaItems(0)
selitem = 0
while selitem < contselitem do
MediaItem = reaper.GetSelectedMediaItem(0, selitem)
selitem = selitem + 1
take = reaper.GetTake(MediaItem, 0)
num=reaper.GetCursorPositionEx(0)
dur=reaper.MIDI_GetPPQPosFromProjTime(take, num)
 reaper.MIDI_DisableSort(take)
local idx=-1 
tbnote={}
repeat 
  n_idx = reaper.MIDI_EnumSelNotes(take,idx)  
   retval, sel, mute, startppqpos, endppqpos, chan, pitch, vel = reaper.MIDI_GetNote(take, n_idx)
   if startppqpos < dur then
  if tbnote[pitch]~=nil then 
  reaper.MIDI_SetNote(take, tbnote[pitch], true, false, NULL, startppqpos, NULL, NULL, NULL, false)
  end
 tbnote[pitch]=n_idx
 end
idx=n_idx
n_idx = reaper.MIDI_EnumSelNotes(take,idx) 
until (n_idx==-1) 
key=0
 while key < 128 do
    if tbnote[key] ~= nil then
    reaper.MIDI_SetNote(take, tbnote[key], true, false, NULL, dur, NULL, NULL, NULL, false)
    end
    key = key + 1
end 
reaper.MIDI_Sort(take)
end -- while item end
dangguidan 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:34 AM.


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