|
@@ -1,14 +1,10 @@
|
|
|
#!/usr/bin/env python3
|
|
|
-# -*- coding: utf-8 -*-
|
|
|
#
|
|
|
# SPDX-License-Identifier: GPL-3.0
|
|
|
#
|
|
|
# GNU Radio Python Flow Graph
|
|
|
# Title: FM Radio Receiver
|
|
|
|
|
|
-import signal
|
|
|
-import sys
|
|
|
-
|
|
|
import gnuradio.analog
|
|
|
import gnuradio.audio
|
|
|
import gnuradio.fft
|
|
@@ -32,12 +28,12 @@ class fm_radio(gnuradio.gr.top_block):
|
|
|
interpolation=audio_sample_rate_hertz, decimation=channel_width_hertz
|
|
|
)
|
|
|
low_pass_filter = gnuradio.filter.fir_filter_ccf(
|
|
|
- (int(samp_rate / channel_width_hertz)),
|
|
|
+ samp_rate // channel_width_hertz,
|
|
|
gnuradio.filter.firdes.low_pass(
|
|
|
2, samp_rate, 100000, 10000, gnuradio.fft.window.WIN_KAISER, 6.76
|
|
|
),
|
|
|
)
|
|
|
- audio_sink = gnuradio.audio.sink(audio_sample_rate_hertz, "", True)
|
|
|
+ audio_sink = gnuradio.audio.sink(audio_sample_rate_hertz)
|
|
|
wbfm_demodulator = gnuradio.analog.wfm_rcv(
|
|
|
quad_rate=channel_width_hertz, audio_decimation=1
|
|
|
)
|
|
@@ -48,27 +44,13 @@ class fm_radio(gnuradio.gr.top_block):
|
|
|
self.connect((rtlsdr_source, 0), (low_pass_filter, 0))
|
|
|
|
|
|
|
|
|
-def main(top_block_cls=fm_radio, 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:
|
|
|
- input("Press Enter to quit: ")
|
|
|
- except EOFError:
|
|
|
- pass
|
|
|
- tb.stop()
|
|
|
- tb.wait()
|
|
|
+def _main():
|
|
|
+ top_block = fm_radio()
|
|
|
+ top_block.start()
|
|
|
+ input("Press Enter to quit: ")
|
|
|
+ top_block.stop()
|
|
|
+ top_block.wait()
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
- main()
|
|
|
+ _main()
|