Old 12-14-2017, 09:41 AM   #1
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default Issue with CC toggle selection

Hey all,

I'm working on a toggle select CC X script. Selecting works great, however unselecting is still a bit buggy. I can't seem to find the issue here.
The code looks okay to me. Maybe someone can help?

Here's what's happening:

- I select all CC1 events
- then I select all CC2 events
- again executing the toggle CC1 script, to deselect CC1
= only one CC event gets deselected and that's the one missing in CC2

I somehow seem to be missing some condition.



Code:
for i = 0, reaper.CountSelectedMediaItems(0)-1 do -- loop through all selected items
    item = reaper.GetSelectedMediaItem(0, i)
    for t = 0, reaper.CountTakes(item)-1 do -- Loop through all takes within each selected item
        take = reaper.GetTake(item, t)
        if reaper.TakeIsMIDI(take) then -- make sure, that take is MIDI
            _, _, ccCount, _ = reaper.MIDI_CountEvts(take) -- count CCs and save amount to "ccCount"
            for c = 0, ccCount-1 do -- loop thru all CCs
                _, selected, _, _, _, _, cc, _ = reaper.MIDI_GetCC(take, c) -- get values from CCs
                if cc == 1 and selected == false then -- if CC is CC1 and CC1 is not selected
					reaper.MIDI_SetCC(take, c, true, nil, nil, nil, nil, nil, nil, nil) -- select CC1
					reaper.ShowConsoleMsg(c.."  ".."CC"..cc.."  "..tostring(selected).."\n")
				elseif cc == 1 and selected == true then -- if CC is CC1 and CC1 is selected
					reaper.MIDI_SetCC(take, c, false, nil, nil, nil, nil, nil, nil, nil) -- unselect CC1
					reaper.ShowConsoleMsg(c.."  ".."CC"..cc.."  "..tostring(selected).."\n")
                
				end
            end
        end
    end
end
_Stevie_ is offline   Reply With Quote
Old 12-14-2017, 09:51 AM   #2
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

I think I found the problem. I have to set noSort = true.
Will check, if this solves it completely.

EDIT: yep, solved! However, I have no idea what this function does

Last edited by _Stevie_; 12-14-2017 at 09:58 AM.
_Stevie_ 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 06:17 PM.


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