Fix ExportFormatSpecification copy-c'tor
[ardour.git] / scripts / create_drum_tracks.lua
1 ardour {\r
2         ["type"] = "EditorAction",\r
3         name = "Create Drum Tracks",\r
4         author = "PSmith",\r
5         description = [[Creates 8 new tracks with representative names and colors.]]\r
6 }\r
7 \r
8 function factory () return function ()\r
9                 local names = {\r
10                         "Kick",\r
11                         "Snare",\r
12                         "Hat",\r
13                         "Fl Tom",\r
14                         "OH L",\r
15                         "OH R",\r
16                         "Room 1",\r
17                         "Room 2"\r
18                 }\r
19 \r
20                 local color = 0xff8800ff  --orange\r
21 \r
22                 local i = 1\r
23                 while names[i] do\r
24                         local tl = Session:new_audio_track (1, 2, nil, 1, names[i],\r
25                                                             ARDOUR.PresentationInfo.max_order,\r
26                                                             ARDOUR.TrackMode.Normal)\r
27 \r
28                         for track in tl:iter () do\r
29                                 track:presentation_info_ptr ():set_color (color)\r
30                         end\r
31 \r
32                         i = i + 1\r
33                 end --foreach track\r
34 \r
35 end end -- function factory\r
36 \r
37 \r
38 function icon (params) return function (ctx, width, height)\r
39         local x = width * .5\r
40         local y = height * .5\r
41         local r = math.min (x, y) * .7\r
42         ctx:save ()\r
43         ctx:translate (x, y)\r
44         ctx:scale (1, .5)\r
45         ctx:translate (-x, -y)\r
46         ctx:arc (x, y, r, 0, 2 * math.pi)\r
47         ctx:set_source_rgba (.9, .9, 1, 1)\r
48         ctx:fill ()\r
49         ctx:arc (x, y, r, 0, math.pi)\r
50         ctx:arc_negative (x, y * 1.6, r, math.pi, 0)\r
51         ctx:set_source_rgba (.7, .7, .7, 1)\r
52         ctx:fill ()\r
53         ctx:restore ()\r
54 \r
55         ctx:set_source_rgba (.6, .4, .2, 1)\r
56         ctx:translate (x, y)\r
57         ctx:scale (.7, 1)\r
58         ctx:translate (-x, -y)\r
59         ctx:set_line_cap (Cairo.LineCap.Round)\r
60 \r
61         function drumstick (xp, lr)\r
62                 ctx:set_line_width (r * .3)\r
63                 ctx:move_to (x * xp, y)\r
64                 ctx:close_path ()\r
65                 ctx:stroke ()\r
66                 ctx:set_line_width (r * .2)\r
67                 ctx:move_to (x * xp, y)\r
68                 ctx:rel_line_to (lr * x, y)\r
69                 ctx:stroke ()\r
70         end\r
71         drumstick (1.2, 1.2)\r
72         drumstick (0.7, -.5)\r
73 end end\r