High frequency cause "index out of bounds"
construidor opened this issue · comments
If the frequency in "options.py" is bigger then 21736, the following error appears in "listen.py":
$ python2 listen.py
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "listen.py", line 39, in process_frames
point = quietnet.has_freq(fft, search_freq, rate, chunk)
File "/home/construidor/src/quietnet/quietnet.py", line 28, in has_freq
if top < np.average([fft_sample[peak-offset], fft_sample[peak+offset]]):
IndexError: index out of bounds
Good catch. Fixed in a8ca7b1. Also added a note in options.py about why a frequency around 19kHz was chosen (frequencies as high as 21736Hz aren't picked up by my built in microphone.)
It will still throw an error on even higher frequencies, but I don't really mind that.