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

Quote:
Originally Posted by SymboliC View Post
Hi,

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

Code:
--[[////////////// pLaMuK ///////////////////////////////////
if no item under edit cursor, create midi item.
please contact me on the forums with any improvements.
discussion: http://forum.cockos.com/showthread.php?p=1520818&posted=1#post1520818
//////////////////////////////////////////////////////--]]

--written in LUA. learn REASCRIPT--http://extremraym.com/en/learn-reascript-reaper/
--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)    
    
  end
  
  reaper.Undo_EndBlock("create midi item under mouse cursor if none exists", 0) 
end

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

Code:
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    
);

do_actions_from_main_and_midi_sections();
__________________
using REAPER as host/arranger/sequencer to write instrumental beat music.
striving for a loop-based, controller-centric midi recording/editing workflow.
justice and equality for editable secondary midi items!
mccrabney is online now   Reply With Quote