
poss2 = ""
M= ""
    local R = reaper.GetCursorPosition();

Z1, Z2, Z3 = reaper.TimeMap_GetTimeSigAtTime(0,R)

XXX = Z1 .. "/" .. Z2


local function RemoveFileExt(file)
  local index = (file:reverse()):find("%.")
  if index > 0 then
    return string.sub(file, 1, #file-index)
  else
    return file
  end
end

-- Function for opening a URL

function export(f, variable)
  f:write(variable)
  f:write("\n")
end


function OpenURL(url)
  local OS = reaper.GetOS()
  if OS == "OSX32" or OS == "OSX64" then
    os.execute('open "" "' .. url .. '"')
  else
    os.execute('start "" "' .. url .. '"')
  end
end

function Msg(str)
  reaper.ClearConsole()
  reaper.ShowConsoleMsg(tostring(str) .. "\n")
end


    local midieditor = reaper.MIDIEditor_GetActive();

--    if not midieditor then return end;




    local take = reaper.MIDIEditor_GetTake(midieditor);



    local _,notecnt,mena,awad = reaper.MIDI_CountEvts(take);
notecnt2= notecnt+mena+awad 
    for i = 1,notecnt do;
        local retval, sel, mut, startppqpos, endppqpos, chan, pitch, vel = reaper.MIDI_GetNote(take,i-1);
        if sel == true then
if (pitch >= 0) and (pitch <=11) then   
O = "-1"
elseif (pitch >= 12) and (pitch <=23) then   
O = "0"
elseif (pitch >= 23) and (pitch <=35) then   
O = "1"
elseif (pitch >= 35) and (pitch <=47) then   
O = "2"
elseif (pitch >= 48) and (pitch <=59) then   
O = "3"
elseif (pitch >= 60) and (pitch <=71) then   
O = "4"
elseif (pitch >= 72) and (pitch <=83) then   
O = "5"
elseif (pitch >= 84) and (pitch <=95) then   
O = "6"
elseif (pitch >= 96) and (pitch <=107) then   
O = "7"
elseif (pitch >= 108) and (pitch <=119) then   
O = "8"
elseif (pitch >= 120) and (pitch <=132) then   
O = "9"
end
key = (pitch +12) %12
	if key == 0 then
key22 =  " Doo"
elseif key == 1 then
key22 =  " DooDyiaz"
elseif key == 2 then
key22 =  " Ree"
elseif key == 3 then
key22 =  " ReeDyiaz"
elseif key == 4 then
key22 =  " Mee"
elseif key == 5 then
key22 =  " Faa"
elseif key == 6 then
key22 =  " FaaDyiaz"
elseif key == 7 then
key22 =  " Sol"
elseif key == 8 then
key22 =  " SolDyiaz"
elseif key == 9 then
key22 =  " Laa"
elseif key == 10 then
key22 =  " LaaDyiaz"
elseif key ==11  then
key22 =  " See"
end
poss = startppqpos-endppqpos 
if (poss == -864) then
poss2 = " rund "
elseif (poss == -432) then
poss2 = " blansh "
elseif (poss == -216) then
poss2 = " noir "
elseif (poss == -108) then
poss2 = " qroech "
elseif (poss == -64) then
poss2 = " Dupple Qroech "
elseif (poss == -32) then
poss2 = " triple Qroech "
elseif (poss == -16) then
poss2 = " qua triple "
end

M = M .. key22 ..poss2 .. " octave " .. O .. "\n"





           end

        end
url =XXX .."\n" .. M


  local date, proj, projfn = '', reaper.EnumProjects(0, "")
 


   retval, file = reaper.JS_Dialog_BrowseForSaveFile( "Export MidiItems to TextFile", '', "", 'TextFile(.txt)\0*.txt\0All Files (*.*)\0*.*\0' )
  
   if retval and file ~= '' then
    if not file:find('.txt') then file = file .. ".txt" end

--   local fn = RemoveFileExt(projfn)..".txt"
   local fn =file
    local file = io.open(fn, "w")
    file:write(url)
    file:close()
end






--        retvalx, preset = reaper.GetUserInputs("know midi of item", 1, "", url)
--reaper.CF_SetClipboard(url)