aboutsummaryrefslogtreecommitdiffhomepage
path: root/applause.lua
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2015-04-20 14:46:48 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2015-04-20 14:46:48 +0200
commitcb29ed5d19e37cb94c02eabf6e6110ac0649e565 (patch)
tree44b3ea9ef93c21f59a309a377e62c64308c7db50 /applause.lua
parent0c10486f3023e911f7fb8b400d61143cfcd009bd (diff)
downloadapplause2-cb29ed5d19e37cb94c02eabf6e6110ac0649e565.tar.gz
filtering: handle frequency streams short than the input stream
Diffstat (limited to 'applause.lua')
-rw-r--r--applause.lua20
1 files changed, 16 insertions, 4 deletions
diff --git a/applause.lua b/applause.lua
index 2e7ec5c..8abdd1a 100644
--- a/applause.lua
+++ b/applause.lua
@@ -742,7 +742,10 @@ function LPFStream:tick()
-- calculate filter coefficients
-- avoid recalculation for constant frequencies
local freq = freq_tick()
- if freq ~= cur_freq then
+ if freq == nil then
+ -- don't filter if we run out of frequency samples
+ return tick()
+ elseif freq ~= cur_freq then
cur_freq = freq
local pfreq = cur_freq * radians_per_sample * 0.5
@@ -796,7 +799,10 @@ function HPFStream:tick()
-- calculate filter coefficients
-- avoid recalculation for constant frequencies
local freq = freq_tick()
- if freq ~= cur_freq then
+ if freq == nil then
+ -- don't filter if we run out of frequency samples
+ return tick()
+ elseif freq ~= cur_freq then
cur_freq = freq
local pfreq = cur_freq * radians_per_sample * 0.5
@@ -851,7 +857,10 @@ function BPFStream:tick()
-- calculate filter coefficients
-- avoid recalculation for constant frequencies
local freq = freq_tick()
- if freq ~= cur_freq then
+ if freq == nil then
+ -- don't filter if we run out of frequency samples
+ return tick()
+ elseif freq ~= cur_freq then
cur_freq = freq
local pfreq = cur_freq * radians_per_sample
@@ -907,7 +916,10 @@ function BRFStream:tick()
-- calculate filter coefficients
-- avoid recalculation for constant frequencies
local freq = freq_tick()
- if freq ~= cur_freq then
+ if freq == nil then
+ -- don't filter if we run out of frequency samples
+ return tick()
+ elseif freq ~= cur_freq then
cur_freq = freq
local pfreq = cur_freq * radians_per_sample