Exemplo n.º 1
0
 def init(self):
     self.channels = 2
     self.channel = self.kwargs['channel']
     self.packetSource = self.kwargs['packetSource']
     cutoff = self.channel.Fc + self.channel.Fs/self.channel.upsample_factor
     self.hp = [iir.highpass(cutoff/self.channel.Fs, continuous=True, dtype=np.float64) for i in range(2)]
     super(ContinuousTransmitter, self).init()
Exemplo n.º 2
0
 def init(self):
     self.channels = 2
     self.i = 0
     cutoff = Fc - Fs / upsample_factor
     self.hp = [
         iir.highpass(cutoff / Fs, continuous=True, dtype=np.float64)
         for i in range(2)
     ]
     super(ContinuousTransmitter, self).init()
Exemplo n.º 3
0
 def init(self):
     self.channels = 2
     self.channel = self.kwargs['channel']
     self.packetSource = self.kwargs['packetSource']
     cutoff = self.channel.Fc + self.channel.Fs / self.channel.upsample_factor
     self.hp = [
         iir.highpass(cutoff / self.channel.Fs,
                      continuous=True,
                      dtype=np.float64) for i in range(2)
     ]
     super(ContinuousTransmitter, self).init()
Exemplo n.º 4
0
def prepareMaskNoise(fn, Fs, Fc, upsample_factor):
    f = wave.open(fn)
    nframes = f.getnframes()
    dtype = [None, np.uint8, np.int16, None, np.int32][f.getsampwidth()]
    frames = np.fromstring(f.readframes(nframes), dtype).astype(float)
    frames = frames.reshape(nframes, f.getnchannels())
    frames = frames.mean(1)
    frames = util.upsample(frames, Fs / f.getframerate())
    frames /= np.amax(np.abs(frames))
    # band-stop filter for data
    frames *= np.exp(-1j * 2 * np.pi * np.arange(frames.size) * Fc / Fs)
    frames = iir.highpass(.8 / upsample_factor)(frames)
    frames *= np.exp(2j * 2 * np.pi * np.arange(frames.size) * Fc / Fs)
    frames = iir.highpass(.8 / upsample_factor)(frames)
    frames *= np.exp(-1j * 2 * np.pi * np.arange(frames.size) * Fc / Fs)
    frames = frames.real
    # look for beginning and end of noise
    envelope = iir.lowpass(.01)(np.r_[np.zeros(6), np.abs(frames)])[6:]
    start = np.where(envelope > np.amax(envelope) * .01)[0][0]
    end = np.where(envelope > np.amax(envelope) * 1e-3)[0][-1]
    return frames[start:end]
Exemplo n.º 5
0
def prepareMaskNoise(fn, Fs, Fc, upsample_factor):
    f = wave.open(fn)
    nframes = f.getnframes()
    dtype = [None, np.uint8, np.int16, None, np.int32][f.getsampwidth()]
    frames = np.fromstring(f.readframes(nframes), dtype).astype(float)
    frames = frames.reshape(nframes, f.getnchannels())
    frames = frames.mean(1)
    frames = util.upsample(frames, Fs/f.getframerate())
    frames /= np.amax(np.abs(frames))
    # band-stop filter for data
    frames *= np.exp(-1j * 2 * np.pi * np.arange(frames.size) * Fc / Fs)
    frames = iir.highpass(.8/upsample_factor)(frames)
    frames *= np.exp(2j * 2 * np.pi * np.arange(frames.size) * Fc / Fs)
    frames = iir.highpass(.8/upsample_factor)(frames)
    frames *= np.exp(-1j * 2 * np.pi * np.arange(frames.size) * Fc / Fs)
    frames = frames.real
    # look for beginning and end of noise
    envelope = iir.lowpass(.01)(np.r_[np.zeros(6), np.abs(frames)])[6:]
    start = np.where(envelope > np.amax(envelope)*.01)[0][0]
    end = np.where(envelope > np.amax(envelope)*1e-3)[0][-1]
    return frames[start:end]
Exemplo n.º 6
0
 def init(self):
     self.channels = 2
     self.i = 0
     cutoff = Fc - Fs/upsample_factor
     self.hp = [iir.highpass(cutoff/Fs, continuous=True, dtype=np.float64) for i in range(2)]
     super(ContinuousTransmitter, self).init()