oriental = ""
mmm=""
local path = reaper.GetResourcePath()

oct = ""
newmeas = 0
newmeass = ""
poss2 = ""
M= ""
    local R = reaper.GetCursorPosition();

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

OOrccc, start= reaper.BR_Win32_GetPrivateProfileString("braille", "start", "nil", path .. "\\ini\\braille.ini")
num1, num2 = reaper.BR_Win32_GetPrivateProfileString("braille", "num", "nil", path .. "\\ini\\braille.ini")
ts1, ts2 = reaper.BR_Win32_GetPrivateProfileString("braille",Z1.. "b", "nil", path .. "\\ini\\braille.ini")
tts1, tts2 = reaper.BR_Win32_GetPrivateProfileString("braille",Z2.. "bb", "nil", path .. "\\ini\\braille.ini")
XXX = num2.. ts2 .. tts2 ..start.. " "


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


n1 = 1
    local _,notecnt,menaa,awadd = reaper.MIDI_CountEvts(take);
notecnt2  = notecnt  + menaa + awadd


    for i = 1,notecnt do;


        local retval, sel, mut, startppqpos, endppqpos, chan, pitch, vel = reaper.MIDI_GetNote(take,i-1);
    for k = n1,menaa do;

mm1,mm2,mm3,mm4,mm5,mm6,mm7,mm8,mm9 =  reaper.MIDI_GetCC(take,k-1) -- , _, _, startppqpos  );
oriental=""	
if (mm4 >= startppqpos) and  (mm4 <=endppqpos) then

if (mm8 < 52) and (mm8 > 40) then
OOc, oriental = reaper.BR_Win32_GetPrivateProfileString("braille", "oriental", "nil", path .. "\\ini\\braille.ini")
else

oriental=""
end
break


end

end

    for l = 1,awadd do;

 mm1,mm2,mm3,mm4,mm5,mm6,mm7 =  reaper.MIDI_GetTextSysexEvt(take,l-1)
mmm=""	
if (mm4 >= startppqpos) and  (mm4 <=endppqpos) then
mmm= mm6
pp =10
                local  OOO = string.reverse(mm6)
                local  OOR = string.match(string.reverse(OOO),".+",pp+1)
                local  OORR = string.reverse(OOR)

if mm6 =="TRAC dynamic crescendo len 1.000"  then
OOc, mmm = reaper.BR_Win32_GetPrivateProfileString("braille", "crescendo", "nil", path .. "\\ini\\braille.ini")
mmm= " ".. mmm.." "
elseif mm6 =="TRAC dynamic diminuendo len 1.000" then
OOc, mmm = reaper.BR_Win32_GetPrivateProfileString("braille", "Diminuendo", "nil", path .. "\\ini\\braille.ini")
mmm= " ".. mmm.." "
elseif mm6 =="NOTE 0 62 ornament up_bow" then
OOc, mmm = reaper.BR_Win32_GetPrivateProfileString("braille", "upBow", "nil", path .. "\\ini\\braille.ini")
mmm= " ".. mmm.." "

