mirror of
https://github.com/romanz/amodem.git
synced 2026-04-21 05:36:42 +08:00
make useful scripts executable
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import common
|
import common
|
||||||
import sigproc
|
import sigproc
|
||||||
|
|||||||
1
errors.py
Normal file → Executable file
1
errors.py
Normal file → Executable file
@@ -1,3 +1,4 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
import common
|
import common
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|||||||
3
recv.py
Normal file → Executable file
3
recv.py
Normal file → Executable file
@@ -1,3 +1,4 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import logging
|
import logging
|
||||||
import itertools
|
import itertools
|
||||||
@@ -145,6 +146,8 @@ def receive(signal, freqs):
|
|||||||
|
|
||||||
def main(fname):
|
def main(fname):
|
||||||
|
|
||||||
|
log.info('Running MODEM @ {:.1f} kbps'.format(sigproc.modem_bps / 1e3))
|
||||||
|
|
||||||
_, x = load(open(fname, 'rb'))
|
_, x = load(open(fname, 'rb'))
|
||||||
result = detect(x, Fc)
|
result = detect(x, Fc)
|
||||||
if result is None:
|
if result is None:
|
||||||
|
|||||||
21
send.py
Normal file → Executable file
21
send.py
Normal file → Executable file
@@ -1,10 +1,10 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
logging.basicConfig(level=0, format='%(message)s')
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
import sigproc
|
import sigproc
|
||||||
@@ -42,11 +42,9 @@ def modulate(sig, bits):
|
|||||||
if all(symbols == 0):
|
if all(symbols == 0):
|
||||||
break
|
break
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def main():
|
||||||
|
|
||||||
import ecc
|
import ecc
|
||||||
bps = baud * sigproc.modulator.bits_per_symbol * len(sym.carrier)
|
log.info('Running MODEM @ {:.1f} kbps'.format(sigproc.modem_bps / 1e3))
|
||||||
log.info('Running MODEM @ {:.1f} kbps'.format(bps / 1e3))
|
|
||||||
|
|
||||||
with open('tx.int16', 'wb') as fd:
|
with open('tx.int16', 'wb') as fd:
|
||||||
start(fd, sym.carrier[carrier_index])
|
start(fd, sym.carrier[carrier_index])
|
||||||
@@ -56,13 +54,6 @@ if __name__ == '__main__':
|
|||||||
bits = to_bits(ecc.encode(data))
|
bits = to_bits(ecc.encode(data))
|
||||||
modulate(fd, bits)
|
modulate(fd, bits)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
from wave import play, record
|
logging.basicConfig(level=logging.DEBUG, format='%(message)s')
|
||||||
|
main()
|
||||||
r = record('rx.int16')
|
|
||||||
start = time.time()
|
|
||||||
p = play(fd.name)
|
|
||||||
p.wait()
|
|
||||||
log.debug('Took %.2f seconds', time.time() - start)
|
|
||||||
time.sleep(1)
|
|
||||||
r.stop()
|
|
||||||
|
|||||||
1
show.py
Normal file → Executable file
1
show.py
Normal file → Executable file
@@ -1,3 +1,4 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
import pylab
|
import pylab
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ _xs, _ys = np.linspace(-1, 1, 4), np.linspace(-1, 1, 4) # QAM-16
|
|||||||
_symbols = np.array([complex(x, y) for x in _xs for y in _ys]) * np.sqrt(0.5)
|
_symbols = np.array([complex(x, y) for x in _xs for y in _ys]) * np.sqrt(0.5)
|
||||||
modulator = QAM(_symbols)
|
modulator = QAM(_symbols)
|
||||||
|
|
||||||
|
modem_bps = common.baud * modulator.bits_per_symbol * len(common.frequencies)
|
||||||
|
|
||||||
def clip(x, lims):
|
def clip(x, lims):
|
||||||
return min(max(x, lims[0]), lims[1])
|
return min(max(x, lims[0]), lims[1])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user