Skip to content

Instantly share code, notes, and snippets.

@kareiva
Created August 18, 2016 04:57
Show Gist options
  • Save kareiva/7af1ce01647b54ebfd6fc39efc5cb958 to your computer and use it in GitHub Desktop.
Save kareiva/7af1ce01647b54ebfd6fc39efc5cb958 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
##################################################
# GNU Radio Python Flow Graph
# Title: Wspr Hackrf
# Generated: Wed Aug 17 21:55:01 2016
##################################################
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 optparse import OptionParser
import osmosdr
import time
class wspr_hackrf(gr.top_block):
def __init__(self):
gr.top_block.__init__(self, "Wspr Hackrf")
##################################################
# Variables
##################################################
self.wav_rate = wav_rate = 12000
self.samp_rate = samp_rate = 2.4e6
self.center_freq = center_freq = 14.0956e6
##################################################
# Blocks
##################################################
self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
interpolation=int(samp_rate / wav_rate),
decimation=1,
taps=None,
fractional_bw=None,
)
self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
interpolation=4,
decimation=1,
taps=None,
fractional_bw=None,
)
self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "" )
self.osmosdr_sink_0.set_sample_rate(samp_rate)
self.osmosdr_sink_0.set_center_freq(center_freq, 0)
self.osmosdr_sink_0.set_freq_corr(-10, 0)
self.osmosdr_sink_0.set_gain(14, 0)
self.osmosdr_sink_0.set_if_gain(47, 0)
self.osmosdr_sink_0.set_bb_gain(20, 0)
self.osmosdr_sink_0.set_antenna("", 0)
self.osmosdr_sink_0.set_bandwidth(0, 0)
self.hilbert_fc_0 = filter.hilbert_fc(65, firdes.WIN_HAMMING, 6.76)
self.blocks_wavfile_source_0 = blocks.wavfile_source("/home/molotov/LY2EN-KO25PQ-10.wav", True)
self.audio_sink_0 = audio.sink(48000, "", True)
##################################################
# Connections
##################################################
self.connect((self.blocks_wavfile_source_0, 0), (self.hilbert_fc_0, 0))
self.connect((self.blocks_wavfile_source_0, 0), (self.rational_resampler_xxx_0, 0))
self.connect((self.hilbert_fc_0, 0), (self.rational_resampler_xxx_1, 0))
self.connect((self.rational_resampler_xxx_0, 0), (self.audio_sink_0, 0))
self.connect((self.rational_resampler_xxx_1, 0), (self.osmosdr_sink_0, 0))
def get_wav_rate(self):
return self.wav_rate
def set_wav_rate(self, wav_rate):
self.wav_rate = wav_rate
def get_samp_rate(self):
return self.samp_rate
def set_samp_rate(self, samp_rate):
self.samp_rate = samp_rate
self.osmosdr_sink_0.set_sample_rate(self.samp_rate)
def get_center_freq(self):
return self.center_freq
def set_center_freq(self, center_freq):
self.center_freq = center_freq
self.osmosdr_sink_0.set_center_freq(self.center_freq, 0)
def main(top_block_cls=wspr_hackrf, options=None):
tb = top_block_cls()
tb.start()
try:
raw_input('Press Enter to quit: ')
except EOFError:
pass
tb.stop()
tb.wait()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment