]> git.parisson.com Git - timeside.git/commitdiff
- fix multiple spectral centroid calls
authoryomguy <yomguy@parisson.com>
Tue, 2 Mar 2010 16:54:09 +0000 (16:54 +0000)
committeryomguy <yomguy@parisson.com>
Tue, 2 Mar 2010 16:54:09 +0000 (16:54 +0000)
grapher/core.py

index a4cd641b8f5918dd00dd749a5c79c2706bda2cf8..d682699735aa79db16a59d22ba1811d695c4dd30 100644 (file)
@@ -233,12 +233,11 @@ class WaveformImage(object):
             buffer = frames[:,0].copy()
             buffer.shape = (len(buffer),1)
 
+        (spectral_centroid, db_spectrum) = self.spectral_centroid.process(buffer, True)
         for samples, end in self.peaks_adapter.process(buffer, eod):
             if self.pixel_cursor == self.image_width:
                 break
             peaks = self.peaks(samples)
-            # FIXME : too much repeated spectrum computation cycle
-            (spectral_centroid, db_spectrum) = self.spectral_centroid.process(buffer, True)
             self.draw_peaks(self.pixel_cursor, peaks, spectral_centroid)
             self.pixel_cursor += 1
 
@@ -250,8 +249,8 @@ class WaveformImage(object):
 
 
 class SpectrogramImage(object):
-    def __init__(self, image_width, image_height, nframes, samplerate, buffer_size, bg_color=None, color_scheme=None, filename=None):
 
+    def __init__(self, image_width, image_height, nframes, samplerate, buffer_size, bg_color=None, color_scheme=None, filename=None):
         self.image_width = image_width
         self.image_height = image_height
         self.nframes = nframes
@@ -306,11 +305,10 @@ class SpectrogramImage(object):
             buffer = frames[:,0].copy()
             buffer.shape = (len(buffer),1)
 
+        (spectral_centroid, db_spectrum) = self.spectral_centroid.process(buffer, True)
         for samples, end in self.peaks_adapter.process(buffer, eod):
             if self.pixel_cursor == self.image_width:
                 break
-            # FIXME : too much repeated spectrum computation cycle
-            (spectral_centroid, db_spectrum) = self.spectral_centroid.process(buffer, True)
             self.draw_spectrum(self.pixel_cursor, db_spectrum)
             self.pixel_cursor += 1