]> git.parisson.com Git - timeside.git/commitdiff
feat(irit_monopoly.py): blocksize and stepsize are now set from aubio_pitch
authorThomas Fillon <thomas@parisson.com>
Thu, 19 Jun 2014 13:58:56 +0000 (15:58 +0200)
committerThomas Fillon <thomas@parisson.com>
Thu, 19 Jun 2014 13:58:56 +0000 (15:58 +0200)
timeside/analyzer/irit_monopoly.py

index cc24a1fec3234ad991704be2845a571f1be1ccce..2afe821b9744873858a58a7ab508adc56b26c8e5 100644 (file)
@@ -40,13 +40,15 @@ class IRITMonopoly(Analyzer):
     def __init__(self):
         super(IRITMonopoly, self).__init__()
 
-        self.parents.append(AubioPitch())
-
         # Irit Monopoly parameters
         self.decisionLen = 1.0
         self.wLen = 0.1
         self.wStep = 0.05
 
+        self._aubio_pitch_analyzer = AubioPitch(blocksize_s=self.wLen,
+                                                stepsize_s=self.wStep)
+        self.parents.append(self._aubio_pitch_analyzer)
+
     @interfacedoc
     def setup(self, channels=None, samplerate=None,
               blocksize=None, totalframes=None):
@@ -55,8 +57,8 @@ class IRITMonopoly(Analyzer):
                                         blocksize,
                                         totalframes)
 
-        self.input_blocksize = int(self.wLen * samplerate)
-        self.input_stepsize = int(self.wStep * samplerate)
+        self.input_blocksize = self._aubio_pitch_analyzer.input_blocksize
+        self.input_stepsize = self._aubio_pitch_analyzer.input_stepsize
 
     @staticmethod
     @interfacedoc
@@ -118,7 +120,7 @@ class IRITMonopoly(Analyzer):
 
         segs.label_metadata.label = label
         segs.data_object.label = [convert[s[2]] for s in segList]
-        segs.data_object.time = [(float(s[0]+0.5) *  self.decisionLen)
+        segs.data_object.time = [(float(s[0]+0.5) * self.decisionLen)
                                  for s in segList]
 
         segs.data_object.duration = [(float(s[1] - s[0]+1) * self.decisionLen)
@@ -133,7 +135,8 @@ class IRITMonopoly(Analyzer):
         beta1 = 0.5955
         beta2 = 0.2821
         delta = 0.848
-        return self.weibullLikelihood(m, v, theta1, theta2, beta1, beta2, delta)
+        return self.weibullLikelihood(m, v, theta1, theta2, beta1, beta2,
+                                      delta)
 
     def polyLikelihood(self, m, v):
         theta1 = 0.3224
@@ -141,7 +144,8 @@ class IRITMonopoly(Analyzer):
         beta1 = 1.889
         beta2 = 0.8705
         delta = 0.644
-        return self.weibullLikelihood(m, v, theta1, theta2, beta1, beta2, delta)
+        return self.weibullLikelihood(m, v, theta1, theta2, beta1, beta2,
+                                      delta)
 
     def weibullLikelihood(self, m, v, theta1, theta2, beta1, beta2, delta):
         m = numpy.array(m)
@@ -151,11 +155,13 @@ class IRITMonopoly(Analyzer):
         a1 = m / theta1
         b1 = a1 ** (beta1 / delta)
         c1 = numpy.log(a1)
+
         a2 = v / theta2
         b2 = a2 ** (beta2 / delta)
         c2 = numpy.log(a2)
         somme1 = (b1 + b2) ** delta
-        Pxy = c0 + (beta1 / delta - 1) * c1 + (beta2 / delta - 1) * c2 + (delta - 2) * \
-            numpy.log(b1 + b2) + numpy.log(somme1 + 1 / delta - 1) - somme1
+        Pxy = c0 + (beta1 / delta - 1) * c1 + (beta2 / delta - 1) * c2 +\
+            (delta - 2) * numpy.log(b1 + b2) +\
+            numpy.log(somme1 + 1 / delta - 1) - somme1
 
         return numpy.mean(Pxy)