oriental = ""
mmn=""
couuu=0
couu = 0
mmmm=""
mmm=""
local mooner =" "
newmenu = ""
local path = reaper.GetResourcePath()
local NameFile ="Notes, Octaves and duration names"
local  pathfull =path .. "\\ini\\" .. NameFile .. ".ini"
poss2 = ""
M= ""
local timer2 =  reaper.NamedCommandLookup("_OSARA_NEXTNOTE")
reaper.osara_outputMessage(M)
    local midieditor = reaper.MIDIEditor_GetActive();
 reaper.MIDIEditor_OnCommand(midieditor, timer2)
--    if not midieditor then return end;




    local take = reaper.MIDIEditor_GetTake(midieditor);



    local _,notecnt,menaa,awadd = reaper.MIDI_CountEvts(take);
    for h = 1,notecnt do;
couu=0
        local retval, sel, mut, startppqpos, endppqpos, chan, pitch, vel = reaper.MIDI_GetNote(take,h-1);
        if (sel == true) and (mut == false) then
couu=couu+1
end
end

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

        if (sel == true) and (mut == false) then

    for k = 0,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
o1, oriental = reaper.BR_Win32_GetPrivateProfileString("names", "oriental", "nil", pathfull)
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("names", "crescendo", "nil", pathfull)
mmm= " ".. mmm.." "
elseif mm6 =="TRAC dynamic diminuendo len 1.000" then
OOc, mmm = reaper.BR_Win32_GetPrivateProfileString("names", "Diminuendo", "nil", pathfull)
mmm= " ".. mmm.." "
elseif mm6 =="NOTE 0 62 ornament up_bow" then
OOc, mmm = reaper.BR_Win32_GetPrivateProfileString("names", "upBow", "nil", pathfull)
mmm= " ".. mmm.." "

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


else
mmm= mm6

















end
if (mm4 >=endppqpos) then
break



end











end

end



if (pitch >= 0) and (pitch <=11) then   
o1, O = reaper.BR_Win32_GetPrivateProfileString("names", "Octave-1", "nil", pathfull)
elseif (pitch >= 12) and (pitch <=23) then   
o1, O = reaper.BR_Win32_GetPrivateProfileString("names", "Octave0", "nil", pathfull)
elseif (pitch >= 23) and (pitch <=35) then   
o1, O = reaper.BR_Win32_GetPrivateProfileString("names", "Octave1", "nil", pathfull)
elseif (pitch >= 35) and (pitch <=47) then   
o1, O = reaper.BR_Win32_GetPrivateProfileString("names", "Octave2", "nil", pathfull)
elseif (pitch >= 48) and (pitch <=59) then   
o1, O = reaper.BR_Win32_GetPrivateProfileString("names", "Octave3", "nil", pathfull)
elseif (pitch >= 60) and (pitch <=71) then   
o1, O = reaper.BR_Win32_GetPrivateProfileString("names", "Octave4", "nil", pathfull)
elseif (pitch >= 72) and (pitch <=83) then   
o1, O = reaper.BR_Win32_GetPrivateProfileString("names", "Octave5", "nil", pathfull)
elseif (pitch >= 84) and (pitch <=95) then   
o1, O = reaper.BR_Win32_GetPrivateProfileString("names", "Octave6", "nil", pathfull)
elseif (pitch >= 96) and (pitch <=107) then   
o1, O = reaper.BR_Win32_GetPrivateProfileString("names", "Octave7", "nil", pathfull)
elseif (pitch >= 108) and (pitch <=119) then   
o1, O = reaper.BR_Win32_GetPrivateProfileString("names", "Octave8", "nil", pathfull)
elseif (pitch >= 120) and (pitch <=132) then   
o1, O = reaper.BR_Win32_GetPrivateProfileString("names", "Octave9", "nil", pathfull)
end
key = (pitch +12) %12
	if key == 0 then
