forgot else in selected-tracks check.
[ardour.git] / scripts / meter_tap.lua
1 ardour {
2     ["type"] = "EditorAction",
3     name = "Meter Tap",
4     author = "Ardour Lua Taskforce",
5     description = [[Change Metering  Point for tracks in your session.]]
6 }
7
8 function factory () return function ()
9
10         local dialog_options = {
11                 { type = "label", colspan = 5, title = "" },
12                 { type = "radio", col = 1, colspan = 7, key = "select", title = "", values ={ ["Set All: Input"] = ARDOUR.MeterPoint.MeterInput, ["Set All: Pre Fader"] = ARDOUR.MeterPoint.MeterPreFader, ["Set All: Post Fader"] = ARDOUR.MeterPoint.MeterPostFader, ["Set All: Output"] = ARDOUR.MeterPoint.MeterOutput, ["Set All: Custom"] = ARDOUR.MeterPoint.MeterCustom}, default = "Set All: Input"},
13                 { type = "label", colspan = 5, title = "" },
14                 { type = "checkbox", col=1, colspan = 1, key = "select-tracks", default = true, title = "Selected tracks only"},
15                 { type = "checkbox", col=2, colspan = 1, key = "rec-tracks", default = true, title = "Record Enabled tracks only"},
16                 { type = "label", colspan = 5, title = "" },
17         }
18
19         local rv = LuaDialog.Dialog("Change all Meter Taps:", dialog_options):run()
20
21         meter_point = rv['select']
22         if rv['select-tracks'] then
23                 local sel = Editor:get_selection ()
24                 for route in sel.tracks:routelist():iter() do
25                         if not(route:to_track():isnil()) then
26                                 if rv['rec-tracks'] then
27                                         if route:rec_enable_control():get_value() == 1.0 then
28                                                 route:to_track():set_meter_point(meter_point, false)
29                                         end
30                                 else
31                                         route:to_track():set_meter_point(meter_point, false)
32                                 end
33                         end
34                 end
35         else
36                 for route in Session:get_routes():iter() do
37                         if not(route:to_track():isnil()) then
38                                 if rv['rec-tracks'] then
39                                         if route:rec_enable_control():get_value() == 1.0 then
40                                                 route:to_track():set_meter_point(meter_point, false)
41                                         end
42                                 else
43                                         route:to_track():set_meter_point(meter_point, false)
44                                 end
45                         end
46                 end
47         end
48         
49 end end