elseif mm6 =="NOTE 0 62 ornament down_bow" then
OOc, mmm = reaper.BR_Win32_GetPrivateProfileString("braille", "downBow", "nil", path .. "\\ini\\braille.ini")
mmm= " ".. mmm.." "
elseif mm6 =="NOTE 0 60 phrase 1 slur begin" then
OOc, mmm = reaper.BR_Win32_GetPrivateProfileString("braille", "phraseSlur0", "nil", path .. "\\ini\\braille.ini")
elseif mm6 =="NOTE 0 64 phrase 1 slur end" then
OOc, mmm = reaper.BR_Win32_GetPrivateProfileString("braille", "phraseSlur1", "nil", path .. "\\ini\\braille.ini")
elseif mm6 =="NOTE 0 62 phrase 1 slur continue" then
mmm= ""
elseif mm6 =="TRAC dynamic p" then
OOc, mmm = reaper.BR_Win32_GetPrivateProfileString("braille", "p", "nil", path .. "\\ini\\braille.ini")
mmm= " ".. mmm.." "
elseif mm6 =="TRAC dynamic pp" then
OOc, mmm = reaper.BR_Win32_GetPrivateProfileString("braille", "pp", "nil", path .. "\\ini\\braille.ini")
mmm= " ".. mmm.." "
elseif mm6 =="TRAC dynamic ppp" then
OOc, mmm = reaper.BR_Win32_GetPrivateProfileString("braille", "ppp", "nil", path .. "\\ini\\braille.ini")
mmm= " ".. mmm.." "
elseif mm6 =="TRAC dynamic pppp" then
OOc, mmm = reaper.BR_Win32_GetPrivateProfileString("braille", "pppp", "nil", path .. "\\ini\\braille.ini")
mmm= " ".. mmm.." "
elseif mm6 =="TRAC dynamic mp" then
OOc, mmm = reaper.BR_Win32_GetPrivateProfileString("braille", "mp", "nil", path .. "\\ini\\braille.ini")
mmm= " ".. mmm.." "
elseif mm6 =="TRAC dynamic f" then
OOc, mmm = reaper.BR_Win32_GetPrivateProfileString("braille", "f", "nil", path .. "\\ini\\braille.ini")
mmm= " ".. mmm.." "
elseif mm6 =="TRAC dynamic ff" then
OOc, mmm = reaper.BR_Win32_GetPrivateProfileString("braille", "ff", "nil", path .. "\\ini\\braille.ini")
mmm= " ".. mmm.." "
elseif mm6 =="TRAC dynamic fff" then
OOc, mmm = reaper.BR_Win32_GetPrivateProfileString("braille", "fff", "nil", path .. "\\ini\\braille.ini")
mmm= " ".. mmm.." "
elseif mm6 =="TRAC dynamic ffff" then
OOc, mmm = reaper.BR_Win32_GetPrivateProfileString("braille", "ffff", "nil", path .. "\\ini\\braille.ini")
mmm= " ".. mmm.." "
elseif mm6 =="TRAC dynamic mf" then
OOc, mmm = reaper.BR_Win32_GetPrivateProfileString("braille", "mf", "nil", path .. "\\ini\\braille.ini")
mmm= " ".. mmm.." "
elseif OORR ~= "" then
mmm = string.reverse(OORR)
mmm = " " .. mmm .. " "


else
mmm= mm6

















end
break













end

end







if (newmeas == -864) then
 newmeass = " "
newmeas = 0
else
 newmeass = ""
 end
        if (sel == true) and (mut == false) then