oo1, key22 = reaper.BR_Win32_GetPrivateProfileString("names", "Doo", "nil", pathfull)
elseif key == 1 then
oo1, key22 = reaper.BR_Win32_GetPrivateProfileString("names", "DooDyiaz", "nil", pathfull)
elseif key == 2 then
oo1, key22 = reaper.BR_Win32_GetPrivateProfileString("names", "Ree", "nil", pathfull)
elseif key == 3 then
oo1, key22 = reaper.BR_Win32_GetPrivateProfileString("names", "ReeDyiaz", "nil", pathfull)
elseif key == 4 then
oo1, key22 = reaper.BR_Win32_GetPrivateProfileString("names", "Mee", "nil", pathfull)
elseif key == 5 then
oo1, key22 = reaper.BR_Win32_GetPrivateProfileString("names", "Faa", "nil", pathfull)
elseif key == 6 then
oo1, key22 = reaper.BR_Win32_GetPrivateProfileString("names", "FaaDyiaz", "nil", pathfull)
elseif key == 7 then
oo1, key22 = reaper.BR_Win32_GetPrivateProfileString("names", "Sol", "nil", pathfull)
elseif key == 8 then
oo1, key22 = reaper.BR_Win32_GetPrivateProfileString("names", "SolDyiaz", "nil", pathfull)
elseif key == 9 then
oo1, key22 = reaper.BR_Win32_GetPrivateProfileString("names", "Laa", "nil", pathfull)
elseif key == 10 then
oo1, key22 = reaper.BR_Win32_GetPrivateProfileString("names", "LaaDyiaz", "nil", pathfull)
elseif key ==11  then
oo1, key22 = reaper.BR_Win32_GetPrivateProfileString("names", "See", "nil", pathfull)
end
poss =endppqpos -  startppqpos
if  (poss >= 3456) and (poss <= 3840) then

oo1, poss2 = reaper.BR_Win32_GetPrivateProfileString("names", "Rond", "nil", pathfull)
elseif (poss >= 1728) and (poss <= 1920) then
oo1, poss2 = reaper.BR_Win32_GetPrivateProfileString("names", "Blanch", "nil", pathfull)
elseif  (poss >= 864) and (poss <= 960) then
oo1, poss2 = reaper.BR_Win32_GetPrivateProfileString("names", "Noir", "nil", pathfull)
elseif (poss >= 432) and (poss <= 480) then
oo1, poss2 = reaper.BR_Win32_GetPrivateProfileString("names", "Qroch", "nil", pathfull)
elseif (poss >= 216) and (poss <= 240) then
oo1, poss2 = reaper.BR_Win32_GetPrivateProfileString("names", "DoppleQroch", "nil", pathfull)
elseif (poss >= 108) and (poss <= 120) then
oo1, poss2 = reaper.BR_Win32_GetPrivateProfileString("names", "TrippleQroch", "nil", pathfull)
elseif (poss >= 54) and  (poss >= 64) then
oo1, poss2 = reaper.BR_Win32_GetPrivateProfileString("names", "QuaTripple", "nil", pathfull)
else
poss2 =""

end

M = key22 ..poss2.." " ..oriental.. O .. mmmm






           end

if (sel == true) and (mut == true) then
poss =endppqpos - startppqpos
if  (poss >= 3456) and (poss <= 3840) then
oo1, poss2 = reaper.BR_Win32_GetPrivateProfileString("names", "SilenceRond", "nil", pathfull)
elseif (poss >= 1728) and (poss <= 1920) then
oo1, poss2 = reaper.BR_Win32_GetPrivateProfileString("names", "SilenceBlanch", "nil", pathfull)
elseif  (poss >= 864) and (poss <= 960) then
oo1, poss2 = reaper.BR_Win32_GetPrivateProfileString("names", "SilenceNoir", "nil", pathfull)
elseif (poss >= 432) and (poss <= 480) then
oo1, poss2 = reaper.BR_Win32_GetPrivateProfileString("names", "SilenceQroch", "nil", pathfull)
elseif (poss >= 216) and (poss <= 240) then
oo1, poss2 = reaper.BR_Win32_GetPrivateProfileString("names", "SilenceDoppleQroch", "nil", pathfull)
elseif (poss >= 108) and (poss <= 120) then
oo1, poss2 = reaper.BR_Win32_GetPrivateProfileString("names", "SilenceTrippleQroch", "nil", pathfull)
elseif (poss >= 54) and  (poss >= 64) then
oo1, poss2 = reaper.BR_Win32_GetPrivateProfileString("names", "SilenceQuaTripple", "nil", pathfull)
end

M =poss2
break

end
        end
	reaper.MIDI_Sort(take)
if mmn ~= "" then
M=M.." "..couuu.."notes".. mmn
end
reaper.osara_outputMessage(M )
