예제 #1
0
 def start(self):
     self.p = pyaudio.PyAudio()
     self.stream = self.p.open(format=pyaudio.paFloat32,
                               channels=1,
                               rate=int(self.fs),
                               output=True)
     Module.start(self)
예제 #2
0
    def __init__(self, *args, **kwargs):
        Module.__init__(self, *args, **kwargs)
        self.chunk_size = 2**9
        for kw in kwargs:
            if kw == 'chunk_size':
                self.chunk_size = kwargs[kw]

        self.save = None
예제 #3
0
 def __init__(self, *args, **kwargs):
     Module.__init__(self, *args, **kwargs)
     self.chunk_size = 2**10
     self.fs = 44.1E3
     for kw in kwargs:
         if kw == 'chunk_size':
             self.chunk_size = kwargs[kw]
         if kw == 'fs':
             self.fs = kwargs[kw]
예제 #4
0
 def start(self):
     self.p = pyaudio.PyAudio()
     self.stream = self.p.open(format=pyaudio.paFloat32,
                               channels=1,
                               rate=int(self.fs),
                               input=True,
                               frames_per_buffer=self.chunk_size,
                               stream_callback=self.callback)
     self.stream.start_stream()
     Module.start(self)
예제 #5
0
 def __init__(self, *args, **kwargs):
     kw = ''
     try:
         kw = 'bcoef'
         self.bcoef = np.array(kwargs[kw])
     except KeyError as kerr:
         self.print_kw_error(kw)
         raise kerr
     self.history = np.zeros(len(self.bcoef))
     Module.__init__(self, *args, **kwargs)
예제 #6
0
 def __init__(self, *args, **kwargs):
     Module.__init__(self, *args, **kwargs)
     fs = 44.1E3
     M = kwargs['M']
     self.gain = 30.0
     peak_tau = M * 200.0 / fs
     lowp_tau = M * 400.0 / fs
     self.peak = PeakDetect(peak_tau, fs)
     self.comp = Comparator(1.0, self.gain, 0.0)
     self.lowp = LowPass(lowp_tau, fs)
     self.init = time()
     self.timeout = 10.0
     self.rssi = 0
예제 #7
0
 def __init__(self, *args, **kwargs):
     Module.__init__(self, *args, **kwargs)
     self.disable = False
     kw = ''
     try:
         kw = 'cipher'
         self.cipher = kwargs[kw]
         self.n = len(self.cipher)
         self.incomplete = 0
         for kw in kwargs:
             if kw == 'disable':
                 self.disable = kwargs[kw]
     except KeyError as ke:
         self.print_kw_error(kw)
         raise (kw)
예제 #8
0
    def __init__(self, *args, **kwargs):
        Module.__init__(self, *args, **kwargs)
        self.alphabet = [-3, -1, 1, 3]
        try:
            self.M = int(kwargs['M'])
            self.log('M: %d' % self.M)
        except KeyError as ke:
            print self.FAIL + 'You must pass ' + str(
                ke) + ' as key word argument'
            raise ke

        #self.offset = int(np.random.rand()*2*self.M)
        self.save1 = 0
        self.save2 = 0
        self.save3 = 0
        self.offset = 1
예제 #9
0
	def __init__(self, *args, **kwargs):
		Module.__init__(self, *args, **kwargs)
		self.maxbyt = 2**16
		bits = 10 
		for kw in kwargs:
			if kw == 'bits':
				bits = int(kwargs[kw])
		self.prefix = maximumlength(bits) 
		self.cipher = self.make_cipher()
		self.prepam = self.num2pam(self.cipher)
		if self.debug and self.plt is not None:
			self.plt.figure(self.fig)
			self.plt.gcf().clf()
			self.plt.stem(self.prepam)
			self.plt.title('Initialization: Prefix PAM Header')
			self.plt.show(block=False)
		# formats the maximum length sequence as little endian
		self.whiten = Whitener(cipher = self.cipher, disable = False)
예제 #10
0
	def __init__(self, *args, **kwargs):
		Module.__init__(self, *args, **kwargs)
		self.fc = 11E3
		self.fs = 44.1E3
		for key in kwargs:
			if key == 'fc':
				self.fc = float(kwargs['fc'])
			elif key == 'fs':
				self.fs = float(kwargs['fs'])

		CostasLoopC.init(self.fc, self.fs)
		self.costa = CostasLoop(self.fc, self.fs, self.debug)
		if self.debug:
			self.ip_lp = LowPass(10, self.fs)
			self.qp_lp = LowPass(10, self.fs)
	
		#self.fc = fround(self.fc, self.fs)
		#self.log('fcenter: %.3f Hz'%self.fc)
		self.loop_time = 0
예제 #11
0
	def __init__(self, *args, **kwargs):
		Module.__init__(self, *args, **kwargs)
		kw = ''
		try:
			kw = 'fs'
			self.fs = float(kwargs['fs'])
			del kwargs['fs']

			kw = 'fc'
			self.fc = float(kwargs['fc'])
			self.osc_phase = Integrator(self.fc/self.fs)
			del kwargs['fc']

			self.offset = 0
			if kwargs.has_key('offset'):
				self.offset = float(kwargs['offset'])

			if self.box is not None:
				self.box_fc = self.box.add_label('fm: %.1f'%self.fc)

		except KeyError as ke:
			self.print_kw_error(kw)
			raise ke
예제 #12
0
 def quit(self, all):
     self.stream.stop_stream()
     self.stream.close()
     self.p.terminate()
     Module.quit(self, all)
예제 #13
0
 def reset(self):
     Module.reset(self)
     self.incomplete = 0
예제 #14
0
	def reset(self):
		Module.reset(self)
		#self.incomplete = 0
		osc_phase.reset()