When using MIDI_SetNote to alter a note whose position is within another note's length, and both notes have the same pitch, the original note's end position gets completely messed up.
Here's a video of it happening:
https://imgur.com/a/G9tuIDA
Look at the length of the red note.
Here's the code:
Code:
reaper.PreventUIRefresh(1)
reaper.Undo_BeginBlock()
local item = reaper.GetSelectedMediaItem(0, 0)
local take = reaper.GetActiveTake(item)
local retval, selected, muted, startpos, endpos, channel, pitch, velocity = reaper.MIDI_GetNote(take, 0)
-- create new note placed 50 ppq away from the original
reaper.MIDI_InsertNote(take, false, muted, startpos + 50, endpos + 50, channel, pitch,
velocity, false)
-- alter the new note
reaper.MIDI_SetNote(take, 1, false, muted, startpos + 50, endpos + 50,
channel + 1, pitch, velocity, false)
reaper.Undo_EndBlock('Note bug test', 0)
reaper.PreventUIRefresh(-1)
reaper.UpdateArrange()
reaper.UpdateTimeline()
reaper.TrackList_AdjustWindows(-1)