if (pitch >= 0) and (pitch <=11) and (oct ~= "a") then
OOc, O = reaper.BR_Win32_GetPrivateProfileString("braille", "oct1", "nil", path .. "\\ini\\braille.ini")
oct = "a"
elseif (pitch >= 12) and (pitch <=23)  and (oct ~= "b") then
OOc, O = reaper.BR_Win32_GetPrivateProfileString("braille", "oct1", "nil", path .. "\\ini\\braille.ini")
oct = "b"
elseif (pitch >= 23) and (pitch <=35)  and (oct ~= "c") then
OOc, O = reaper.BR_Win32_GetPrivateProfileString("braille", "oct1", "nil", path .. "\\ini\\braille.ini")
oct = "c"
elseif (pitch >= 35) and (pitch <=47)  and  (oct ~= "d") then
OOc, O = reaper.BR_Win32_GetPrivateProfileString("braille", "oct2", "nil", path .. "\\ini\\braille.ini")
oct = "d"
elseif (pitch >= 48) and (pitch <=59)  and   (oct ~= "e") then
OOc, O = reaper.BR_Win32_GetPrivateProfileString("braille", "oct3", "nil", path .. "\\ini\\braille.ini")
oct = "e"
elseif (pitch >= 60) and (pitch <=71)  and (oct ~= "f") then
OOc, O = reaper.BR_Win32_GetPrivateProfileString("braille", "oct4", "nil", path .. "\\ini\\braille.ini")
oct = "f"
elseif (pitch >= 72) and (pitch <=83)  and (oct ~= "g") then
OOc, O = reaper.BR_Win32_GetPrivateProfileString("braille", "oct5", "nil", path .. "\\ini\\braille.ini")
oct = "g"
elseif (pitch >= 84) and (pitch <=95)  and (oct ~= "h") then
OOc, O = reaper.BR_Win32_GetPrivateProfileString("braille", "oct6", "nil", path .. "\\ini\\braille.ini")
oct = "h"
elseif (pitch >= 96) and (pitch <=107)  and (oct ~= "i") then
OOc, O = reaper.BR_Win32_GetPrivateProfileString("braille", "oct7", "nil", path .. "\\ini\\braille.ini")
oct = "i"
elseif (pitch >= 108) and (pitch <=119)  and (oct ~= "j") then
OOc, O = reaper.BR_Win32_GetPrivateProfileString("braille", "oct10", "nil", path .. "\\ini\\braille.ini")
oct = "j"
elseif (pitch >= 120) and (pitch <=132)  and (oct ~= "k") then
OOc, O = reaper.BR_Win32_GetPrivateProfileString("braille", "oct11", "nil", path .. "\\ini\\braille.ini")
oct = "k"
else
O = ""
end

key = (pitch +12) %12
	if key == 1 then
