text: #!/usr/bin/env python3
  # -*- coding: utf-8 -*-
  
  #
  # SPDX-License-Identifier: GPL-3.0
  #
  # GNU Radio Python Flow Graph
  # Title: Not titled yet
  # Author: yegres
  # GNU Radio version: 3.8.1.0
  
  from pty import slave_open
  from gnuradio import analog
  from gnuradio import blocks
  from gnuradio import filter
  from gnuradio.filter import firdes
  from gnuradio import gr
  import sys
  import signal
  from argparse import ArgumentParser
  from gnuradio.eng_arg import eng_float, intx
  from gnuradio import eng_notation
  import datetime
  import osmosdr
  import time
  
  
  # первый аргумент - центральная частота 
  # второй аргумент - ширина полосы записи (нормальная без деления на два)
  # третий аргумент - длительность записи (в секундах)
  
  
  class test1(gr.top_block):
  
      def __init__(self):
          global sleep_to_write
          gr.top_block.__init__(self, "Not titled yet")
  
          ##################################################
          # Variables
          ##################################################
          self.width = width = 100000
          self.samp_rate = samp_rate = 3000000
          temp_freq = float(sys.argv[1]) # Частота 
          temp_cutoff = float(sys.argv[2] // 2) # ширина полосы 
          sleep_to_write = int(sys.argv[3])
          self.freq_0 = freq_0 = temp_freq
          self.freq = freq = temp_freq
          self.file_name = file_name = f"/data/REC_{str(freq)[:6]}_{datetime.datetime.now().replace(microsecond=0).isoformat().replace('T', '_').replace(':', '-')}.wav"
          self.cutoff = cutoff = temp_cutoff
          self.audio_rate = audio_rate = 50000
  
          ##################################################
          # Blocks
          ##################################################
          self.rtlsdr_source_0 = osmosdr.source(
              args="numchan=" + str(1) + " " + 'driver="airspy"'
          )
          self.rtlsdr_source_0.set_time_unknown_pps(osmosdr.time_spec_t())
          self.rtlsdr_source_0.set_sample_rate(samp_rate)
          self.rtlsdr_source_0.set_center_freq(freq, 0)
          self.rtlsdr_source_0.set_freq_corr(0, 0)
          self.rtlsdr_source_0.set_gain(20, 0)
          self.rtlsdr_source_0.set_if_gain(10, 0)
          self.rtlsdr_source_0.set_bb_gain(10, 0)
          self.rtlsdr_source_0.set_antenna('', 0)
          self.rtlsdr_source_0.set_bandwidth(0, 0)
          self.low_pass_filter_0_0 = filter.fir_filter_ccf(
              12,
              firdes.low_pass(
                  1,
                  samp_rate,
                  cutoff,
                  width,
                  firdes.WIN_HAMMING,
                  6.76))
          self.blocks_wavfile_sink_0 = blocks.wavfile_sink(file_name, 1, audio_rate, 8)
          self.analog_fm_demod_cf_0 = analog.fm_demod_cf(
          	channel_rate=samp_rate//12,
          	audio_decim=5,
          	deviation=75000,
          	audio_pass=15000,
          	audio_stop=16000,
          	gain=1.0,
          	tau=75e-6,
          )
  
  
  
          ##################################################
          # Connections
          ##################################################
          self.connect((self.analog_fm_demod_cf_0, 0), (self.blocks_wavfile_sink_0, 0))
          self.connect((self.low_pass_filter_0_0, 0), (self.analog_fm_demod_cf_0, 0))
          self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0_0, 0))
  
      def get_width(self):
          return self.width
  
      def set_width(self, width):
          self.width = width
          self.low_pass_filter_0_0.set_taps(firdes.low_pass(1, self.samp_rate, self.cutoff, self.width, firdes.WIN_HAMMING, 6.76))
  
      def get_samp_rate(self):
          return self.samp_rate
  
      def set_samp_rate(self, samp_rate):
          self.samp_rate = samp_rate
          self.low_pass_filter_0_0.set_taps(firdes.low_pass(1, self.samp_rate, self.cutoff, self.width, firdes.WIN_HAMMING, 6.76))
          self.rtlsdr_source_0.set_sample_rate(self.samp_rate)
  
      def get_freq_0(self):
          return self.freq_0
  
      def set_freq_0(self, freq_0):
          self.freq_0 = freq_0
  
      def get_freq(self):
          return self.freq
  
      def set_freq(self, freq):
          self.freq = freq
          self.rtlsdr_source_0.set_center_freq(self.freq, 0)
  
      def get_file_name(self):
          return self.file_name
  
      def set_file_name(self, file_name):
          self.file_name = file_name
          self.blocks_wavfile_sink_0.open(self.file_name)
  
      def get_cutoff(self):
          return self.cutoff
  
      def set_cutoff(self, cutoff):
          self.cutoff = cutoff
          self.low_pass_filter_0_0.set_taps(firdes.low_pass(1, self.samp_rate, self.cutoff, self.width, firdes.WIN_HAMMING, 6.76))
  
      def get_audio_rate(self):
          return self.audio_rate
  
      def set_audio_rate(self, audio_rate):
          self.audio_rate = audio_rate
  
  
  
  def main(top_block_cls=test1, options=None):
      tb = top_block_cls()
  
      def sig_handler(sig=None, frame=None):
          tb.stop()
          tb.wait()
          sys.exit(0)
  
      signal.signal(signal.SIGINT, sig_handler)
      signal.signal(signal.SIGTERM, sig_handler)
  
      tb.start()
      try:
          time.sleep(sleep_to_write)
      except EOFError:
          pass
      tb.stop()
      tb.wait()
  
  
  if __name__ == '__main__':
      main()
  