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 """
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)
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:
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