skip initial spikes

This commit is contained in:
Roman Zeyde
2014-07-21 13:58:35 +03:00
parent 871ec8bb46
commit 194a967cc3
3 changed files with 21 additions and 16 deletions

View File

@@ -46,6 +46,12 @@ class SaturationError(ValueError):
pass
def check_saturation(x):
peak = np.max(np.abs(x))
if peak > SATURATION_THRESHOLD:
raise SaturationError(peak)
def load(fileobj, time=False):
return loads(fileobj.read(), time=time)
@@ -53,10 +59,6 @@ def load(fileobj, time=False):
def loads(data, time=False):
x = np.fromstring(data, dtype='int16')
x = x / scaling
peak = np.max(np.abs(x))
if peak > SATURATION_THRESHOLD:
raise SaturationError(peak)
if time:
t = np.arange(len(x)) / Fs
return t, x
@@ -121,6 +123,10 @@ def icapture(iterable, result):
result.append(i)
yield i
def take(iterable, n):
return np.array(list(itertools.islice(iterable, n)))
if __name__ == '__main__':
import pylab