from rtlsdr import RtlSdr from multiprocessing import Process, Manager # Parameters fft_size = 512 # output size of fft, the input size is the samples_per_batch waterfall_samples = 100 # number of rows of the waterfall samples_per_batch = 256 * 1024 # num of samples that we process at a time samples_in_time_plots = 500 # should be less than samples_per_batch # RTL-SDR stuff sdr = RtlSdr() sdr.sample_rate = 2.048e6 # Hz sdr.center_freq = 101.1e6 # Hz sdr.freq_correction = 60 # PPM sdr.gain = sdr.get_gains()[-1] / 10.0 # highest gain to start with # Set up the shared buffer between threads (using multiprocessing's Manager). it is global manager = Manager() shared_buffer = manager.dict() # there is also an option to use a list shared_buffer['waterfall'] = np.ones( (waterfall_samples, fft_size)) * -100.0 # waterfall buffer shared_buffer['psd'] = np.zeros(fft_size) # PSD buffer shared_buffer['i'] = np.zeros(samples_in_time_plots) # I buffer (time domain) shared_buffer['q'] = np.zeros(samples_in_time_plots) # Q buffer (time domain) shared_buffer[ 'stop-signal'] = False # used to signal RTL to stop (when it goes true) shared_buffer[ 'utilization'] = 0.0 # float between 0 and 1, used to store how the process_samples is keeping up # create a streaming-type FIR filter (this should act the same as a FIR filter block in GNU Radio)