Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

…der samples
  • Loading branch information...
commit 4f02964f2fdc0a41476412b2715323a654aa0e5c 1 parent ca762a3
Petr Baudis authored September 14, 2012

Showing 1 changed file with 3 additions and 1 deletion. Show diff stats Hide diff stats

  1. 4  host_python/equalizer.py
4  host_python/equalizer.py
@@ -100,6 +100,8 @@ def get_color(volume):
100 100
 
101 101
 l = ledbar.Ledbar(PIXELS)
102 102
 history = []
  103
+
  104
+history_diminish = np.array([[((i+1.0) / HISTORY_SIZE)**2] * CHUNK_SIZE for i in xrange(HISTORY_SIZE)])
103 105
 window = np.array([0.5*(1-math.cos(2*math.pi*i/(SAMPLE_SIZE-1))) for i in xrange(SAMPLE_SIZE)])
104 106
 work = True
105 107
 
@@ -119,7 +121,7 @@ def get_color(volume):
119 121
         history.append(indata)
120 122
         if len(history) > HISTORY_SIZE: history.pop(0)
121 123
         elif len(history) < HISTORY_SIZE: continue
122  
-        fft = np.fft.rfft(np.concatenate(history)*window)
  124
+        fft = np.fft.rfft(np.concatenate(history*history_diminish)*window)
123 125
         freq_limit = MIN_FREQ
124 126
         freq = 0
125 127
         i = 0

0 notes on commit 4f02964

Please sign in to comment.
Something went wrong with that request. Please try again.