discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] Newbie Question: Linking with GnuRadio Libraries


From: Bill Peter
Subject: Re: [Discuss-gnuradio] Newbie Question: Linking with GnuRadio Libraries
Date: Sun, 30 Jan 2005 08:47:04 -0500

Martin:

Thanks for your help and sample code...I'm really impressed with what
I've seen so far in GnuRadio!

--Bill


On Sat, 29 Jan 2005 16:59:02 +0100, Martin Dvh
<address@hidden> wrote:
> Bill Peter wrote:
>   > (1) Can I use the GnuRadio libraries to link in my own "driver" c++
> > code to do the same thing I do with Matlab--but now with GnuRadio?
> Yes, I think you could.
> >
> > (2) How would I do this?  Can I just write a c++ program that makes
> > use of your Quadrature Demodulation class to do it for me:  Would it
> > look something like this:
> >
> > //use GnuRadio libraries
> > my_demod = new VrQuadratureDemod( xxx ) ;
> >
> > and link in with the appropriate libraries?  Does anyone have any
> > simple examples/templates and a Makefile ?
> It is easier if you just use gnuradio for all the processing.
> If you have the captured raw data already on your harddisk (shorts or floats) 
> You could start rightaway using gnuradio blocks and input your
> data as a file_source (see example at end of mail)
> If you want to do realtime analysing you would need to write your own 
> gnuradio driver.
> 
> I had a somewhat similar thing I wanted to do.
> I wanted to use standard videocapture cards as ADC and do some processing.
> What I did was.
> 1. use the standard linux kernel video4linux driver.
> 2. Take some code of an existing videocapture example program
> 3. Take the mc4020 gnuradio "driver" (really is and interface to the mc4020 
> kernel driver)
> 4. Replace the code which interfaces with the mc4020 kernel driver with my 
> video4linux videocapture code.
> 
> Now I can use the new driver within gnuradio programs.
> I didn't link in any libraries but of course you could link in any needed 
> libraries in you new driver.
> 
> This way you can write any gnuradio code (python) and use your new 
> driver/library and any existing gnuradio blocks.
> Just look at all the gnuradio examples in the WIKI and in gnuradio-example in 
> CVS.
> 
> If you don't want to write your program in python in the gnuradio framework, 
> you could also just link in the gnuradio libraries and use them
> directly.
> This would mean some more work because the python interface is an integral 
> part of gnuradio. Some parts are written in python and I don't know
> if it is easy to interface them back to C++ or objective C.
> the recent java interface discussion on this mailinglist could be of interest 
> to you for this. (Search the mailinglist archives for OSGi)
> 
> All above is only valid for gnuradio 2.x. The old gnuradio 0.x code can be 
> used directly from C++ but I don't think there is any development
> going on in gnuradio 0.x.
> 
> Greetings,
> Martin
> 
> from gnuradio import gr
> from gnuradio import audio
> #from gnuradio import mydriver
> import sys
> 
> def build_graph ():
>          sampling_freq = 10e6
>          cfir_decimation = 100
>          fg = gr.flow_graph ()
> 
>          #src0 = mydriver.source_f(0)
>          src0 = gr.file_source (gr.sizeof_short, "captured_10.7Mhz_data.raw", 
> 0)
>          # compute FIR filter taps
>          #(lowpass cutoff and width of transition band determine the with of 
> the bandpass channel filter)
>          channel_coeffs = \
>                  gr.firdes.low_pass (
>                    1.0,                  # gain
>                    sampling_freq,
>                    50e3,                 # low pass cutoff
>                    400e3,                 # width of transition band
>                    gr.firdes.WIN_HAMMING )
> 
>          # input: short; output: complex
>          chan_filter1 = \  # do downconversion(decimation) and bandpass 
> channel filtering in one step
>                  gr.freq_xlating_fir_filter_scf (
>                    cfir_decimation,#decimation_factor
>                    channel_coeffs,
>                    10.7*1e6, # wanted center frequency 10.7 MHz
>                    sampling_freq )
> 
>          my_processing = gr.complex_to_mag () #This is just an example, 
> complex_to_mag would do an am-demodulation of a complex signal, you
> could add any processing block you want here
> 
>          dst = gr.file_sink (gr.sizeof_float, "processed_signal_out.raw")
>          #dst = audio.sink ( 32000 )
> 
>          fg.connect ( src0, chan_filter1 )
>          fg.connect ( chan_filter1,my_processing )
>          fg.connect ( my_processing, dst )
> 
>          return fg
> 
> def main (args):
> 
>          fg = build_graph()
>          fg.start()
>          raw_input ('Press Enter to quit')
>          fg.stop()
> 
> if __name__ == '__main__':
>          main (sys.argv[1:])
> 
> _______________________________________________
> Discuss-gnuradio mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]