]> git.parisson.com Git - timeside.git/commitdiff
Grapher : Add a generic Class to display Analyzers through their 'render' method...
authorThomas Fillon <thomas@parisson.com>
Mon, 20 Jan 2014 14:37:11 +0000 (15:37 +0100)
committerThomas Fillon <thomas@parisson.com>
Mon, 20 Jan 2014 14:37:11 +0000 (15:37 +0100)
timeside/analyzer/core.py
timeside/core.py
timeside/grapher/__init__.py
timeside/grapher/core.py

index defe49eecc06ec2b68d03bc72e88e9ebec6e293f..bff6b8652a6edbb64bb1f7f07ba03a8eeb230e29 100644 (file)
@@ -29,6 +29,7 @@ import numpy
 from collections import OrderedDict
 import h5py
 import h5tools
+import matplotlib.pyplot as plt
 
 numpy_data_types = [
     #'float128',
@@ -758,7 +759,22 @@ class GlobalLabelResult(LabelObject, GlobalObject, AnalyzerResult):
 
 
 class FrameValueResult(ValueObject, FramewiseObject, AnalyzerResult):
-    pass
+    def render(self, size=(1024, 256), dpi=80):
+
+        image_width, image_height = size
+
+        xSize = image_width / dpi
+        ySize = image_height / dpi
+
+        fig = plt.figure(figsize=(xSize, ySize), dpi=dpi)
+
+        ax = plt.Axes(fig, [0, 0, 1, 0.9])
+        ax.set_frame_on(False)
+        ax.plot(self.time, self.data)
+        ax.axis('off')
+        fig.add_axes(ax)
+
+        return fig
 
 
 class FrameLabelResult(LabelObject, FramewiseObject, AnalyzerResult):
index 56036d490691d6e50bb829a1722572c7af4eadbd..629d4f4e6e835f5e944236420c0190c1c7f1c7dc 100644 (file)
@@ -83,7 +83,7 @@ class Processor(Component):
 
         self.parents = []
         self.source_mediainfo = None
-        self.pipe = None
+        self.process_pipe = None
         self.UUID = uuid.uuid4()
 
     @interfacedoc
index 1cfd82029471bc7b5c1dc3cdabce5af49ae63a6c..4284bd44dc1069738737a598decc1386a3f8220d 100644 (file)
@@ -6,3 +6,4 @@ from waveform_transparent import *
 from waveform_contour import *
 from spectrogram_log import *
 from spectrogram_lin import *
+from render_analyzers import DisplayAubioPitch
\ No newline at end of file
index 550a51389bcfad512abbff45b32f9369d610fe43..ac416adf0c1df4f42603a34336d9cac44d6e4df9 100644 (file)
@@ -158,7 +158,11 @@ class Grapher(Processor):
     @interfacedoc
     def render(self, output=None):
         if output:
-            self.image.save(output)
+            try:
+                self.image.save(output)
+            except AttributeError:
+                print "Pixel %s x %d" % (self.image_width, self.image_height)
+                self.image.savefig(output, dpi=341)
             return
         return self.image