summaryrefslogtreecommitdiff
path: root/scripts/preare_record_example.lua
blob: 48e063d3267d281f8038f635fffb02b9e4e2b9ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
--[[

# Example script to prepare the Ardour session for recording

Usually there's a certain state needed to actually start the recording.  This example
script treats the situation of a podcast recording. When starting the recording the
following settings have to be ensured.

* Session has to be recenabled
* Tracks have to be recenabled
* Gain automation have to set on write in order to record events from mute buttons
* The playhead has to be at 00:00:00.000
* The last (failed) capture has to be cleared
* Location markers have to be cleared

So this script automizes away the task and lets the podcast moderator by just one
action (for example triggerd by a Wiimote) prepare the session for recording.

It can be used for example with the python script of the Linux podcasting hacks:
https://github.com/linux-podcasting-hacks/wiimote-recording-control

Not that this script is more meant as an demo script to demonstrate the
possibilities of the Lua interface.

--]]

ardour {
	["type"] = "EditorAction",
	name = "Prepare recording for podcast",
	author = "Johannes Mueller",
	description = [[
Prepares the Ardour session for podcast recording.

* Sets the gain automation to "Write" so that muting buttons work.
* Recenables all tracks.
* Clears all markers.
* Erases the last capture (assuming that it was a failed one)
* Rewinds the session to starting point.
* Recenables the session.
]]
}

function factory (unused) return function()
	if Session:actively_recording() then
		return end

	for t in Session:get_tracks():iter() do
		t:gain_control():set_automation_state(ARDOUR.AutoState.Write)
		t:rec_enable_control():set_value(1, PBD.GroupControlDisposition.UseGroup)
	end

	for l in Session:locations():list():iter() do
		if l:is_mark() then
			Session:locations():remove(l)
		end
	end

	Session:goto_start()
	Editor:remove_last_capture()
	Session:maybe_enable_record()

end end

function icon (params) return function (ctx, width, height)
	local x = width * .5
	local y = height * .5
	local r = math.min (x, y) * .55

	ctx:arc (x, y, r, 0, 2 * math.pi)
	ctx:set_source_rgba (.9, .3, .3, 1.)
	ctx:fill_preserve ()
	ctx:set_source_rgba (0, 0, 0, .8)
	ctx:set_line_width (1)
	ctx:stroke ()

	local txt = Cairo.PangoLayout (ctx, "ArdourMono ".. math.ceil(r * 1.5) .. "px")
	txt:set_text ("P")
	local tw, th = txt:get_pixel_size ()
	ctx:set_source_rgba (0, 0, 0, 1.0)
	ctx:move_to (.5 * (width - tw), .5 * (height - th))
	txt:show_in_cairo_context (ctx)
end end