Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Feature Requests

Reply
 
Thread Tools Display Modes
Old 10-25-2022, 03:43 AM   #1
mozart999uk
Human being with feelings
 
Join Date: Nov 2010
Posts: 1,737
Default After recording MIDI, expand / trim media item beginning and end to nearest bar

As the title suggests, I think it would be helpful if, after recording midi, the media item start and end were expanded (trimmed?) to the nearest bar on the grid.

This currently happens with retrospective record so I think it would be consistent for it to happen in normal record.

It would be a great timesaver when wanting to loop newly recorded midi items, IMHO, as I spend a lot of my time, post recording, triggering an action to expand the item.

If this isn't useful to some, then maybe an option?

Edit: Having thought about my discourse with Vitalker below, I now think "trim" is also relevant for both start and end of the item. Say you start recording before bar 3 but you don't actually play a note till the 2nd beat of bar 3. For me, the beginning of the item should be "trimmed" to the start of bar 3, not expanded to the beginning of bar 2. Same with the end ; You finish playing before the end of bar 3 but continue recording over the beginning of bar 4. I would want the item to be trimmed to the end of bar 3 rather than expanded to the end of bar 4.

Last edited by mozart999uk; 11-14-2022 at 09:04 AM. Reason: thought of something else
mozart999uk is offline   Reply With Quote
Old 10-25-2022, 03:56 AM   #2
vitalker
Human being with feelings
 
vitalker's Avatar
 
Join Date: Dec 2012
Posts: 13,333
Default

I support, but not trimming, just expanding to nearest, so no data is lost.
vitalker is online now   Reply With Quote
Old 10-25-2022, 04:03 AM   #3
mozart999uk
Human being with feelings
 
Join Date: Nov 2010
Posts: 1,737
Default

Quote:
Originally Posted by vitalker View Post
I support, but not trimming, just expanding to nearest, so no data is lost.
Yes indeed. Expanding is the better word 👍

Actually see above. I think "trim" as also relevant here not just "expand". Data will not be lost in the scenario I mention above.

Last edited by mozart999uk; 03-19-2023 at 10:46 AM. Reason: thought of something else
mozart999uk is offline   Reply With Quote
Old 10-25-2022, 04:18 AM   #4
vitalker
Human being with feelings
 
vitalker's Avatar
 
Join Date: Dec 2012
Posts: 13,333
Default

Quote:
Originally Posted by mozart999uk View Post
Yes indeed. Expanding is the better word 👍
Maybe rename the thread then.
vitalker is online now   Reply With Quote
Old 10-25-2022, 04:23 AM   #5
mozart999uk
Human being with feelings
 
Join Date: Nov 2010
Posts: 1,737
Default

Quote:
Originally Posted by vitalker View Post
Maybe rename the thread then.
OK. I wasn't going to as then it would make your comment look pointless. But I will.
mozart999uk is offline   Reply With Quote
Old 10-25-2022, 04:23 AM   #6
Daodan
Human being with feelings
 
Join Date: Jan 2011
Posts: 1,178
Default

+1!
Daodan is online now   Reply With Quote
Old 10-28-2022, 03:12 PM   #7
skylar_battles
Human being with feelings
 
Join Date: Mar 2022
Posts: 1,522
Default

+1
skylar_battles is offline   Reply With Quote
Old 11-05-2022, 07:57 AM   #8
hits_of_sunshine
Human being with feelings
 
Join Date: Mar 2017
Location: Tokyo
Posts: 73
Default

+1
hits_of_sunshine is offline   Reply With Quote
Old 11-07-2022, 06:53 AM   #9
V1b3zman
Human being with feelings
 
Join Date: Oct 2016
Posts: 101
Default

+1
V1b3zman is offline   Reply With Quote
Old 11-07-2022, 02:32 PM   #10
sockmonkey72
Human being with feelings
 
sockmonkey72's Avatar
 
Join Date: Sep 2021
Location: Berlin
Posts: 1,957
Default

This script will do the expansion of selected MIDI items -- I know that's not exactly what you want, but it's a "today" option, as opposed to a "possibly never" solution.

Let me know how it works for you...

Code:
-- sockmonkey72_ExtendMIDIItemToNearestBars.lua

local reaper = reaper

