-- Delete notes at specific positions --nwcut.status = nwcut.const.rc_Report -- $NWCUT$CONFIG: ClipText $ if nwcut.getprop("Mode") ~= nwcut.const.mode_ClipText then error("Invalid input mode...this tool requires single staff clip text") end nwcut.setlevel(1) function addPos(pos, toBeKept) if pos ~= nil then for notepos in string.gmatch(pos, "[^,]+") do toBeKept[notepos] = 1 end end end function matchingPos(toBeKept, pos) local result = "" for notepos in string.gmatch(pos, "[^,]+") do if toBeKept[notepos] ~= nil then result = result .. "," .. notepos end end return string.sub(result, 2) end local positionsToBeKept for item in nwcut.items() do if item:IsFake() then -- ignore elseif not item:ContainsNotes() then nwcut.writeline(item) elseif positionsToBeKept == nil then nwcut.writeline(item) positionsToBeKept = {} addPos(item:Get('Pos'), positionsToBeKept) addPos(item:Get('Pos2'), positionsToBeKept) else local pos = matchingPos(positionsToBeKept, item:Get('Pos')) local pos2 = matchingPos(positionsToBeKept, item:Get('Pos2') or "") if pos == "" then pos = pos2 pos2 = "" end if pos == "" then rest = "|Rest|Dur:" .. item:Get('Dur') nwcut.writeline(rest) else item:Set('Pos', pos) if pos2 ~= "" then item:Set('Pos2', pos2) else item.Opts["Pos2"]=nil end nwcut.writeline(item) end end end