def test_random(): r = random.Random(0) x = bytearray(r.randrange(0, 256) for i in range(16 * 1024)) y = ecc.encode(x) x_ = concat(ecc.decode(y)) assert x_[: len(x)] == x assert all(v == 0 for v in x_[len(x) :])
def main(args): import ecc log.info('Running MODEM @ {:.1f} kbps'.format(modem.modem_bps / 1e3)) fd = sys.stdout # padding audio with silence writer.write(fd, np.zeros(int(config.Fs * args.silence_start))) start(fd, sym.carrier[config.carrier_index]) for c in sym.carrier: training(fd, c) training_size = writer.offset log.info('%.3f seconds of training audio', training_size / wave.bytes_per_second) reader = Reader(sys.stdin, 64 << 10) data = itertools.chain.from_iterable(reader) encoded = itertools.chain.from_iterable(ecc.encode(data)) modulate(fd, bits=common.to_bits(encoded)) data_size = writer.offset - training_size log.info('%.3f seconds of data audio, for %.3f kB of data', data_size / wave.bytes_per_second, reader.total / 1e3) # padding audio with silence writer.write(fd, np.zeros(int(config.Fs * args.silence_stop)))
def test_file(): data = open("data.send").read() enc = ecc.encode(data) assert concat(ecc.decode(enc)) == data