    
    ---------------------------------------------------------
    local function no_undo();reaper.defer(function()end);end;
    ---------------------------------------------------------
    
    
    
    local CountSelTrack = reaper.CountSelectedTracks(0);
    if CountSelTrack == 0 then no_undo() return end;
    
    
    reaper.Undo_BeginBlock();
    
    for i = 1, CountSelTrack do;
	   local SelTrack = reaper.GetSelectedTrack(0, i-1);
local master_tempo = math.floor(reaper.Master_GetTempo())
retval, preset = reaper.GetUserInputs("ChangeProjectTempo", 1, "", master_tempo)


if retval == true then 
reaper.CSurf_OnTempoChange(preset)
    end;
        end;

    reaper.Undo_EndBlock("Change master tempo", -1)
    
    reaper.UpdateArrange();