kkc, key22 = reaper.BR_Win32_GetPrivateProfileString("braille", "DooDyiaz", "nil", path .. "\\ini\\braille.ini")
elseif key == 3 then
kkc, key22 = reaper.BR_Win32_GetPrivateProfileString("braille", "ReeDyiaz", "nil", path .. "\\ini\\braille.ini")
elseif key == 6 then
kkc, key22 = reaper.BR_Win32_GetPrivateProfileString("braille", "FaaDyiaz", "nil", path .. "\\ini\\braille.ini")
elseif key == 8 then
kkc, key22 = reaper.BR_Win32_GetPrivateProfileString("braille", "SolDyiaz", "nil", path .. "\\ini\\braille.ini")
elseif key == 10 then
kkc, key22 = reaper.BR_Win32_GetPrivateProfileString("braille", "LaaDyiaz", "nil", path .. "\\ini\\braille.ini")
else
key22 = ""
end
key22= oriental .. key22
poss = startppqpos-endppqpos 
if (key == 0) and (poss == -864) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "DooRond", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key  ==1 ) and (poss == -864) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "DooRond", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 2) and (poss == -864) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "ReeRond", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 3) and (poss == -864) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "ReeRond", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 4) and (poss == -864) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "MeeRond", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 5) and (poss == -864) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "FaaRond", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 6) and (poss == -864) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "FaaRond", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 7) and (poss == -864) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "SolRond", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 8) and (poss == -864) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "SolRond", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 9) and (poss == -864) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "LaaRond", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 10) and (poss == -864) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "LaaRond", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 11) and (poss == -864) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "SeeRond", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 0) and (poss == -432) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "DooBlansh", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key  ==1 ) and (poss == -432) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "DooBlansh", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 2) and (poss == -432) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "ReeBlansh", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 3) and (poss == -432) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "ReeBlansh", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 4) and (poss == -432) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "MeeBlansh", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 5) and (poss == -432) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "FaaBlansh", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 6) and (poss == -432) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "FaaBlansh", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 7) and (poss == -432) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "SolBlansh", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 8) and (poss == -432) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "SolBlansh", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 9) and (poss == -432) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "LaaBlansh", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 10) and (poss == -432) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "LaaBlansh", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 11) and (poss == -432) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "SeeBlansh", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 0) and (poss == -216) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "DooNoir", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key  ==1 ) and (poss == -216) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "DooNoir", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 2) and (poss == -216) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "ReeNoir", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 3) and (poss == -216) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "ReeNoir", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 4) and (poss == -216) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "MeeNoir", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 5) and (poss == -216) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "FaaNoir", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 6) and (poss == -216) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "FaaNoir", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 7) and (poss == -216) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "SolNoir", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 8) and (poss == -216) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "SolNoir", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 9) and (poss == -216) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "LaaNoir", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 10) and (poss == -216) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "LaaNoir", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 11) and (poss == -216) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "SeeNoir", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 0) and (poss == -64) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "DooRond", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key  ==1 ) and (poss == -64) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "DooRond", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 2) and (poss == -64) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "ReeRond", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 3) and (poss == -64) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "ReeRond", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 4) and (poss == -64) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "MeeRond", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 5) and (poss == -64) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "FaaRond", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 6) and (poss == -64) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "FaaRond", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 7) and (poss == -64) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "SolRond", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 8) and (poss == -64) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "SolRond", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 9) and (poss == -64) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "LaaRond", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 10) and (poss == -64) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "LaaRond", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 11) and (poss == -64) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "SeeRond", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 0) and (poss == -32) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "DooBlansh", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key  ==1 ) and (poss == -32) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "DooBlansh", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 2) and (poss == -32) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "ReeBlansh", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 3) and (poss == -32) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "ReeBlansh", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 4) and (poss == -32) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "MeeBlansh", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 5) and (poss == -32) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "FaaBlansh", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 6) and (poss == -32) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "FaaBlansh", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 7) and (poss == -32) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "SolBlansh", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 8) and (poss == -32) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "SolBlansh", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 9) and (poss == -32) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "LaaBlansh", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 10) and (poss == -32) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "LaaBlansh", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 11) and (poss == -32) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "SeeBlansh", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 0) and (poss == -16) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "DooNoir", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key  ==1 ) and (poss == -16) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "DooNoir", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 2) and (poss == -16) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "ReeNoir", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 3) and (poss == -16) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "ReeNoir", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 4) and (poss == -16) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "MeeNoir", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 5) and (poss == -16) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "FaaNoir", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 6) and (poss == -16) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "FaaNoir", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 7) and (poss == -16) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "SolNoir", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 8) and (poss == -16) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "SolNoir", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 9) and (poss == -16) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "LaaNoir", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 10) and (poss == -16) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "LaaNoir", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 11) and (poss == -16) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "SeeNoir", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 0) and (poss == -108) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "DooQroch", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key  ==1 ) and (poss == -108) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "DooQroch", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 2) and (poss == -108) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "ReeQroch", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 3) and (poss == -108) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "ReeQroch", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 4) and (poss == -108) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "MeeQroch", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 5) and (poss == -108) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "FaaQroch", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 6) and (poss == -108) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "FaaQroch", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 7) and (poss == -108) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "SolQroch", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 8) and (poss == -108) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "SolQroch", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 9) and (poss == -108) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "LaaQroch", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 10) and (poss == -108) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "LaaQroch", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (key == 11) and (poss == -108) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "SeeQroch", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
else
poss2  = ""


end
M = M..mmm.. newmeass.. O .. key22 ..poss2

end
        if (sel == true) and (mut == true) then
poss = startppqpos-endppqpos 
if (poss == -864) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "SilenceRond", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (poss == -432) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "SilenceBlansh", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
elseif (poss == -216) then
ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "SilenceNoir", "nil", path .. "\\ini\\braille.ini")

newmeas = newmeas + poss
elseif (poss == -108) then

ppc, poss2 = reaper.BR_Win32_GetPrivateProfileString("braille", "SilenceQroch", "nil", path .. "\\ini\\braille.ini")
newmeas = newmeas + poss
else
poss2  = ""
end
M = M ..poss2
end






           end




OOccc, end2= reaper.BR_Win32_GetPrivateProfileString("braille", "end", "nil", path .. "\\ini\\braille.ini")
url =XXX .. M..end2


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


   retval, file = reaper.JS_Dialog_BrowseForSaveFile( "Export MidiItems to Braille File", '', "", '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)
	




