extend/fix/improve operator overloads and methods for Evoral::Beats
[ardour.git] / scripts / create_drum_tracks.lua
index 0ade66a60d4ffbe226254f7fd025a24f2905251a..0f16f87a7072594fefc02bdf5db5021eb81ea15a 100644 (file)
@@ -1,4 +1,3 @@
-\r
 ardour {\r
        ["type"] = "EditorAction",\r
        name = "Create Drum Tracks",\r
@@ -6,36 +5,69 @@ ardour {
        description = [[Creates 8 new tracks with representative names and colors.]]\r
 }\r
 \r
-names = {\r
-"Kick",\r
-"Snare",\r
-"Hat",\r
-"Fl Tom",\r
-"OH L",\r
-"OH R",\r
-"Room 1",\r
-"Room 2"\r
-}\r
-\r
-color = 0xff8800ff  --orange\r
+function factory () return function ()\r
+               local names = {\r
+                       "Kick",\r
+                       "Snare",\r
+                       "Hat",\r
+                       "Fl Tom",\r
+                       "OH L",\r
+                       "OH R",\r
+                       "Room 1",\r
+                       "Room 2"\r
+               }\r
 \r
-    \r
-function factory (params)\r
-       return function ()\r
+               local color = 0xff8800ff  --orange\r
 \r
                local i = 1\r
                while names[i] do\r
-                       Session:new_audio_track(1,2,RouteGroup,1,names[i],i,ARDOUR.TrackMode.Normal)\r
+                       local tl = Session:new_audio_track (1, 2, nil, 1, names[i],\r
+                                                           ARDOUR.PresentationInfo.max_order,\r
+                                                           ARDOUR.TrackMode.Normal)\r
 \r
-                       track = Session:route_by_name(names[i])\r
-                       if (not track:isnil()) then\r
-                               trkinfo = track:presentation_info_ptr ()        \r
-                               trkinfo:set_color (color)\r
+                       for track in tl:iter () do\r
+                               track:presentation_info_ptr ():set_color (color)\r
                        end\r
 \r
                        i = i + 1\r
                end --foreach track\r
 \r
-       end  --function\r
+end end -- function factory\r
+\r
+\r
+function icon (params) return function (ctx, width, height)\r
+       local x = width * .5\r
+       local y = height * .5\r
+       local r = math.min (x, y) * .7\r
+       ctx:save ()\r
+       ctx:translate (x, y)\r
+       ctx:scale (1, .5)\r
+       ctx:translate (-x, -y)\r
+       ctx:arc (x, y, r, 0, 2 * math.pi)\r
+       ctx:set_source_rgba (.9, .9, 1, 1)\r
+       ctx:fill ()\r
+       ctx:arc (x, y, r, 0, math.pi)\r
+       ctx:arc_negative (x, y * 1.6, r, math.pi, 0)\r
+       ctx:set_source_rgba (.7, .7, .7, 1)\r
+       ctx:fill ()\r
+       ctx:restore ()\r
+\r
+       ctx:set_source_rgba (.6, .4, .2, 1)\r
+       ctx:translate (x, y)\r
+       ctx:scale (.7, 1)\r
+       ctx:translate (-x, -y)\r
+       ctx:set_line_cap (Cairo.LineCap.Round)\r
 \r
-end --factory\r
+       function drumstick (xp, lr)\r
+               ctx:set_line_width (r * .3)\r
+               ctx:move_to (x * xp, y)\r
+               ctx:close_path ()\r
+               ctx:stroke ()\r
+               ctx:set_line_width (r * .2)\r
+               ctx:move_to (x * xp, y)\r
+               ctx:rel_line_to (lr * x, y)\r
+               ctx:stroke ()\r
+       end\r
+       drumstick (1.2, 1.2)\r
+       drumstick (0.7, -.5)\r
+end end\r