mirror of
https://github.com/brmlab/ledbar.git
synced 2025-06-09 05:14:03 +02:00
equalizer: Reduce lag caused by averaging by giving less weight to older samples
This commit is contained in:
parent
ca762a30f1
commit
4f02964f2f
1 changed files with 3 additions and 1 deletions
|
@ -100,6 +100,8 @@ def get_color(volume):
|
||||||
|
|
||||||
l = ledbar.Ledbar(PIXELS)
|
l = ledbar.Ledbar(PIXELS)
|
||||||
history = []
|
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)])
|
window = np.array([0.5*(1-math.cos(2*math.pi*i/(SAMPLE_SIZE-1))) for i in xrange(SAMPLE_SIZE)])
|
||||||
work = True
|
work = True
|
||||||
|
|
||||||
|
@ -119,7 +121,7 @@ try:
|
||||||
history.append(indata)
|
history.append(indata)
|
||||||
if len(history) > HISTORY_SIZE: history.pop(0)
|
if len(history) > HISTORY_SIZE: history.pop(0)
|
||||||
elif len(history) < HISTORY_SIZE: continue
|
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_limit = MIN_FREQ
|
||||||
freq = 0
|
freq = 0
|
||||||
i = 0
|
i = 0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue