  reaper.Undo_BeginBlock()
quar=48
S1 = "e"
E1 ="a#"
H1="b"

    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);
if notecnt == nil then return end
	retval2, quar = reaper.GetUserInputs("Write quarter tone value", 1,"", quar) 
	retval, retvals_csv = reaper.GetUserInputs("Set quarter tone", 3, "First note,Second note,Third note", S1..","..E1..","..H1)
	if retval == true then

S3, E3, H3 = retvals_csv:match("([^,]+),([^,]+)")
end
if S3 == "c" then
S5= 0
elseif S3 == "c#" then
S5= 1
elseif S3 == "d" then
S5= 3
elseif S3 == "d#" then
S5= 3
elseif S3 == "e" then
S5= 4
elseif S3 == "f" then
S5= 5
elseif S3 == "f#" then
S5= 6
elseif S3 == "g" then
S5= 7
elseif S3 == "g#" then
S5= 8
elseif S3 == "a" then
S5= 9
elseif S3 == "a#" then
S5= 10
elseif S3 == "b" then
S5= 11
else
S5= 200
end
if E3 == "c" then
E5= 0
elseif E3 == "c#" then
E5= 1
elseif E3 == "d" then
E5= 3
elseif E3 == "d#" then
E5= 3
elseif E3 == "e" then
E5= 4
elseif E3 == "f" then
E5= 5
elseif E3 == "f#" then
E5= 6
elseif E3 == "g" then
E5= 7
elseif E3 == "g#" then
E5= 8
elseif E3 == "a" then
E5= 9
elseif E3 == "a#" then
E5= 10
elseif E3 == "b" then
E5= 11
else
E5= 200
end

if H3 == "c" then
H5= 0
elseif H3 == "c#" then
H5= 1
elseif H3 == "d" then
H5= 3
elseif H3 == "d#" then
H5= 3
elseif H3 == "e" then
H5= 4
elseif H3 == "f" then
H5= 5
elseif H3 == "f#" then
H5= 6
elseif H3 == "g" then
H5= 7
elseif H3 == "g#" then
H5= 8
elseif H3 == "a" then
H5= 9
elseif H3 == "a#" then
H5= 10
elseif H3 == "b" then
H5= 11
else
H5= 200
end

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
pitch2 = (pitch +12)%12
if (pitch2 == S5) or(pitch2 == E5) or (pitch2 == H5) then
        reaper.MIDI_InsertCC(take, true, false, startppqpos, 224, chan, 8192, quar)
else
        reaper.MIDI_InsertCC(take, true, false, startppqpos, 224, chan, 8192, 64)
end
end
end
  reaper.Undo_EndBlock("Quarter tone", -1)