def process(self, signalIn): signalOut = dspSignal.Signal(baseSig=signalIn) #TODO, must be updated so that samples betwen vector chunks are also interpolated #Setup data to be resampled, if there is an old sample, add to beginning of vector if self.lastIn is None: interpSamples = signalIn.samples else: interpSamples = np.hstack( (np.array([self.lastIn]), signalIn.samples)) timeAxis = np.arange(len(interpSamples)) / float(signalOut.rate) self.lastIn = None #signalIn.samples[-1] rsr = self.outputRate / float(signalIn.rate) numOutSamp = np.floor(len(timeAxis) * rsr) resampTime = np.arange(numOutSamp - rsr) / self.outputRate interpolator = scipy.interpolate.interp1d(timeAxis, interpSamples, assume_sorted=False) #print "ta", timeAxis #print "sa", interpSamples #print "rt", resampTime #print "rsr", rsr signalOut.samples = interpolator(resampTime) signalOut.rate = self.outputRate return signalOut
def process(self, signalIn): signalOut = dspSignal.Signal(baseSig=signalIn) phaseRate = 2.0 * np.pi * self.nco / signalIn.rate phases = (self.ph + np.arange(len(signalIn.samples)) * phaseRate) self.ph = phases[-1] + phaseRate signalOut.shift += self.nco signalOut.samples = signalIn.samples * np.exp(1j * phases) return signalOut
def process(self, signalIn): signalOut = dspSignal.Signal(baseSig=signalIn) allsample = np.hstack((self.rest, signalIn.samples)) outSample = np.floor(len(allsample) / self.factor) last = int(outSample * self.factor) signalOut.samples = allsample[0:last:self.factor] self.rest = allsample[last:] signalOut.rate /= float(self.factor) return signalOut
def process(self, signalIn): samples = [] while samples == []: samples = self.sndDev.getSamples(self.samples) time.sleep(0.001) #print samples if len(samples.shape) > 1: samples = samples[:,1] return dspSignal.Signal(samples=samples, domain='time', fc=0, rate = 44000, shift = 0)
def process(self, signalIn): signalOut = dspSignal.Signal(baseSig=signalIn) #t = np.arange(len(signalIn.samples))/float(signalIn.rate)+1.0/signalIn.rate+self.tlast #time rate = np.cumsum(np.real(signalIn.samples*self.s))/float(signalIn.rate) cp = np.pi*2*rate+self.plast #print cp #signalOut.samples = signalIn.samples*np.exp(-1.0j*np.pi*2.0*t) signalOut.samples = np.exp(1.0j*cp) self.plast = cp[-1]%(2.0*np.pi) return signalOut
def process(self, signalIn): #time.sleep(0.001) #tIdle = time.time()-self.tlast #t0 = time.time() samples = self.sdr.getSamples(self.samples) if samples is None: return None return dspSignal.Signal(samples=samples, domain='time', fc=self.fc, rate=self.rate, shift=0)
def process(self, signalIn): signalOut = signalIn if not self.fig.isReady(): return signalOut if self.nmax is None: nsamp = len(signalIn.samples) else: nsamp = min(len(signalIn.samples), self.nmax) signalOut = dspSignal.Signal(baseSig=signalIn) ft = np.fft.fftshift(np.fft.fft(signalIn.samples[0:nsamp])) db = np.clip(20 * np.log10(np.abs(ft)), -100, None) fax = np.linspace(-signalIn.rate, signalIn.rate, nsamp) - signalIn.shift self.fig.plot(fax, db) return signalOut
def process(self, signalIn): signalOut = dspSignal.Signal(baseSig=signalIn) ph = np.diff(np.unwrap(np.angle(signalIn.samples))) signalOut.samples = ph return signalOut
def process(self, signalIn): signalOut = dspSignal.Signal(baseSig=signalIn) signalOut.samples = signalIn.samples - np.mean(signalIn.samples) return signalOut
def process(self, signalIn): signalOut = dspSignal.Signal(baseSig=signalIn) signalOut.samples = self.processSimple(signalIn.samples) return signalOut