mirror of
https://github.com/brmlab/ledbar.git
synced 2025-06-09 21:34:00 +02:00
equalizer: minor exception handling
This commit is contained in:
parent
2658d670b6
commit
17f589d929
1 changed files with 9 additions and 3 deletions
|
@ -66,7 +66,7 @@ for k, v in opts:
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
elif k == '-a':
|
elif k == '-a':
|
||||||
try: v = float(v)
|
try: v = float(v)
|
||||||
except:
|
except ValueError:
|
||||||
print 'error: attenuation must be float value'
|
print 'error: attenuation must be float value'
|
||||||
print_usage()
|
print_usage()
|
||||||
ATTENUATION = 10**(v/10)
|
ATTENUATION = 10**(v/10)
|
||||||
|
@ -148,6 +148,7 @@ def loop( stream ):
|
||||||
elif len(history) < HISTORY_SIZE: continue
|
elif len(history) < HISTORY_SIZE: continue
|
||||||
|
|
||||||
# obtain input sequence ~~ oohhh what a kind of dimmish magic and windowing
|
# obtain input sequence ~~ oohhh what a kind of dimmish magic and windowing
|
||||||
|
#TODO: dynamic attenuation based on average power of input signal over timespan, threshold to cut off noise
|
||||||
x = np.concatenate(history*history_diminish)*window/ATTENUATION
|
x = np.concatenate(history*history_diminish)*window/ATTENUATION
|
||||||
|
|
||||||
# compute power spectral desity using autocarelate approach
|
# compute power spectral desity using autocarelate approach
|
||||||
|
@ -159,6 +160,7 @@ def loop( stream ):
|
||||||
# integrate energy within bands ~~ oh, oohhh: look at the orthoginality trick
|
# integrate energy within bands ~~ oh, oohhh: look at the orthoginality trick
|
||||||
bands = (freqs>bands[...,:-1]) & (freqs<=bands[...,1:])
|
bands = (freqs>bands[...,:-1]) & (freqs<=bands[...,1:])
|
||||||
energy = np.round(( bands * psd ).sum(0).squeeze())
|
energy = np.round(( bands * psd ).sum(0).squeeze())
|
||||||
|
#energy = np.round(( bands * psd / bands.sum(0) ).sum(0).squeeze())
|
||||||
|
|
||||||
# write some debug colorfull, very usefull
|
# write some debug colorfull, very usefull
|
||||||
ansicolors = ('\033[30;1m%5.0f\033[0m', '\033[33;1m%5.0f\033[0m', '\033[1;31m%5.0f\033[0m')
|
ansicolors = ('\033[30;1m%5.0f\033[0m', '\033[33;1m%5.0f\033[0m', '\033[1;31m%5.0f\033[0m')
|
||||||
|
@ -177,4 +179,8 @@ def loop( stream ):
|
||||||
# time.sleep(0.05)
|
# time.sleep(0.05)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
try:
|
||||||
with_stream(loop)
|
with_stream(loop)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue