]> git.parisson.com Git - timeside.git/commitdiff
add dc and men_level analyzers, fix max_level
authoryomguy <yomguy@parisson.com>
Sun, 29 Aug 2010 22:43:04 +0000 (22:43 +0000)
committeryomguy <yomguy@parisson.com>
Sun, 29 Aug 2010 22:43:04 +0000 (22:43 +0000)
timeside/analyzer/__init__.py
timeside/analyzer/dc.py
timeside/analyzer/duration.py
timeside/analyzer/max_level.py
timeside/analyzer/mean_level.py

index 6259160db7d5b698a1d9cd0da0dc52c47863ea2a..19db5e368bb28b9cec344f1bc82430df61526966 100644 (file)
@@ -1,8 +1,9 @@
-# -*- coding: utf-8 -*-
+    # -*- coding: utf-8 -*-
 
 from core import *
+
 from duration import *
 from max_level import *
+from mean_level import *
+from dc import *
 
-#from timeside.analyzer.mean_level import *
-#from timeside.analyzer.dc import *
index e92cfd5300e0a911e17b9aab7abe7d507857616c..d293d76cc195bc1728a031fb4fe2b078d49e8415 100644 (file)
 
 # Author: Guillaume Pellerin <yomguy@parisson.com>
 
+from timeside.core import Processor, implements, interfacedoc, FixedSizeInputAdapter
 from timeside.analyzer.core import *
 from timeside.api import IValueAnalyzer
 import numpy
 
-
 class MeanDCShift(Processor):
     implements(IValueAnalyzer)
 
@@ -51,7 +51,7 @@ class MeanDCShift(Processor):
         return "%s %s" % (str(self.value), unit())
 
     def process(self, frames, eod=False):
-        self.value = numpy.round(100*numpy.mean(samples),4)
+        self.value = numpy.round(100*numpy.mean(frames),3)
         return frames, eod
 
     def result(self):
index 7c2269c11019a0a6d4adfc85773bfd02d041ae35..47aa59e3d67ad6535bfdec287c3885272675e857 100644 (file)
@@ -49,7 +49,13 @@ class Duration(Processor):
     @interfacedoc
     def unit():
         return "seconds"
+    
+    def __str__(self):
+        return "%s %s" % (str(self.value), unit())
 
+    def process(self, frames, eod=False):
+        return frames, eod
+    
     def result(self):
         return self.input_nframes / float(self.input_samplerate)
-    
\ No newline at end of file
+    
index 9ecc323bcfcef55d1c877feaa40f21f587ca9a45..58ea322b1a1d70bc3ea7614be8bc1f181c70f830 100644 (file)
@@ -23,6 +23,7 @@
 from timeside.core import Processor, implements, interfacedoc, FixedSizeInputAdapter
 from timeside.analyzer.core import *
 from timeside.api import IValueAnalyzer
+import numpy
 
 
 class MaxLevel(Processor):
@@ -31,7 +32,7 @@ class MaxLevel(Processor):
     @interfacedoc
     def setup(self, channels=None, samplerate=None, nframes=None):
         super(MaxLevel, self).setup(channels, samplerate, nframes)
-        self.max_value = 0
+        self.value = 0
 
     @staticmethod
     @interfacedoc
@@ -46,17 +47,15 @@ class MaxLevel(Processor):
     @staticmethod
     @interfacedoc
     def unit():
-        # power? amplitude?
-        return ""
+        return "dB"
 
     def process(self, frames, eod=False):
-        max = frames.max()
-        if max > self.max_value:
+        max = round(20*numpy.log(frames.max()), 3)
+        if max > self.value:
             self.max_value = max
-
         return frames, eod
 
     def result(self):
-        return self.max_value
+        return self.value
 
 
index 8b683244e41061db973556421e7a8f57dec81e62..9d114f01c4d53d2aa9215e0030e335e8dbe84c00 100644 (file)
@@ -19,6 +19,7 @@
 
 # Author: Guillaume Pellerin <yomguy@parisson.com>
 
+from timeside.core import Processor, implements, interfacedoc, FixedSizeInputAdapter
 from timeside.analyzer.core import *
 from timeside.api import IValueAnalyzer
 import numpy
@@ -51,12 +52,10 @@ class MeanLevel(Processor):
         return "%s %s" % (str(self.value), unit())
 
     def process(self, frames, eod=False):
-        max = numpy.round(20*numpy.log10(numpy.mean(numpy.sqrt(numpy.square(frames.max())))), 2)
-        if max > self.value:
-            self.value = max
-
+        value = numpy.round(20*numpy.log10(numpy.mean(numpy.sqrt(numpy.square(frames)))), 3)
+        if value > self.value:
+            self.value = value
         return frames, eod
 
     def result(self):
         return self.value
-