text: #!/usr/bin/env python2
  # -*- coding: utf-8 -*-
  ##################################################
  # GNU Radio Python Flow Graph
  # Title: Top Block
  # Generated: Fri Mar 17 15:14:46 2017
  ##################################################
  
  if __name__ == '__main__':
      import ctypes
      import sys
      if sys.platform.startswith('linux'):
          try:
              x11 = ctypes.cdll.LoadLibrary('libX11.so')
              x11.XInitThreads()
          except:
              print "Warning: failed to XInitThreads()"
  
  from gnuradio import analog
  from gnuradio import audio
  from gnuradio import blocks
  from gnuradio import eng_notation
  from gnuradio import filter
  from gnuradio import gr
  from gnuradio.eng_option import eng_option
  from gnuradio.filter import firdes
  from gnuradio.wxgui import forms
  from grc_gnuradio import wxgui as grc_wxgui
  from optparse import OptionParser
  import wx
  
  
  class top_block(grc_wxgui.top_block_gui):
  
      def __init__(self):
          grc_wxgui.top_block_gui.__init__(self, title="Top Block")
          _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
          self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))
  
          ##################################################
          # Variables
          ##################################################
          self.samp_rate = samp_rate = 400e3
          self.freq = freq = 880e3
          self.center_freq = center_freq = 900e3
  
          ##################################################
          # Blocks
          ##################################################
          self._freq_text_box = forms.text_box(
          	parent=self.GetWin(),
          	value=self.freq,
          	callback=self.set_freq,
          	label='freq',
          	converter=forms.float_converter(),
          )
          self.Add(self._freq_text_box)
          self._center_freq_text_box = forms.text_box(
          	parent=self.GetWin(),
          	value=self.center_freq,
          	callback=self.set_center_freq,
          	label='center_freq',
          	converter=forms.float_converter(),
          )
          self.Add(self._center_freq_text_box)
          self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
                  interpolation=32,
                  decimation=400,
                  taps=None,
                  fractional_bw=None,
          )
          self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
          	1, samp_rate, 5e3, 1e3, firdes.WIN_HAMMING, 6.76))
          self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
          self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/home/klangner/workspaces/rust/radio/data/am_broadcast_02_c900k_s400k.iq", True)
          self.audio_sink_0 = audio.sink(32000, "", True)
          self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, center_freq-freq, 1, 0)
          self.analog_am_demod_cf_0 = analog.am_demod_cf(
          	channel_rate=samp_rate,
          	audio_decim=1,
          	audio_pass=5000,
          	audio_stop=5500,
          )
  
          ##################################################
          # Connections
          ##################################################
          self.connect((self.analog_am_demod_cf_0, 0), (self.rational_resampler_xxx_0, 0))    
          self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0))    
          self.connect((self.blocks_file_source_0, 0), (self.blocks_multiply_xx_0, 1))    
          self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0))    
          self.connect((self.low_pass_filter_0, 0), (self.analog_am_demod_cf_0, 0))    
          self.connect((self.rational_resampler_xxx_0, 0), (self.audio_sink_0, 0))    
  
      def get_samp_rate(self):
          return self.samp_rate
  
      def set_samp_rate(self, samp_rate):
          self.samp_rate = samp_rate
          self.analog_sig_source_x_0.set_sampling_freq(self.samp_rate)
          self.low_pass_filter_0.set_taps(firdes.low_pass(1, self.samp_rate, 5e3, 1e3, firdes.WIN_HAMMING, 6.76))
  
      def get_freq(self):
          return self.freq
  
      def set_freq(self, freq):
          self.freq = freq
          self._freq_text_box.set_value(self.freq)
          self.analog_sig_source_x_0.set_frequency(self.center_freq-self.freq)
  
      def get_center_freq(self):
          return self.center_freq
  
      def set_center_freq(self, center_freq):
          self.center_freq = center_freq
          self._center_freq_text_box.set_value(self.center_freq)
          self.analog_sig_source_x_0.set_frequency(self.center_freq-self.freq)
  
  
  def main(top_block_cls=top_block, options=None):
  
      tb = top_block_cls()
      tb.Start(True)
      tb.Wait()
  
  
  if __name__ == '__main__':
      main()
  