local REMOVE_PITCH_N = {1,3,5,6,8,10}--Высоту указанной ноты через запятую, обязательно в фигурных скобках
local DEL_NOTE_RAD = 1 -- в каком радиусе искать ноту (установить отступ 0 точно 1,2,30 и т.д. это отступ в каждую сторону )
local NAME_TRACK = "test"
local NAME_ITEM = -1 -- -1 looking for item with name track, otherwise enter "item name"
local POSITIOT_NOTE = 1 -- 0 editCur / 1 mouseCur
local LENGTH_NOTE = 0.468 -- длина ноты
local SELECTED = true -- true / false
local MUTED = false -- true / false
local CHAN = 1 -- 1 - 16
local PITCH = 0 -- 0 - 127 / 12*3+2
local VELOCITY = 100 -- 0 - 127
local function remNote(Take,startppqpos,DEL_NOTE_RAD,REMOVE_PITCH_N);
local _, notecnt,_,_ = reaper.MIDI_CountEvts(Take);
for i = notecnt-1,0,-1 do;
local retval,selected,muted,startppq,endppq,chan,pitch,vel = reaper.MIDI_GetNote(Take,i);
if startppq > startppqpos - DEL_NOTE_RAD and startppq < startppqpos + DEL_NOTE_RAD then;
for i2 = 1,#REMOVE_PITCH_N do;
if pitch == REMOVE_PITCH_N[i2]-1 then;
reaper.MIDI_DeleteNote(Take,i);
end;
end;
end;
end;
end;
----------------------------------------------
--local selTrack = reaper.GetSelectedTrack(0,0);
--if not selTrack then return end;
----------------------------------------------
local CountTracks = reaper.CountTracks(0)
for i = 1, CountTracks do
local Track = reaper.GetTrack(0,i-1);
local _, Name = reaper.GetSetMediaTrackInfo_String(Track,"P_NAME",0,0);
if Name == NAME_TRACK then
reaper.SetTrackSelected(Track,1)
selTrack = Track
break
end
end
if not selTrack then return end;
----------------------------------------------
if POSITIOT_NOTE == 0 then
PosMouseCur = reaper.GetCursorPosition();
elseif POSITIOT_NOTE == 1 then
PosMouseCur = reaper.BR_PositionAtMouseCursor(true);
if PosMouseCur < 0 then return end;
else
return
end
if type(PosMouseCur) ~= "number" then return end
local TrackName
if NAME_ITEM == -1 then
retval, TrackName = reaper.GetSetMediaTrackInfo_String(selTrack,"P_NAME",0,0);
else
TrackName = NAME_ITEM
end
local CountTrItem = reaper.CountTrackMediaItems(selTrack);
for i = 1,CountTrItem do;
local Item = reaper.GetTrackMediaItem(selTrack,i-1);
local PosIt = reaper.GetMediaItemInfo_Value(Item,"D_POSITION");
local LinIt = reaper.GetMediaItemInfo_Value(Item,"D_LENGTH");
if PosIt <= PosMouseCur and PosIt + LinIt > PosMouseCur then
reaper.SetMediaItemInfo_Value(Item,"B_UISEL",1);
local CountTake = reaper.CountTakes(Item);
for i2 = 1,CountTake do;
local Take = reaper.GetMediaItemTake(Item,i2-1);
local retval,TakeName = reaper.GetSetMediaItemTakeInfo_String(Take,"P_NAME",0,0);
if TakeName == TrackName then
----
local startppqpos = reaper.MIDI_GetPPQPosFromProjTime(Take, PosMouseCur );
local endppqpos = reaper.MIDI_GetPPQPosFromProjTime(Take, PosMouseCur+LENGTH_NOTE);
-----
remNote(Take,startppqpos,DEL_NOTE_RAD,REMOVE_PITCH_N)
-----
reaper.MIDI_InsertNote
(Take,SELECTED,MUTED,startppqpos,endppqpos,CHAN-1,PITCH,VELOCITY,false)
end;
end;
end;
end;
---------------------------------------------------------------