def test_resample(): x = np.sin(2*np.pi * 10 * np.linspace(0, 1, 1001)) src = BytesIO(common.dumps(x)) dst = BytesIO() sampling.resample(src=src, dst=dst, df=0.0) y = common.loads(dst.getvalue()) err = x[:len(y)] - y assert np.max(np.abs(err)) < 1e-4 dst = BytesIO() sampling.resample(src=BytesIO(b'\x00\x00'), dst=dst, df=0.0) assert dst.tell() == 0
def test_resample(): x = np.sin(2 * np.pi * 10 * np.linspace(0, 1, 1001)) src = BytesIO(common.dumps(x)) dst = BytesIO() sampling.resample(src=src, dst=dst, df=0.0) y = common.loads(dst.getvalue()) err = x[:len(y)] - y assert np.max(np.abs(err)) < 1e-4 dst = BytesIO() sampling.resample(src=BytesIO(b'\x00\x00'), dst=dst, df=0.0) assert dst.tell() == 0
def run(size, chan=None, df=0, success=True, cfg=None): if cfg is None: cfg = config.slowest() tx_data=get_bigger_string(10000) tx_audio = BytesIO() main.send(config=cfg, src=BytesIO(tx_data), dst=tx_audio, gain=0.5) with open('rx_data.wav','w') as f: f.write(tx_audio.getvalue()) f.flush() dst = BytesIO() sampling.resample(src=tx_audio, dst=dst, df=50.0)
def main(): p = argparse.ArgumentParser() p.add_argument('df', type=float) args = p.parse_args() resample(src=sys.stdin, dst=sys.stdout, df=args.df)