예제 #1
0
#!/usr/bin/env python
import numpy as np
import util
delay = .005
Fs = 48000
reps = 100
tail_samples = int(Fs * 2.)
delay_samples = int(delay * Fs)
signal = np.tile(
    np.r_[np.random.standard_normal(Fs * 2) * .1,
          np.zeros(Fs * 2)], reps)
signal = np.vstack((np.r_[np.zeros(delay_samples),
                          signal], np.r_[signal,
                                         np.zeros(delay_samples)])).T
signal = np.vstack((signal, np.zeros((tail_samples, 2))))
util.writewave('noise.wav', signal, Fs, 3)
예제 #2
0
파일: blurt.py 프로젝트: homelee/blurt
            if doDiagnostics:
                decoderDiagnostics()
        elif args[0] == '--tx':
            startTransmitting()
        elif args[0] == '--wav-in' and len(args) > 1:
            input, Fs_file = util.readwave(args[1])
            input = util.upsample(input, Fs / float(Fs_file))
            input = audioLoopback.processInput(input, Fs, Fc, upsample_factor)
            for payload,_,_,lsnr_estimate in wifi.decode(input)[0]:
                print(repr(''.join(map(chr, payload))) + (' @ %.1f dB' % lsnr_estimate))
        elif args[0] == '--wav-out' and len(args) > 1:
            fn = args[1]
            args = args[2:]
            packets = 1
            while len(args):
                if args[0] == '--packets':
                    packets = int(args[1])
                    args = args[2:]
            outputChunks = []
            for i in xrange(packets):
                input_octets = ord('A') + np.random.random_integers(0,25,length)
                input_octets[:6] = map(ord, '%06d' % i)
                output = audioLoopback.processOutput(wifi.encode(input_octets, rate), Fs, Fc, upsample_factor, mask_noise)
                output *= 1 / np.abs(output).max()
                outputChunks.append(output)
                outputChunks.append(np.zeros((Fs/10, outputChunks[0].shape[1])))
            outputChunks.append(np.zeros((Fs/2, outputChunks[0].shape[1])))
            output = np.vstack(outputChunks)
            bytesPerSample = 3
            util.writewave(fn, output, Fs, bytesPerSample)
예제 #3
0
#!/usr/bin/env python
import numpy as np
import util
delay = .005
Fs = 48000
reps = 100
tail_samples = int(Fs*2.)
delay_samples = int(delay*Fs)
signal = np.tile(np.r_[np.random.standard_normal(Fs*2)*.1, np.zeros(Fs*2)], reps)
signal = np.vstack((np.r_[np.zeros(delay_samples), signal], np.r_[signal, np.zeros(delay_samples)])).T
signal = np.vstack((signal, np.zeros((tail_samples, 2))))
util.writewave('noise.wav', signal, Fs, 3)
예제 #4
0
            input = util.upsample(input, Fs / float(Fs_file))
            input = audioLoopback.processInput(input, Fs, Fc, upsample_factor)
            for payload, _, _, lsnr_estimate in wifi.decode(input)[0]:
                print(
                    repr(''.join(map(chr, payload))) +
                    (' @ %.1f dB' % lsnr_estimate))
        elif args[0] == '--wav-out' and len(args) > 1:
            fn = args[1]
            args = args[2:]
            packets = 1
            while len(args):
                if args[0] == '--packets':
                    packets = int(args[1])
                    args = args[2:]
            outputChunks = []
            for i in xrange(packets):
                input_octets = ord('A') + np.random.random_integers(
                    0, 25, length)
                input_octets[:6] = map(ord, '%06d' % i)
                output = audioLoopback.processOutput(
                    wifi.encode(input_octets, rate), Fs, Fc, upsample_factor,
                    mask_noise)
                output *= 1 / np.abs(output).max()
                outputChunks.append(output)
                outputChunks.append(
                    np.zeros((Fs / 10, outputChunks[0].shape[1])))
            outputChunks.append(np.zeros((Fs / 2, outputChunks[0].shape[1])))
            output = np.vstack(outputChunks)
            bytesPerSample = 3
            util.writewave(fn, output, Fs, bytesPerSample)