]> git.parisson.com Git - timeside.git/commitdiff
Fix bug in cdd971db06391a724f03
authorThomas Fillon <thomas@parisson.com>
Thu, 18 Dec 2014 15:53:00 +0000 (16:53 +0100)
committerThomas Fillon <thomas@parisson.com>
Thu, 18 Dec 2014 15:53:00 +0000 (16:53 +0100)
tests/test_graphers_render_analyzers.py
timeside/analyzer/core.py
timeside/grapher/render_analyzers.py

index d047a8401360bceddc4be6aa2382297d9fe6b4de..b0134660656bb57c6814427567a98aeb6f250b04 100755 (executable)
@@ -3,8 +3,7 @@ from __future__ import division
 
 from unit_timeside import unittest, TestRunner
 import timeside
-from scipy.signal import chirp
-import numpy as np
+from timeside.tools.test_samples import samples
 from tempfile import NamedTemporaryFile
 import os
 
@@ -15,13 +14,9 @@ class Test_graphers_analyzers(unittest.TestCase):
     """ test Graphers from analyzers"""
 
     def setUp(self):
-        samplerate = 16000  # LimsiSad require Fs = 16000 Hz
-        duration = 10
-        t = np.arange(0, duration, 1/samplerate)
-        samples = chirp(t=t, f0=20, t1=t[-1], f1=samplerate/2,
-                        method='logarithmic')
-        decoder_cls = timeside.core.get_processor('array_decoder')
-        self.decoder = decoder_cls(samples, samplerate=samplerate)
+        source = samples["C4_scale.wav"]
+        decoder_cls = timeside.core.get_processor('file_decoder')
+        self.decoder = decoder_cls(uri=source)
 
     def _perform_test(self, grapher_cls):
             """Internal function that test grapher for a given analyzer"""
index 8e9483d28aad3a43604d1817e44030e63c02c290..151d09b724ead3abcf3273205e8acbaa955e9917 100644 (file)
@@ -834,9 +834,19 @@ class FrameValueObject(ValueObject, FramewiseObject):
             # see http://stackoverflow.com/a/8881973
             #  TODO: mean may not be appropriate for waveform ... (mean~=0)
             nb_frames = self.data.shape[0]
-            chunksize = size[0]
 
-            numchunks = nb_frames // chunksize
+            numchunks = size[0]
+
+            if nb_frames > 10*numchunks:
+                ax.plot(self.time, self.data)
+                return
+            else:
+                chunksize = 1
+                numchunks = nb_frames
+
+            print "nb_frames %d" % nb_frames
+            print "chunksize %d" % chunksize
+            print "numchunks %d" % numchunks
 
             if self.data.ndim <= 1:
                 ychunks = self.data[:chunksize*numchunks].reshape((-1,
@@ -854,9 +864,9 @@ class FrameValueObject(ValueObject, FramewiseObject):
             xcenters = xchunks.mean(axis=1)
 
             # Now plot the bounds and the mean...
-            ax.fill_between(xcenters, min_env, max_env, color='gray',
-                            edgecolor='none', alpha=0.5)
-            ax.plot(xcenters, ycenters)
+            ax.fill_between(xcenters, min_env, max_env, color='blue',
+                            edgecolor='black', alpha=1)
+            #ax.plot(xcenters, ycenters, color='gray', alpha=0.5)
 
             #ax.plot(self.time, self.data)
         else:
index 81dd58654429ae25c69d674310921ea7c75a50cc..125cb10449c21407e5cc9991a3e99ae697472d2f 100644 (file)
@@ -54,10 +54,10 @@ class DisplayAnalyzer(Grapher):
     @interfacedoc
     def post_process(self):
         pipe_result = self.process_pipe.results
-        parent_uuid = self.parents['analyzer'].uuid()
-        parent_result = pipe_result[parent_uuid][self._result_id]
+        analyzer_uuid = self.parents['analyzer'].uuid()
+        analyzer_result = pipe_result[analyzer_uuid][self._result_id]
 
-        fg_image = parent_result._render_PIL((self.image_width,
+        fg_image = analyzer_result._render_PIL((self.image_width,
                                               self.image_height), self.dpi)
         if self._background:
             bg_uuid = self.parents['bg_analyzer'].uuid()
@@ -69,7 +69,7 @@ class DisplayAnalyzer(Grapher):
 
             # Merge background and foreground images
             from PIL.Image import blend
-            fg_image = blend(fg_image, bg_image, 0.25)
+            fg_image = blend(fg_image, bg_image, 0.15)
 
         self.image = fg_image
 
@@ -107,8 +107,6 @@ class DisplayAnalyzer(Grapher):
 
                 parent_analyzer = analyzer(**analyzer_parameters)
                 self.parents['analyzer'] = parent_analyzer
-                # TODO : make it generic when analyzer will be "atomize"
-                self._parent_uuid =  parent_analyzer.uuid()
                 self._result_id = result_id
 
             @staticmethod