View Single Post
Old 12-07-2019, 08:40 AM   #18
Human being with feelings
Breeder's Avatar
Join Date: Nov 2010
Location: Croatia
Posts: 2,284

Originally Posted by _Stevie_ View Post
This is only partly related, I know... But since this is about viewport and MIDI editor:

could we have a way to center the MIDI content horizontally? Or some other solution? The issue is: when recording new notes, very high or low, on first open of an item, the MIDI editor usually doesn't show these events and I need to scroll a lot to make them visible. I can post a GIF later.
Originally Posted by Klangfarben View Post
+1 This is very much needed.
Something like View: Zoom to content but version that acts on selected notes only for example?

If you work on the piano part with extreme lows and high, there isn't any API or action to zoom in to selected notes vertically. I personally just split items and then use this script to do it. (It's almost a reflex by now to do ctrl+a and then alt+e (which calls the script) upon opening any MIDI item):

-- Main ----------------------------------------------------------------------------------------------------------------
function Main ()

	local undoMsg = "MIDI Editor: Zoom to content and selection/time selection/loop iteration"

	local midiEditor = reaper.MIDIEditor_GetActive()
	if midiEditor ~= nil then
		local take = reaper.MIDIEditor_GetTake(midiEditor)
		if take ~= nil then

			reaper.MIDIEditor_LastFocused_OnCommand(40466, false) -- View: Zoom to content

			if reaper.MIDI_EnumSelEvts(take, -1) ~= -1 then
				reaper.MIDIEditor_LastFocused_OnCommand(40725, false) -- View: Zoom to selected notes/CC

				local timeSelStart, timeSelEnd = reaper.GetSet_LoopTimeRange(false, false, 0, 0, false)
				if timeSelStart ~= timeSelEnd then
					reaper.MIDIEditor_LastFocused_OnCommand(40726, false) -- View: Zoom to project loop selection
					reaper.MIDIEditor_LastFocused_OnCommand(40468, false) -- View: Zoom to one loop iteration
			reaper.Undo_OnStateChangeEx2(0, undoMsg, 8, -1);

function NoUndoPoint () end -- Makes sure there is no unnecessary undo point created, see more
reaper.defer(NoUndoPoint)   -- here:
Would be nice to have an option so this is done automatically too

Last edited by Breeder; 12-07-2019 at 08:46 AM.
Breeder is offline   Reply With Quote