On Thu, Aug 04, 2005 at 02:33:18PM +0930, Choon Ho wrote: > Quoting Choon Ho <[EMAIL PROTECTED]>: > > Hello folks > > I v got 2 unit of USRP, and i am writing my own polyphase filter code to > recieve > AM signal. I am now stuck on how to get the filtered signal (an array of > signal) > to the sound card? I hv attached my code, and would appreciate if soume one > could just give me some advise. Or sent me some examples. > > The signal i want to sent to the sound card is named "output", at the last > line > of the code. > > Thanking u in advance > Johnny Ho
Please take a look at the examples in gnuradio-examples Start with gnuradio-examples/python/audio/dial_tone.py FYI, GNU Radio already contains high performance polyphase filtering code. Take a look at gr.fir_filter_??? where ??? indicates the type of the input, output and taps respectively. f = float, c = complex I also suggest that you start with: http://www.gnu.org/software/gnuradio/doc/exploring-gnuradio.html Be sure that you understand the flow graph and signal processing block concepts. Eric > # start of my program > #!/usr/bin/env python > > import numarray > from numarray import* > from gnuradio import gr, eng_notation > > # from gnuradio import usrp > from gnuradio.eng_option import eng_option > from optparse import OptionParser > import sys > import math > > def FIR_filter(sig,coef): > > # #### FIR FILTER #### > print "the signal:", sig, "the coef:",coef > > filter_out = zeros((size(sig))) > print shape(filter_out) > print "newly created",filter_out > > buff_len = size(sig) > coeff_len = size(coef) > filter_len = buff_len - coeff_len > print "filter_len = ", filter_len > L = 0 > > print "coef len", coeff_len, "buff_len", buff_len,"filter_len:", > filter_len > > for x in range(filter_len+1): # loop 3x > tmp = 0 > curr_tmp = 0 > final_tmp = 0 > K = 0 > > for n in range(coeff_len): # loop 2x > print "coef(n):",coef[n],"sig(n):",sig[L + (size(coef)- > 1) - K], "x loop =", x, "n loop = ", n > > curr_tmp = coef[n] * sig[L + (size(coef)-1) - K] > final_tmp = tmp + curr_tmp > tmp = final_tmp > K = K + 1 > L = L + 1 > filter_out[x] = final_tmp > print "after compute",filter_out > return (filter_out) > > > M=3 > > # reshape coeff > h = array([1, 2, 3]); > print h > z1 = concatenate(zeros((1,M-1)),1); > print z1 > h_pad = concatenate((z1,h),1); > print h_pad > > if len(h_pad)%M !=0: > z1=concatenate(zeros((1,M-(len(h_pad)%M)))) > h_pad=concatenate((h_pad,z1),1) > > h_mat = reshape(h_pad,(len(h_pad)/M,M)) > print h_mat > h_tran = transpose(h_mat) > print h_tran > h_flip = h_tran[::-1] > print h_flip > > # reshape sig > sig_new = array([1, 2, 3, 4, 5, 6, 7, 8, 9, 0,11,12,13]); > print sig_new > z2 = concatenate(zeros((1,M-(len(sig_new)%M)))) > print z2 > sig_pad = concatenate((sig_new,z2),1); > print sig_pad > sig_mat = reshape(sig_pad,(len(sig_pad)/M,M)); > print sig_mat > sig_tran = transpose(sig_mat); > print sig_tran > > output_poly=zeros((shape(sig_tran))) > print "output_poly:",output_poly > for irow in range(M-1): > print "the sig:",sig_tran[irow], "the coef:",h_flip[irow] > ytmp=FIR_filter(sig_tran[irow],h_flip[irow]) > output_poly[irow]=ytmp > > output=sum(output_poly) > print "output:",output _______________________________________________ Discuss-gnuradio mailing list [email protected] http://lists.gnu.org/mailman/listinfo/discuss-gnuradio
