View Single Post
Old 06-04-2017, 05:50 AM   #1189
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 493
Default

Quote:
Originally Posted by reddiesel41264 View Post
Selecting notes in the notation editor does not select the CC data connected to those notes, this is a very big problem when copying and pasting notes between staves.
I've come up with a temporary solution for this which will solve the issue for copying and pasting and maybe some other scenarios. Make a custom action and include the lua script below, followed by the standard edit->copy action. Then assign it ctrl+c as a shortcut (or whatever you want).

Code:
--[[ 
* ReaScript Name: MIDI Select All CC Events Under Selected Notes
* Version: 04/06/2017
* Author: David Healey.
--]] 

take = reaper.MIDIEditor_GetTake(reaper.MIDIEditor_GetActive()) --Get active take

if take ~= nil then
	
	reaper.Undo_BeginBlock();

	retval, notes, ccs, sysex = reaper.MIDI_CountEvts(take) --Count note and cc evens

	for n = 0, notes, 1 do --Each note event

		retval, n_selected, n_muted, n_ppq, n_endppq, n_chan, pitch, vel = reaper.MIDI_GetNote(take, n); --Get note data

		if n_selected == true then --If this note is selected

			for c = 0, ccs, 1 do --Each CC event
				retval, c_selected, c_muted, c_ppq, c_chanmsg, c_chan, msg2, msg3 = reaper.MIDI_GetCC(take, c) --Get CC data

				--If the CC ppq is within the note's start and end ppq
				if c_ppq >= n_ppq and c_ppq < n_endppq then
					reaper.MIDI_SetCC(take, c, true, NULL, NULL, NULL, NULL, NULL, NULL, true); --Set CC as selected
				end
			end

		end

	end
end

reaper.MIDI_Sort(take)
reaper.Undo_EndBlock("MIDI Select All CC Events Under Selected Notes",-1);
reaper.UpdateArrange();
__________________
http://librewave.com - Freedom respecting instruments and effects
http://xtant-audio.com/ - Purveyor of fine sample libraries (and Kontakt scripting tutorials)
reddiesel41264 is offline   Reply With Quote