mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-09 08:14:58 +01:00
Second round of Lua script API updates
This commit is contained in:
parent
1abf6a77d6
commit
76c0f42ecb
23 changed files with 76 additions and 112 deletions
|
|
@ -134,20 +134,20 @@ function factory (unused_params)
|
|||
Session:begin_reversible_command("Add LFO automation to region")
|
||||
local before = al:get_state() -- save previous state (for undo)
|
||||
-- Clear events in target automation-list for the selected region.
|
||||
al:clear(region:position() - region:start(), region:position() - region:start() + region:length())
|
||||
al:clear(region:position() - region:start(), region:position() + region:length() - region:start())
|
||||
|
||||
local values = lut[wave]
|
||||
local last = nil
|
||||
for i = 0, cycles - 1 do
|
||||
-- cycle length = region:length() / cycles
|
||||
local cycle_start = region:position() - region:start() + i * region:length() / cycles
|
||||
local offset = region:length() / cycles / (#values - 1)
|
||||
local cycle_start = region:position() - region:start() + region:length():scale(Temporal.ratio(i, cycles))
|
||||
local offset = region:length():scale (Temporal.ratio (1, cycles * (#values - 1)))
|
||||
|
||||
for k, v in pairs(values) do
|
||||
local pos = cycle_start + (k - 1) * offset
|
||||
local pos = cycle_start + offset:scale (Temporal.ratio (k - 1, 1))
|
||||
if k == 1 and v ~= last then
|
||||
-- Move event one sample further. A larger offset might be needed to avoid unwanted effects.
|
||||
pos = pos + 1
|
||||
pos = pos:increment ()
|
||||
end
|
||||
|
||||
if k > 1 or v ~= last then
|
||||
|
|
@ -167,7 +167,9 @@ function factory (unused_params)
|
|||
|
||||
-- Save undo
|
||||
Session:add_command(al:memento_command(before, al:get_state()))
|
||||
Session:commit_reversible_command(nil)
|
||||
if not Session:abort_empty_reversible_command () then
|
||||
Session:commit_reversible_command (nil)
|
||||
end
|
||||
|
||||
region, al, lut = nil, nil, nil
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue