Old 02-13-2019, 06:39 PM   #1
meta
Human being with feelings
 
Join Date: Sep 2018
Posts: 29
Default API: MIDI_SetNote affects nearby note

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)

Last edited by meta; 02-13-2019 at 07:35 PM.
meta is offline   Reply With Quote
Old 02-21-2019, 05:54 AM   #2
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,372
Default

This is unfortunately an inevitable side-effect of the way REAPER stores MIDI data, and scripts should take precautions.

The problems with overlapping notes have been discussed in several threads in the MIDI subforum and the Bug report subforum, and these discussions will give you a good overview of the issue. For example: MIDI overlapping note issue.
juliansader 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 05:15 PM.


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