mirror of
https://github.com/romanz/amodem.git
synced 2026-03-28 05:49:08 +08:00
Refactor a bit
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user