Refactor a bit

This commit is contained in:
Roman Zeyde
2014-06-27 18:23:12 +03:00
parent b276440b01
commit 5a854be751
7 changed files with 24 additions and 17 deletions

View File

@@ -34,7 +34,11 @@ def to_bytes(bits):
return chr(byte)
def load(fname):
x = np.fromfile(open(fname, 'rb'), dtype='int16')
data = open(fname, 'rb').read()
return loads(data)
def loads(data):
x = np.fromstring(data, dtype='int16')
x = x / scaling
t = np.arange(len(x)) / Fs
return t, x
@@ -45,6 +49,9 @@ def dumps(sym, n=1):
data = sym.tostring()
return data * n
def norm(x):
return np.sqrt(np.dot(x.conj(), x).real)
if __name__ == '__main__':
import pylab