mirror of
https://github.com/romanz/amodem.git
synced 2026-04-19 04:36:02 +08:00
fix common.load()
This commit is contained in:
@@ -33,9 +33,8 @@ def to_byte(bits):
|
|||||||
byte = int(np.dot(bits, bit_weights))
|
byte = int(np.dot(bits, bit_weights))
|
||||||
return chr(byte)
|
return chr(byte)
|
||||||
|
|
||||||
def load(fname):
|
def load(fileobj):
|
||||||
data = open(fname, 'rb').read()
|
return loads(fileobj.read())
|
||||||
return loads(data)
|
|
||||||
|
|
||||||
def loads(data):
|
def loads(data):
|
||||||
x = np.fromstring(data, dtype='int16')
|
x = np.fromstring(data, dtype='int16')
|
||||||
|
|||||||
2
drift.py
2
drift.py
@@ -28,7 +28,7 @@ import pylab
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
f0 = 10e3
|
f0 = 10e3
|
||||||
_, x = common.load('recv_10kHz.pcm')
|
_, x = common.load(file('recv_10kHz.pcm', 'rb'))
|
||||||
x = x[100:]
|
x = x[100:]
|
||||||
|
|
||||||
S = []
|
S = []
|
||||||
|
|||||||
2
recv.py
2
recv.py
@@ -128,7 +128,7 @@ def constellation(y):
|
|||||||
|
|
||||||
def main(fname):
|
def main(fname):
|
||||||
|
|
||||||
_, x = load(fname)
|
_, x = load(open(fname, 'rb'))
|
||||||
result = detect(x, Fc)
|
result = detect(x, Fc)
|
||||||
if result is None:
|
if result is None:
|
||||||
log.info('No carrier detected')
|
log.info('No carrier detected')
|
||||||
|
|||||||
2
show.py
2
show.py
@@ -13,7 +13,7 @@ if __name__ == '__main__':
|
|||||||
import common
|
import common
|
||||||
|
|
||||||
for fname in sys.argv[1:]:
|
for fname in sys.argv[1:]:
|
||||||
t, x = common.load(fname)
|
t, x = common.load(open(fname, 'rb'))
|
||||||
pylab.figure()
|
pylab.figure()
|
||||||
pylab.title(fname)
|
pylab.title(fname)
|
||||||
spectrogram(t, x, common.Fs)
|
spectrogram(t, x, common.Fs)
|
||||||
|
|||||||
Reference in New Issue
Block a user