1 -- cd gtk2_ardour; ./arlua < ../tools/split_benchmark.lua
5 backend = AudioEngine:set_backend("None (Dummy)", "", "")
6 backend:set_device_name ("Uniform White Noise")
8 os.execute('rm -rf /tmp/luabench')
9 s = create_session ("/tmp/luabench", "luabench", 48000)
12 s:new_audio_track (1, 2, nil, 16, "", ARDOUR.PresentationInfo.max_order, ARDOUR.TrackMode.Normal)
14 for t in s:get_tracks():iter() do
15 t:rec_enable_control():set_value(1, PBD.GroupControlDisposition.UseGroup)
18 ARDOUR.LuaAPI.usleep (100000)
21 s:maybe_enable_record()
23 s:request_transport_speed(1.0, true, 4)
24 ARDOUR.LuaAPI.usleep (1000000 * reclen)
25 s:request_transport_speed(0.0, false, 4)
27 for t in s:get_tracks():iter() do
28 t:rec_enable_control():set_value(0, PBD.GroupControlDisposition.UseGroup)
31 ARDOUR.LuaAPI.usleep (100000)
36 function split_at (pos)
37 local add_undo = false -- keep track if something has changed
38 Session:begin_reversible_command ("Auto Region Split")
39 for route in Session:get_tracks():iter() do
40 local playlist = route:to_track():playlist ()
41 playlist:to_stateful ():clear_changes ()
42 for region in playlist:regions_at (pos):iter () do
43 playlist:split_region (region, ARDOUR.MusicSample (pos, 0))
45 if not Session:add_stateful_diff_command (playlist:to_statefuldestructible ()):empty () then
50 Session:commit_reversible_command (nil)
52 Session:abort_reversible_command ()
56 function count_regions ()
58 for route in Session:get_tracks():iter() do
59 total = total + route:to_track():playlist():region_list():size()
64 stepsize = Session:samples_per_timecode_frame()
65 fps = Session:nominal_sample_rate () / stepsize
67 cnt = reclen * fps / n_steps
70 local playhead = Session:transport_sample ()
72 local t_start = ARDOUR.LuaAPI.monotonic_time ()
74 split_at (playhead + stepsize * i)
76 local t_end = ARDOUR.LuaAPI.monotonic_time ()
78 Session:request_locate((playhead + stepsize * n_steps), false, 5)
79 print (count_regions (), (t_end - t_start) / 1000 / n_steps)
81 ARDOUR.LuaAPI.usleep(500000)