summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormax <max@65a5c917-d112-43f1-993d-58c26a4786be>2013-06-14 02:01:19 +0000
committermax <max@65a5c917-d112-43f1-993d-58c26a4786be>2013-06-14 02:01:19 +0000
commit73e2f68fc6f199a478697638878a693cd8051dff (patch)
tree4b02c7073301407502c9ebcd74de83d4d839c790
parent225f1972ab099a38df704487f17bf1c368f264f8 (diff)
add arb-resample.py
git-svn-id: http://op25.osmocom.org/svn/trunk@317 65a5c917-d112-43f1-993d-58c26a4786be
-rwxr-xr-xrepeater/src/python/arb-resample.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/repeater/src/python/arb-resample.py b/repeater/src/python/arb-resample.py
new file mode 100755
index 0000000..42e2382
--- /dev/null
+++ b/repeater/src/python/arb-resample.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+
+import sys
+import math
+from gnuradio import gr, gru, audio, eng_notation, blks2, optfir
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+
+class my_top_block(gr.top_block):
+ def __init__(self):
+ gr.top_block.__init__(self)
+ parser = OptionParser(option_class=eng_option)
+
+ parser.add_option("-c", "--calibration", type="eng_float", default=0, help="freq offset")
+ parser.add_option("-g", "--gain", type="eng_float", default=1)
+ parser.add_option("-i", "--input-file", type="string", default="in.dat", help="specify the input file")
+ parser.add_option("-o", "--output-file", type="string", default="out.dat", help="specify the output file")
+ parser.add_option("-r", "--new-sample-rate", type="int", default=96000, help="output sample rate")
+ parser.add_option("-s", "--sample-rate", type="int", default=48000, help="input sample rate")
+ (options, args) = parser.parse_args()
+
+ sample_rate = options.sample_rate
+ new_sample_rate = options.new_sample_rate
+
+ IN = gr.file_source(gr.sizeof_gr_complex, options.input_file)
+ OUT = gr.file_sink(gr.sizeof_gr_complex, options.output_file)
+
+ LO = gr.sig_source_c(sample_rate, gr.GR_COS_WAVE, options.calibration, 1.0, 0)
+ MIXER = gr.multiply_cc()
+
+ AMP = gr.multiply_const_cc(options.gain)
+
+ nphases = 32
+ frac_bw = 0.05
+ p1 = frac_bw
+ p2 = frac_bw
+ rs_taps = gr.firdes.low_pass(nphases, nphases, p1, p2)
+ #RESAMP = blks2.pfb_arb_resampler_ccf(float(sample_rate) / float(new_sample_rate), (rs_taps), nphases, )
+ RESAMP = blks2.pfb_arb_resampler_ccf(float(new_sample_rate) / float(sample_rate), (rs_taps), nphases, )
+
+ self.connect(IN, (MIXER, 0))
+ self.connect(LO, (MIXER, 1))
+
+ self.connect(MIXER, AMP, RESAMP, OUT)
+
+if __name__ == "__main__":
+ try:
+ my_top_block().run()
+ except KeyboardInterrupt:
+ tb.stop()