Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

equalizer: Reduce lag caused by averaging by giving less weight to ol…

…der samples
  • Loading branch information...
commit 4f02964f2fdc0a41476412b2715323a654aa0e5c 1 parent ca762a3
@pasky pasky authored
Showing with 3 additions and 1 deletion.
  1. +3 −1 host_python/equalizer.py
View
4 host_python/equalizer.py
@@ -100,6 +100,8 @@ def get_color(volume):
l = ledbar.Ledbar(PIXELS)
history = []
+
+history_diminish = np.array([[((i+1.0) / HISTORY_SIZE)**2] * CHUNK_SIZE for i in xrange(HISTORY_SIZE)])
window = np.array([0.5*(1-math.cos(2*math.pi*i/(SAMPLE_SIZE-1))) for i in xrange(SAMPLE_SIZE)])
work = True
@@ -119,7 +121,7 @@ def get_color(volume):
history.append(indata)
if len(history) > HISTORY_SIZE: history.pop(0)
elif len(history) < HISTORY_SIZE: continue
- fft = np.fft.rfft(np.concatenate(history)*window)
+ fft = np.fft.rfft(np.concatenate(history*history_diminish)*window)
freq_limit = MIN_FREQ
freq = 0
i = 0
Please sign in to comment.
Something went wrong with that request. Please try again.