diff options
author | Robin Gareus <robin@gareus.org> | 2019-04-08 16:12:19 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2019-04-08 16:12:19 +0200 |
commit | 57616fdb1198b0643815aa08c4526b19bdb27fb9 (patch) | |
tree | 2cc133934422e14f32fd9d8701d6c964f8e27e28 | |
parent | 3ec261ae5d7352b7d77aa0f9a60f24ef1f9e08a5 (diff) |
Cleaup meter-tap: reduce nesting and remove code-dup
-rw-r--r-- | scripts/meter_tap.lua | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/scripts/meter_tap.lua b/scripts/meter_tap.lua index 6f8f62c229..645af522bd 100644 --- a/scripts/meter_tap.lua +++ b/scripts/meter_tap.lua @@ -17,34 +17,26 @@ function factory () return function () } local rv = LuaDialog.Dialog("Change all Meter Taps:", dialog_options):run() - if rv then - meter_point = rv['select'] - if rv['select-tracks'] then - local sel = Editor:get_selection () - for route in sel.tracks:routelist():iter() do - if not(route:to_track():isnil()) then - if rv['rec-tracks'] then - if route:rec_enable_control():get_value() == 1.0 then - route:to_track():set_meter_point(meter_point, false) - end - else - route:to_track():set_meter_point(meter_point, false) - end - end - end - else - for route in Session:get_routes():iter() do - if not(route:to_track():isnil()) then - if rv['rec-tracks'] then - if route:rec_enable_control():get_value() == 1.0 then - route:to_track():set_meter_point(meter_point, false) - end - else - route:to_track():set_meter_point(meter_point, false) - end + if not rv then return end -- user cancelled + + local rl; + if rv['select-tracks'] then + rl = Editor:get_selection () + else + rl = Session:get_routes() + end + + local meter_point = rv['select'] + + for route in rl:iter() do + if not(route:to_track():isnil()) then + if rv['rec-tracks'] then + if route:rec_enable_control():get_value() == 1.0 then + route:to_track():set_meter_point(meter_point, false) end + else + route:to_track():set_meter_point(meter_point, false) end end end - end end |