From 13b1b607b56b556a036b6ca8ba8d080b7a7afc77 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 19 Feb 2017 16:03:17 +0100 Subject: [PATCH] Clean up create drum-tracks script (no global variables) --- scripts/create_drum_tracks.lua | 41 +++++++++++++++------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/scripts/create_drum_tracks.lua b/scripts/create_drum_tracks.lua index 0ade66a60d..57c484a61e 100644 --- a/scripts/create_drum_tracks.lua +++ b/scripts/create_drum_tracks.lua @@ -1,4 +1,3 @@ - ardour { ["type"] = "EditorAction", name = "Create Drum Tracks", @@ -6,36 +5,32 @@ ardour { description = [[Creates 8 new tracks with representative names and colors.]] } -names = { -"Kick", -"Snare", -"Hat", -"Fl Tom", -"OH L", -"OH R", -"Room 1", -"Room 2" -} +function factory () return function () -color = 0xff8800ff --orange + local names = { + "Kick", + "Snare", + "Hat", + "Fl Tom", + "OH L", + "OH R", + "Room 1", + "Room 2" + } - -function factory (params) - return function () + local color = 0xff8800ff --orange local i = 1 while names[i] do - Session:new_audio_track(1,2,RouteGroup,1,names[i],i,ARDOUR.TrackMode.Normal) + local tl = Session:new_audio_track (1, 2, nil, 1, names[i], + ARDOUR.PresentationInfo.max_order, + ARDOUR.TrackMode.Normal) - track = Session:route_by_name(names[i]) - if (not track:isnil()) then - trkinfo = track:presentation_info_ptr () - trkinfo:set_color (color) + for track in tl:iter () do + track:presentation_info_ptr ():set_color (color) end i = i + 1 end --foreach track - end --function - -end --factory +end end -- function factory -- 2.30.2