Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Bug Reports

Reply
 
Thread Tools Display Modes
Old 10-15-2019, 07:17 PM   #1
pcartwright
Human being with feelings
 
Join Date: Jan 2009
Posts: 1,030
Default Bug: MIDIEditor_GetTake between Arrange View and MIDI Editor Selection

I noticed that a separate script that I'm developing wouldn't always update to the correct track. I made a mini script following similar logic (I'm not a programmer, so I may be off basis in my execution... if so, my apologies).

Here's the basic script:
Code:
function Msg(parameter)
     reaper.ShowConsoleMsg(tostring(parameter).."\n")
end


function Main()
  projState = reaper.GetProjectStateChangeCount(0)
  -- if the project has changed then
  if (projState ~= oldProjState) then
      -- get active midi
      editor = reaper.MIDIEditor_GetActive()
      -- get take active in midi editor
      itemTake = reaper.MIDIEditor_GetTake(editor)
      -- get track of take in midi editor
      track = reaper.GetMediaItemTake_Track(itemTake)
      -- display results
      Msg("---------------------------")
      Msg("Editor: " .. tostring(editor))
      Msg("Item Take: " .. tostring(itemTake))
      Msg("Track: ".. tostring(track)) 
      Msg("---------------------------")      

  end
  oldProjState = projState
  reaper.defer(Main)
end

--Create window
gfx.init("Test", 300, 300, dockState, 50, 50)

--Get initial project state
projState = reaper.GetProjectStateChangeCount(0)
oldProjState = -1
Main()
The intent of the code is to reference the track being edited in the MIDI editor whenever a change is made in the Reaper project. This action updates GUI options in my other script, but the overall logic is similar for track selection here.

I have the following MIDI editor settings:
Using one MIDI editor per project
Behavior for "open items in built-in MIDI editor" (Open all MIDI in the project)
Active MIDI item follows selection changes in arrange view (selected)
Media item selection is linked to visibility (selected)
Selection is linked to editability (selected)
Close editor when the active item is deleted in the arrange view (not selected)

Steps to test: For the test, I created two tracks in an otherwise blank project and added blank MIDI items of one measure to both tracks.

First, I tried toggling between media items in arrange view by clicking on alternate items, the itemTake that was returned did not always match the selection:

Code:
-- ARRANGE VIEW
-- Click on media item in track 1
---------------------------
Editor: userdata: 00000000011A07E2
Item Take: userdata: 00000000079229F0
Track: userdata: 00000000030A0080
---------------------------

-- Click on media item in track 2 (Item Take is different as expected)
---------------------------
Editor: userdata: 00000000011A07E2
Item Take: userdata: 00000000079219F0
Track: userdata: 0000000003140910
---------------------------

-- Click on media item in track 1 (Item Take has not changed)
---------------------------
Editor: userdata: 00000000011A07E2
Item Take: userdata: 00000000079219F0
Track: userdata: 0000000003140910
---------------------------

-- Click on media item in track 2
---------------------------
Editor: userdata: 00000000011A07E2
Item Take: userdata: 00000000079219F0
Track: userdata: 0000000003140910
---------------------------

Next, I tried toggling between tracks in the MIDI editor. This worked as expected.
Code:
-- MIDI EDITOR
-- Click on track 1 in MIDI editor track list
---------------------------
Editor: userdata: 00000000011A07E2
Item Take: userdata: 00000000079229F0
Track: userdata: 00000000030A0080
---------------------------

-- Click on track 2 in MIDI editor track list
---------------------------
Editor: userdata: 00000000011A07E2
Item Take: userdata: 00000000079219F0
Track: userdata: 0000000003140910
---------------------------

-- Click on track 1 in MIDI editor track list
---------------------------
Editor: userdata: 00000000011A07E2
Item Take: userdata: 00000000079229F0
Track: userdata: 00000000030A0080
---------------------------

-- Click on track 2 in MIDI editor track list
---------------------------
Editor: userdata: 00000000011A07E2
Item Take: userdata: 00000000079219F0
Track: userdata: 0000000003140910
---------------------------
Expected behavior: With the "Active MIDI item follows selection changes in arrange view" option selected, I would expect that toggling between MIDI items in both Arrange View and MIDI Editor would generate the same results from the script provided.
pcartwright is offline   Reply With Quote
Old 10-18-2019, 02:14 PM   #2
pcartwright
Human being with feelings
 
Join Date: Jan 2009
Posts: 1,030
Default

So... can nobody replicate this? It's very possible that I messed up something when calling the functions, so I'd appreciate it if someone pointed out my error if it exists.
pcartwright 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 01:57 PM.


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