Old 06-03-2018, 10:01 AM   #1
hanstheman
Human being with feelings
 
Join Date: Oct 2016
Posts: 32
Default Can't get undo block working for reaper.MIDI_InsertNote

Hey I'm making a script where I insert multiple midi notes.
I do
script_title = "MidiTest"
reaper.Undo_BeginBlock()
reaper.MIDI_SelectAll(cur_take, false)
GenerateScale()
reaper.Undo_EndBlock(script_title, 0)

local function GenerateScale()
for i, pitch in ipairs(pitchScaleList) do
reaper.MIDI_InsertNote(cur_take, true, false,
tickMap[i], tickMap[i]+firstNoteLength, firstNoteChan, pitch, firstNoteVel, true)
end
reaper.MIDI_Sort(cur_take)
end

I also tried with -1 as endblock flag but not working either..
When I disable Undo_BeginBlock() and EndBlock result is the same, so seems like the insert note function is not generating an undo point ??

Help needed! Thanks!
hanstheman is offline   Reply With Quote
Old 06-04-2018, 12:54 PM   #2
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,764
Default

Yep, there are some bugs in MIDI functions not triggering undo:
* Undo_ in ReaScript issue... SOLVED
* ReaScript: Undo_EndBlock with flags != -1 are not added to undo history
juliansader is offline   Reply With Quote
Old 06-04-2018, 10:42 PM   #3
hanstheman
Human being with feelings
 
Join Date: Oct 2016
Posts: 32
Default Thank you

Quote:
Originally Posted by juliansader View Post
Thank you so much! I got it working with the following code..

reaper.Undo_BeginBlock()
local item = reaper.GetMediaItemTake_Item(cur_take)
reaper.MarkTrackItemsDirty(reaper.GetMediaItemTake _Track(cur_take), item)
-- my code..
reaper.Undo_EndBlock(script_title, -1)
hanstheman 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 09:07 PM.


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