View Single Post
Old 11-12-2018, 05:10 AM   #2
Human being with feelings
mccrabney's Avatar
Join Date: Aug 2015
Location: Barrph, NY
Posts: 2,389

Originally Posted by SymboliC View Post

When one MIDI editor per project is used and several midi items from different tracks are opened in the editor/notation view, is it possible to quickly switch between/activate tracks by a shortcut?

It would be nice if a switching is possible between active tracks by a button press. Anyone know a way to make it so?
my default project starts with 8 channels of midi for melodic instrumentation and a 9th for percussive midi.

the tracks are all set up, and i use the side buttons on my launchpad to switch between them -- single press to switch to that channel/select the track, double press to open the midi on that track, and longpress to show fx chain for that track.

here's my "open midi item" custom action and the script it uses within...

1- sws: show selected track in TCP
2- script 1: create midi item under edit cursor if none exists (NOTE--this assumes you've already selected your intended midi track)
3- Xen/sws - select items under edit cursor on selected track
4- script 2: open midi editor / run midi editor action
5- select all items on track

script 1: create midi item under edit cursor if none exists

--[[////////////// pLaMuK ///////////////////////////////////
if no item under edit cursor, create midi item.
please contact me on the forums with any improvements.

--written in LUA. learn REASCRIPT--
--script v. 1.0
--todo: tempo-calculated item endpoint (X 1/4notes)
--followup script that checks midi item for contents, and if none, deletes it

-- reaper.ShowConsoleMsg(tostring("test").."\n")

function is_edit_cursor_on_item() 
  reaper.Undo_BeginBlock() --Begining of the undo block.
  selected_tracks_count = reaper.CountSelectedTracks(0)
  cursor_pos = reaper.GetCursorPosition() --edit cursor position
  no_edit_cursor = 0 --number of tracks that DON'T contain the edit cursor

  for i = 0, selected_tracks_count-1  do  -- LOOP THROUGH SELECTED TRACKS
    track_sel = reaper.GetSelectedTrack(0, i)
    item_num = reaper.CountTrackMediaItems(track_sel)

    for j = 0, item_num-1 do -- LOOP THROUGH MEDIA ITEMS
      item = reaper.GetTrackMediaItem(track_sel, j)
      start_pos = reaper.GetMediaItemInfo_Value(item, "D_POSITION");
      end_pos = start_pos + reaper.GetMediaItemInfo_Value(item, "D_LENGTH");
           --now, count how many items don't contain edit cursor:
        if cursor_pos >= start_pos and cursor_pos <= end_pos 
          then --do nothing. consider editing to DELETE item if no midi events counted.     
          else no_edit_cursor = no_edit_cursor + 1
        end --end item count
    end -- ENDLOOP through selected items
  end -- ENDLOOP through selected tracks
  if no_edit_cursor == item_num   --- check to see if # of items w/out edit cursor == total
    then reaper.CreateNewMIDIItemInProj(track_sel, cursor_pos, cursor_pos+1)

    reaper.Main_OnCommandEx(reaper.NamedCommandLookup( "_ecc87463a4710b46a8843a0dbe767187"), 0, 0)    
  reaper.Undo_EndBlock("create midi item under mouse cursor if none exists", 0) 

is_edit_cursor_on_item() -- Execute your main function
reaper.UpdateArrange() -- Update the arrangement (often needed)
script 2: open midi editor / run midi editor action (NOTE - comment out anything here you don't need regarding zoom/fold/etc

function do_actions_from_main_and_midi_sections()
   Main_OnCommand(40153, 0); // MAIN section action 40153: "open selected item in MIDI editor"
   active_MIDI_editor = MIDIEditor_GetActive(); // Now the MIDI editor is opened -> get MIDI editor ID
  MIDIEditor_OnCommand(active_MIDI_editor, 40799); // other midi on track (doesn't work in script)
  //MIDIEditor_OnCommand(active_MIDI_editor, 40452); // show all note rowss40466
  MIDIEditor_OnCommand(active_MIDI_editor, 40453); // hide unused note row
  MIDIEditor_OnCommand(active_MIDI_editor, 40006); // select all events
  MIDIEditor_OnCommand(active_MIDI_editor, 40725); // zoom to selected notes
  MIDIEditor_OnCommand(active_MIDI_editor, 40214); // deselect all
  MIDIEditor_OnCommand(active_MIDI_editor, 40466); // zoom to content    

using REAPER as host/arranger/sequencer to write instrumental beat music.
striving for a loop-based, controller-centric midi recording/editing workflow.
FR- option: disallow overlapping midi items in track (trim behind, ala AI)
mccrabney is offline   Reply With Quote