Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/plugins/audio_sensors
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/audio_sensors')
-rw-r--r--plugins/audio_sensors/audio_sensors.py11
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)