[Discuss-gnuradio] Noise problem in multiband FM transmitter
From:
mayur sarode
Subject:
[Discuss-gnuradio] Noise problem in multiband FM transmitter
Date:
Wed, 13 May 2009 11:27:22 +0530
Hello, I have built a Multi band NBFM transmitter.As I increase the number of channels for transmission ,the noise is increasing.How do i counteract this in the code.The code is given below
#!/usr/bin/env python ## a program to send multiple mp3 playlist on the FM band #in this example a single mp3 is sent over N channels on the fm band
from gnuradio import gr, eng_notation from gnuradio import usrp from gnuradio import audio from gnuradio import blks2 from gnuradio.eng_option import eng_option from optparse import OptionParser from usrpm import usrp_dbid import math import sys,os,re,tempfile,time,thread
# Read in .pls format (can be made e.g., using beep-media-player) def read_playlist(fname): input = open(fname, 'r')
playlist=[]
#[playlist] l = input.readline() # NumberOfEntries l = input.readline() nentries = int(re.findall("NumberOfEntries=([0-9]+)",l)[0])
print "Number of items in list %d
" % nentries i = 1 while l: l=input.readline()
filepath = re.findall("File[0-9]+=(.*)$",l) if filepath: print filepath[0] playlist.append(filepath[0]) i = i + 1
input.close() return(playlist)
## just create a standard tempfn (sox will create the file, so remove one made by system) def mktempfn(): tf = tempfile.mkstemp(".raw") outputfile = tf[1] os.close(tf[0]) os.remove(tf[1]) return(outputfile)
self.subdev.set_gain(self.subdev.gain_range()[1]) # set max Tx gain
if not self.set_freq(options.freq): freq_range = self.subdev.freq_range() print "Failed to set frequency to %s. Daughterboard supports %s to %s" % ( eng_notation.num_to_str(options.freq), eng_notation.num_to_str(freq_range[0]), eng_notation.num_to_str(freq_range[1])) raise SystemExit self.subdev.set_enable(True) # enable transmitter print "TX freq %1.2f MHz
" % (options.freq/1e6)
sum = gr.add_cc ()
# Instantiate N NBFM channels step = 25e3 offset = (0 * step, 1 * step, -1 * step, 2 * step, -2 * step, 3 * step, -3 * step, 4 * step,-4 * step ) for i in range (options.nchannels): outputfile = mktempfn() # write raw sound to named pipe in thread.start_new_thread(mp3toraw,(playlist[i],outputfile)) # sleep until we are sure there is something to play time.sleep(3) print "File size %d
" % int(os.stat(outputfile)[6]) t = pipeline(outputfile,offset[i], self.audio_rate, self.usrp_rate) self.fg.connect(t,(sum, i))
gain = gr.multiply_const_cc (4000.0) # connect it all self.fg.connect (sum, gain,self.u) #src = "" (gr.sizeof_float,outputfile, False) # stop and wait to finish print "Starting to play" self.fg.run() print "Done"
#stop and wait to finish self.fg.stop() self.fg.wait() #src=""> #fmtx=get_fmtx() #self.fg.disconnect(src, fmtx, gain, self.u)
os.remove(outputfile) # hack, we should get pid and kill sox only if necessary. os.system("killall sox")
def set_freq(self, target_freq): """ Set the center frequency we're interested in. """
r = self.u.tune(self.subdev.which(), self.subdev, target_freq) if r: print "r.baseband_freq =", eng_notation.num_to_str(r.baseband_freq) print "r.dxc_freq =", eng_notation.num_to_str(r.dxc_freq) print "r.residual_freq =", eng_notation.num_to_str(r.residual_freq) print "r.inverted =", r.inverted return True return False