]> git.parisson.com Git - telemeta.git/commitdiff
* Fix syntax
authoryomguy <>
Thu, 21 Aug 2008 15:16:03 +0000 (15:16 +0000)
committeryomguy <>
Thu, 21 Aug 2008 15:16:03 +0000 (15:16 +0000)
telemeta/analysis/core.py

index 7b8dca0872c4b46efb2bd5d55b127edc4a1c9885..5ccf68c1e276a26cc45453bbdfcecbbc74baba66 100644 (file)
@@ -52,7 +52,7 @@ class AudioProcessor(Component):
             samples = samples[:,0]
         return samples    
         
-    def read(self, start, size, resize_if_less=False):
+def read(self, start, size, resize_if_less=False):
         """ read size samples starting at start, if resize_if_less is True and less than size
         samples are read, resize the array to size and fill with zeros """
         
@@ -63,7 +63,10 @@ class AudioProcessor(Component):
         if start < 0:
             # the first FFT window starts centered around zero
             if size + start <= 0:
-                return numpy.zeros(size) if resize_if_less else numpy.array([])
+                if resize_if_less:
+                    return numpy.zeros(size)
+                else:
+                    return numpy.array([])
             else:
                 self.audio_file.seek(0)
 
@@ -85,7 +88,10 @@ class AudioProcessor(Component):
             samples = self.audio_file.read_frames(to_read)
         except IOError:
             # this can happen for wave files with broken headers...
-            return numpy.zeros(size) if resize_if_less else numpy.zeros(2)
+            if resize_if_less:
+                return numpy.zeros(size)
+            else:
+                return numpy.zeros(2)
 
         # convert to mono by selecting left channel only
         if self.channels > 1:
@@ -175,8 +181,11 @@ class AudioProcessor(Component):
             if local_min_value < min_value:
                 min_value = local_min_value
                 min_index = local_min_index
-    
-        return (min_value, max_value) if min_index < max_index else (max_value, min_value)
+
+        if min_index < max_index:
+            return (min_value, max_value)
+        else:
+            return (max_value, min_value)
 
 
         
\ No newline at end of file