Compare commits

...

2 Commits

Author SHA1 Message Date
25e70f3f99 [docs] feat: add readme and license
Signed-off-by: Christopher Arndt <chris@chrisarndt.de>
2024-01-20 17:23:49 +01:00
1d9706e19a feat: use range instead of location/arrangement markers
Signed-off-by: Christopher Arndt <chris@chrisarndt.de>
2024-01-20 17:21:11 +01:00
3 changed files with 46 additions and 6 deletions

21
LICENSE.md Normal file
View File

@ -0,0 +1,21 @@
# License
Copyright (c) 2024 Christopher Arndt <chris@chrisarndt.de>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

20
README.md Normal file
View File

@ -0,0 +1,20 @@
# My Ardour Scripts
This repository contains the [Lua scripts] I have written for the [Ardour DAW].
The scripts are released under the [MIT License]. Please see the details in the
file [LICENSE.md](./LICENSE.md).
## Scripts
[rename_regions_from_markers.lua](./rename_regions_from_markers.lua)
Renames all selected regions to the name of the track they are on plus the
label of the range marker, which starts where the region starts. If no range
marker is found at this position, the region name remains unchanged. Supports
undo.
[Ardour DAW]: https://ardour.org/
[Lua scripts]: https://manual.ardour.org/lua-scripting/
[MIT License]: https://spdx.org/licenses/MIT.html

View File

@ -3,7 +3,7 @@ ardour {
name = "Rename regions from markers", name = "Rename regions from markers",
license = "MIT", license = "MIT",
author = "Christopher Arndt", author = "Christopher Arndt",
description = [[Rename selected regions using track name and label of location marker at region start]] description = [[Rename selected regions using track name and label of range marker at region start]]
} }
function factory () function factory ()
@ -24,7 +24,6 @@ function factory ()
local sel = Editor:get_selection () -- get current selection local sel = Editor:get_selection () -- get current selection
local loc = Session:locations() -- get locations local loc = Session:locations() -- get locations
-- prepare undo operation -- prepare undo operation
Session:begin_reversible_command ("Rename regions from markers") Session:begin_reversible_command ("Rename regions from markers")
@ -32,17 +31,17 @@ function factory ()
for region in sel.regions:regionlist():iter () do for region in sel.regions:regionlist():iter () do
-- test if it's an audio region -- test if it's an audio region
local ar = region:to_audioregion () local ar = region:to_audioregion ()
if ar:isnil () then if ar:isnil() then
goto next goto next
end end
--~ print("Region:", region:name()) --~ print("Region:", region:name())
local rid = region:to_stateful():id() local rid = region:to_stateful():id()
--~ print("ID:", id:to_s()) --~ print("ID:", rid:to_s())
-- get marker at region start position -- get range marker at region start position
local pos = region:position() local pos = region:position()
local mloc = loc:first_mark_at(pos, Temporal.timecnt_t(0)) local mloc = loc:range_starts_at(pos, Temporal.timecnt_t(0), true)
if not mloc then if not mloc then
goto next goto next
end end