diff options
author | Walter Bender <walter.bender@gmail.com> | 2012-06-23 20:37:09 (GMT) |
---|---|---|
committer | Walter Bender <walter.bender@gmail.com> | 2012-06-23 20:37:09 (GMT) |
commit | 08c70527f7dada80a57fc69b8ed7f5892a9608d2 (patch) | |
tree | b1e72d7bc67181af61bcd17ae7f15bc05c17f6a6 /plugins | |
parent | f607cd4eda37c06709a143f9e36d278fd9388c20 (diff) |
simplified freq. code
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/audio_sensors/audio_sensors.py | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/plugins/audio_sensors/audio_sensors.py b/plugins/audio_sensors/audio_sensors.py index 0a7fb81..0ec383c 100644 --- a/plugins/audio_sensors/audio_sensors.py +++ b/plugins/audio_sensors/audio_sensors.py @@ -320,10 +320,7 @@ class Audio_sensors(Plugin): ''' return index of max value in fft of mic in values ''' if not PITCH_AVAILABLE or not self._status: return 0 - buf = [] - for i in range(4): - buf = append( - buf, self.ringbuffer[channel].read(None, self.input_step)) + buf = self.ringbuffer[channel].read(None, self.input_step) if len(buf) > 0: buf = rfft(buf) buf = abs(buf) @@ -331,9 +328,9 @@ class Audio_sensors(Plugin): if maxi == 0: pitch = 0 else: # Simple interpolation - a, b, c = buf[maxi - 4], buf[maxi], buf[maxi + 4] - maxi -= (4. * a) / float(a + b + c) - maxi += (4. * c) / float(a + b + c) + a, b, c = buf[maxi - 1], buf[maxi], buf[maxi + 1] + maxi -= a / float(a + b + c) + maxi += c / float(a + b + c) pitch = maxi * 48000 / (len(buf) * 2) self._parent.lc.update_label_value('pitch', pitch) |