reaper.Undo_BeginBlock2(0)
local selectedItems = reaper.CountSelectedMediaItems(0)
for i = 0, selectedItems - 1 do
  local item = reaper.GetSelectedMediaItem(0, i)
  take = reaper.GetActiveTake(item)
  if take and reaper.TakeIsMIDI(take) then
    local pos = reaper.GetMediaItemInfo_Value(item, "D_POSITION")
    local len = reaper.GetMediaItemInfo_Value(item, "D_LENGTH")

    local _, startMeasures = reaper.TimeMap2_timeToBeats(0, pos)
    local endBeats, endMeasures, endCml = reaper.TimeMap2_timeToBeats(0, pos + len)
    if endBeats < 0.00001 then
      endCml = 0
    end
    local startOfMeasure = reaper.TimeMap2_beatsToTime(0, 0, startMeasures)
    local endOfMeasure = reaper.TimeMap2_beatsToTime(0, endCml, endMeasures)

    reaper.MIDI_SetItemExtents(item, reaper.TimeMap2_timeToQN(0, startOfMeasure), reaper.TimeMap2_timeToQN(0, endOfMeasure))
    reaper.MarkTrackItemsDirty(reaper.GetMediaItem_Track(item), item)
  end
end
reaper.Undo_EndBlock2(0, "Resize MIDI Item(s)", -1)
__________________
ReaPack Repository: right-click and copy index URL

Last edited by sockmonkey72; 11-08-2022 at 08:12 AM.
sockmonkey72 is online now   Reply With Quote
Old 11-08-2022, 04:32 AM   #11
mozart999uk
Human being with feelings
 
Join Date: Nov 2010
Posts: 1,737
Default

Hey thanks for that Sockmonkey.

As an interim fix, that works really well. 👍

I was using the me2beats script (trim sel items edge to nearest measure start) but I needed an expand rather than a trim,

Let's hope the devs see this thread and come up with a automatic solution :-)
mozart999uk is offline   Reply With Quote
Old 11-08-2022, 08:13 AM   #12
sockmonkey72
Human being with feelings
 
sockmonkey72's Avatar
 
Join Date: Sep 2021
Location: Berlin
Posts: 1,957
Default

Quote:
Originally Posted by mozart999uk View Post
Hey thanks for that Sockmonkey.

As an interim fix, that works really well. 👍

I was using the me2beats script (trim sel items edge to nearest measure start) but I needed an expand rather than a trim,

Let's hope the devs see this thread and come up with a automatic solution :-)
Thanks for letting me know. I've added the script to my ReaPack repos, in case it's more comfortable to grab from there.
__________________
ReaPack Repository: right-click and copy index URL
sockmonkey72 is online now   Reply With Quote
Old 11-08-2022, 08:34 AM   #13
mozart999uk
Human being with feelings
 
Join Date: Nov 2010
Posts: 1,737
Default

Excellent!
mozart999uk is offline   Reply With Quote
Old 11-08-2022, 09:30 AM   #14
R.Cato
Human being with feelings
 
Join Date: Dec 2020
Posts: 56
Default

+1
R.Cato is offline   Reply With Quote
Old 11-14-2022, 02:52 PM   #15
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,066
Default

Appreciate the script as well @sock.
But then again, some functionality should work as it should without trying to fix it with scripts. I already got so many fix-scripts running to adjust REAPERs behavior, it's not even funny anymore.
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 11-14-2022, 04:54 PM   #16
kamilbaranski1
Human being with feelings
 
Join Date: Apr 2021
Posts: 56
Default

+1 as we discussed before in https://forum.cockos.com/showthread.php?p=2368940 . That's the most logical and convenient way to work fast with MIDI.
kamilbaranski1 is offline   Reply With Quote
Old 12-21-2022, 01:19 AM   #17
Lloyd-Phillips
Human being with feelings
 
Join Date: Sep 2022
Posts: 6
Default

+1
Lloyd-Phillips is offline   Reply With Quote
Old 02-19-2023, 03:55 PM   #18
Skorobagatko
Human being with feelings
 
Skorobagatko's Avatar
 
Join Date: Mar 2017
Location: Ukraine, Kyiv
Posts: 546
Default

Quote:
Originally Posted by sockmonkey72 View Post
This script will do the expansion of selected MIDI items -- I know that's not exactly what you want, but it's a "today" option, as opposed to a "possibly never" solution.

Let me know how it works for you...

Code:
-- sockmonkey72_ExtendMIDIItemToNearestBars.lua

