def test_002_square2_ff (self): src_data0 = ( 0.01+0.11j, 0.02+0.22j, 0.03+0.33j, 0.04+0.44j, 0.05+0.55j, 0.06+0.66j, 0.07+0.77j, 0.08+0.88j, 0.09+0.99j ) src_coeff = (0.101, 0.102, 0.103, 0.104, 0.105) scale = 15 expected_result = (245, 320, 395, 470, 445, 400, 334, 246, 135) src0 = gr.vector_source_c (src_data0) dsp.init() # dsp.fir_ccf ( # coefficients, # Q formatted can be between Q0 -> Q14 # scaling factor = [0, 15] # interpolation factor # currently not implemented "properly" a.k.a don't use just yet # input signature # 0 = normalized input # 1 = scaled by a factor equal "scale" # output signature # 0 = normalized input # 1 = scaled by a factor equal "scale" # initialize DSP (set to 0 use dsp.init() instead # 1 = yes # 0 = no # block ID # 1 or 0 to uniquly identify block instance for now there's support for only two blocks ccf_filt = dsp.fir_ccf (src_coeff, scale, 1, 0, 0, 0, 0) # gccf = gr.interp_fir_filter_ccf (1, src_coeff) dst0 = gr.vector_sink_c () dst1 = gr.vector_sink_c () self.tb.connect ((src0, 0), ccf_filt) self.tb.connect (ccf_filt, dst0) self.tb.run () result_data0 = dst0.data () result_data1 = dst1.data () print "Result DSP " dsp.clean()
def __init__(self): gr.top_block.__init__(self) usage="%prog: [options] output_filename" parser = OptionParser(option_class=eng_option, usage=usage) parser.add_option("-I", "--audio-input", type="string", default="", help="pcm input device name. E.g., hw:0,0 or /dev/dsp") parser.add_option("-r", "--sample-rate", type="eng_float", default=48000, help="set sample rate to RATE (48000)") parser.add_option("-N", "--nsamples", type="eng_float", default=None, help="number of samples to collect [default=+inf]") (options, args) = parser.parse_args () if len(args) != 1: parser.print_help() raise SystemExit, 1 #filename = args[0] sample_rate = int(options.sample_rate) audio_coeffs = ( 0.00058729130373770002, 0.0016584444738215582, 0.0015819269921330031, 0.0014607862142637573, 0.00020681278261230754, -0.0013001097961560814, -0.00249802658603143, -0.0024276134129972843, -0.00083069749014258953, 0.0017562878158492619, 0.003963761120687582, 0.0043075911442784871, 0.0020710872871114866, -0.0020172640629268932, -0.005882026963765212, -0.0070692053073845166, -0.0041954626649490937, 0.0019311082705710714, 0.0082980827342646387, 0.011045923787287403, 0.0076530405054369872, -0.0012102332109476402, -0.011372099802214802, -0.016910189774436514, -0.013347352799620162, -0.00068013535845177706, 0.015578754320259895, 0.026379517186832846, 0.023618496101893545, 0.0051085800414948012, -0.022608534445133374, -0.045529642916534545, -0.047580556152787695, -0.018048092177406189, 0.042354392363985506, 0.11988807809069109, 0.19189052073753335, 0.2351677633079737, 0.2351677633079737, 0.19189052073753335, 0.11988807809069109, 0.042354392363985506, -0.018048092177406189, -0.047580556152787695, -0.045529642916534545, -0.022608534445133374, 0.0051085800414948012, 0.023618496101893545, 0.026379517186832846, 0.015578754320259895, -0.00068013535845177706, -0.013347352799620162, -0.016910189774436514, -0.011372099802214802, -0.0012102332109476402, 0.0076530405054369872, 0.011045923787287403, 0.0082980827342646387, 0.0019311082705710714, -0.0041954626649490937, -0.0070692053073845166, -0.005882026963765212, -0.0020172640629268932, 0.0020710872871114866, 0.0043075911442784871, 0.003963761120687582, 0.0017562878158492619, -0.00083069749014258953, -0.0024276134129972843, -0.00249802658603143, -0.0013001097961560814, 0.00020681278261230754, 0.0014607862142637573, 0.0015819269921330031, 0.0016584444738215582, 0.00058729130373770002) # initializes the DSP dsp.init() src = audio.source (sample_rate, options.audio_input) #dst = gr.file_sink (gr.sizeof_float, filename) dst = audio.sink (sample_rate, options.audio_output) audio_filter = dsp.fir_fff(1, audio_coeffs) # deletes DSP related buffers and resources # dsp.clean() if options.nsamples is None: self.connect((src, 0), audio_filter, dst) else: head = gr.head(gr.sizeof_float, int(options.nsamples)) self.connect((src, 0), head, audio_filter, dst)