diff options
author | Robin Gareus <robin@gareus.org> | 2020-01-20 06:37:30 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2020-01-20 06:37:30 +0100 |
commit | 978de93cf2cb7d872cd48b1c213fbd81d4f9ecdd (patch) | |
tree | ae723cd951558f42b97c5d362aada141b989ed55 /scripts/s_region_gain.lua | |
parent | a439d8bbe4b58abefa96ee6f518edc5c326d9b02 (diff) |
Add/update scripts reading raw audio-data
Diffstat (limited to 'scripts/s_region_gain.lua')
-rw-r--r-- | scripts/s_region_gain.lua | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/scripts/s_region_gain.lua b/scripts/s_region_gain.lua index dec9899828..648e76629c 100644 --- a/scripts/s_region_gain.lua +++ b/scripts/s_region_gain.lua @@ -31,10 +31,10 @@ function factory () return function () local peak = 0 -- the audio peak to be calculated -- iterate over all channels in Audio Region - for c = 0, n_channels do + for c = 0, n_channels -1 do + local pos = 0 repeat - local pos = 0 - -- read at most 8K samples of channel 'c' + -- read at most 8K samples of channel 'c' starting at 'pos' local s = rd:read (cmem:to_float (0), pos, 8192, c) pos = pos + s -- access the raw audio data @@ -46,7 +46,8 @@ function factory () return function () peak = math.abs (d[i]) end end - until pos < n_samples + until s < 8192 + assert (pos == n_samples) end if (peak > 0) then |