local reaper = reaper

reaper.Undo_BeginBlock2(0)
local selectedItems = reaper.CountSelectedMediaItems(0)
for i = 0, selectedItems - 1 do
  local item = reaper.GetSelectedMediaItem(0, i)
  take = reaper.GetActiveTake(item)
  if take and reaper.TakeIsMIDI(take) then
    local pos = reaper.GetMediaItemInfo_Value(item, "D_POSITION")
    local len = reaper.GetMediaItemInfo_Value(item, "D_LENGTH")

    local _, startMeasures = reaper.TimeMap2_timeToBeats(0, pos)
    local endBeats, endMeasures, endCml = reaper.TimeMap2_timeToBeats(0, pos + len)
    if endBeats < 0.00001 then
      endCml = 0
    end
    local startOfMeasure = reaper.TimeMap2_beatsToTime(0, 0, startMeasures)
    local endOfMeasure = reaper.TimeMap2_beatsToTime(0, endCml, endMeasures)

    reaper.MIDI_SetItemExtents(item, reaper.TimeMap2_timeToQN(0, startOfMeasure), reaper.TimeMap2_timeToQN(0, endOfMeasure))
    reaper.MarkTrackItemsDirty(reaper.GetMediaItem_Track(item), item)
  end
end
reaper.Undo_EndBlock2(0, "Resize MIDI Item(s)", -1)
is there any progress on this to make it work natively?
Skorobagatko is offline   Reply With Quote
Old 03-18-2023, 07:58 PM   #19
jonnyjupiter
Human being with feelings
 
jonnyjupiter's Avatar
 
Join Date: Jan 2022
Posts: 72
Default

Thanks sockmonkey. Does anyone happen to have a script to use this function on midi items from arrangement view, without having to go into the midi window?
__________________
website | youtube | imdb
jonnyjupiter is offline   Reply With Quote
Old 03-19-2023, 05:34 AM   #20
sockmonkey72
Human being with feelings
 
sockmonkey72's Avatar
 
Join Date: Sep 2021
Location: Berlin
Posts: 1,957
Default

Quote:
Originally Posted by jonnyjupiter View Post
Thanks sockmonkey. Does anyone happen to have a script to use this function on midi items from arrangement view, without having to go into the midi window?
That script should work fine from the arrangement view, it doesn't rely on the MIDI Editor at all. You just need to select the items you want modified.
__________________
ReaPack Repository: right-click and copy index URL
sockmonkey72 is online now   Reply With Quote
Old 03-19-2023, 10:47 AM   #21
mozart999uk
Human being with feelings
 
Join Date: Nov 2010
Posts: 1,737
Default

Just bumping this as I think it should work this way natively :-)
mozart999uk is offline   Reply With Quote
Old 03-19-2023, 10:47 AM   #22
mozart999uk
Human being with feelings
 
Join Date: Nov 2010
Posts: 1,737
Default

Quote:
Originally Posted by Skorobagatko View Post
is there any progress on this to make it work natively?
Not yet but I'm hoping it will attract the attention of the devs soon :-)
mozart999uk is offline   Reply With Quote
Old 03-19-2023, 10:48 AM   #23
mozart999uk
Human being with feelings
 
Join Date: Nov 2010
Posts: 1,737
Default

Quote:
Originally Posted by _Stevie_ View Post
Appreciate the script as well @sock.
But then again, some functionality should work as it should without trying to fix it with scripts. I already got so many fix-scripts running to adjust REAPERs behavior, it's not even funny anymore.
Agreed 100% :-)
mozart999uk is offline   Reply With Quote
Old 07-28-2023, 07:54 AM   #24
hits_of_sunshine
Human being with feelings
 
Join Date: Mar 2017
Location: Tokyo
Posts: 73
Default

Not yet?
hits_of_sunshine is offline   Reply With Quote
Old 08-01-2023, 01:20 AM   #25
mozart999uk
Human being with feelings
 
Join Date: Nov 2010
Posts: 1,737
Default

Nothing yet :-(
mozart999uk is offline   Reply With Quote
Old 08-02-2023, 06:12 AM   #26
inthevoid
Human being with feelings
 
inthevoid's Avatar
 
Join Date: May 2022
Location: London
Posts: 440
Default

+1 to this - relying on retroactive record at the moment with MIDI for this reason.
inthevoid is online now   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:06 AM.


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