mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-08 07:45:00 +01:00
Also move Lua scripts to share subfolder
This commit is contained in:
parent
bf649cd68a
commit
180843f9bd
129 changed files with 2 additions and 2 deletions
47
share/scripts/__readable.lua
Normal file
47
share/scripts/__readable.lua
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
ardour { ["type"] = "Snippet", name = "Readable Test" }
|
||||
|
||||
function factory () return function ()
|
||||
|
||||
local file = "/tmp/reverbs/Large Wide Echo Hall.wav"
|
||||
local rl = ARDOUR.Readable.load (Session, file)
|
||||
local cmem = ARDOUR.DSP.DspShm (8192)
|
||||
|
||||
local d = cmem:to_float (0):array()
|
||||
for i = 1, 8192 do d[i] = 0 end
|
||||
d[1] = .5
|
||||
|
||||
local ar = ARDOUR.AudioRom.new_rom (cmem:to_float (0), 8192)
|
||||
|
||||
rl:push_back (ar)
|
||||
|
||||
local c = 1
|
||||
for rd in rl:iter () do
|
||||
local n_samples = rd:readable_length ()
|
||||
assert (rd:n_channels () == 1)
|
||||
|
||||
local peak = 0
|
||||
local pos = 0
|
||||
repeat
|
||||
-- read at most 8K samples starting at 'pos'
|
||||
local s = rd:read (cmem:to_float (0), pos, 8192, 0)
|
||||
pos = pos + s
|
||||
-- access the raw audio data
|
||||
-- http://manual.ardour.org/lua-scripting/class_reference/#C:FloatArray
|
||||
local d = cmem:to_float (0):array()
|
||||
-- iterate over the audio sample data
|
||||
for i = 0, s do
|
||||
if math.abs (d[i]) > peak then
|
||||
peak = math.abs (d[i])
|
||||
end
|
||||
end
|
||||
until s < 8192
|
||||
assert (pos == n_samples)
|
||||
|
||||
if (peak > 0) then
|
||||
print ("File:", file, "channel", c, "peak:", 20 * math.log (peak) / math.log(10), "dBFS")
|
||||
else
|
||||
print ("File:", file, "channel", c, " is silent")
|
||||
end
|
||||
c = c + 1;
|
||||
end
|
||||
end end
|
||||
Loading…
Add table
Add a link
Reference in a new issue