Old 06-04-2019, 02:50 PM   #1
Roger Heathcote
Human being with feelings
Join Date: Sep 2018
Posts: 6
Default reascript: The MIDI data before D_POSITION

So for each MIDI clip in a given track I am creating a blank clip with matching start time and length on the track below. I then copy the notes from the source item's current take to the destination, applying some processing to each note. I don't need cc information or anything like that, just raw notes. Anyway that is all working fine on nice vanilla MIDI clips but it all comes apart on clips that have been split.

The problem is reaper.GetMediaItemInfo_Value with D_POSITION tells me where the source item's left edge (effective start point) is on the timeline BUT the item itself has MIDI data before that point i.e. you can grab the left edge and drag it left to reveal notes before that point. However MIDI_GetNote gives me note positions as ppq starting from zero (the actual start point) and seems to have no concept of the "effective" start point.

Ideally I need to get the item's "actual" start point in seconds (were it fully unfurled) on the timeline, create a new clip starting at the actual start, copy all the notes to the new item, then adjust that item's "effective" start and end points to match the source clip.

I've spent a couple of hours staring at the API docs now and I can't see how I can accomplish this. I can't see anything that embodies the concept of an "actual" start or end point at all but maybe I just don't know the right term for such a thing yet.

I guess the other way to accomplish this would be to use the built in actions to copy the item then remove the cc data etc and process/move the notes in place but that feels kinda kludgey to me so I'd rather do it this way if that's possible.

Help please! Happy to post the code if that is helpful.
Roger Heathcote is offline   Reply With Quote
Old 06-04-2019, 02:55 PM   #2
Human being with feelings
Lokasenna's Avatar
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,257

I believe you're looking for:
 reaper.GetMediaItemTakeInfo_Value( take, parmname )
D_STARTOFFS : double *, start offset in take of item
Lokasenna is offline   Reply With Quote
Old 06-04-2019, 03:24 PM   #3
Roger Heathcote
Human being with feelings
Join Date: Sep 2018
Posts: 6

Aha fantastic! That looks like exactly what I need Thanks for the super quick response!
Roger Heathcote is offline   Reply With Quote

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 11:47 AM.

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