discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] gnuradio c++ code structure question


From: Martin Braun
Subject: Re: [Discuss-gnuradio] gnuradio c++ code structure question
Date: Mon, 7 Mar 2011 15:47:46 +0100
User-agent: Mutt/1.5.20 (2009-06-14)

Hi Mehmet,

you've omitted some crucial parts of your code.
I'm guessing you've made your block a gr_sync_block.

It's easiest if your input items are vectors. In that case, your input
buffer (input_items) will contain noutput_items * 2048 float values.
Then, just process your data on whole blocks.

The operation you describe seems pretty simple. You can probably set it
up with a couple of existing blocks without having to write any code at
all, although your method is surely more efficient (in terms of CPU
load, not development time).

MB

On Mon, Mar 07, 2011 at 03:56:04PM +0200, mehmet kabasakal wrote:
> Hi everyone,
> 
> I am trying to develop a frame based structure for gnuradio block on c++.
> The frame size will be 2048 point and i will calculate the normalized
> amplitude for every frame i.e.
> 
> ma = sum(every 2048 points)/2048;
> normalized amplitude = all 2048 points / ma;
> 
> i wrote a code that gives me the desired result under "work" function;
> 
> 
> 
> int
> gr_gama_maks_ff::work (int noutput_items,
>                       gr_vector_const_void_star &input_items,
>                       gr_vector_void_star &output_items)
> {
>   const float *in = (const float *) input_items[0];
>   float *out = (float *) output_items[0];
>   float ma = 0.0;
>   float acn[noutput_items], an[noutput_items];
>   int C = 2048;
>   int a = 0;
>   int count = 0;
> 
>   for (int i = 0; i < noutput_items; i++){
>     ma = 0.0;
>     for (int m = a*C; m < a*C+C ; m++) {
>       ma += in[m]/C;  
>     }
> 
>     an[i] = in[i]/ma;
>     acn[i] = an[i]-1;
>     out[i] = acn[i]*d_k;
> 
>    if ((i+1) % C == 0) {
>     a = a + 1;
>    }
>   }
> 
> 
> 
> As you see i didn't keep a 2048 point array, i just find the sum of
> 2048 points and then use it for the output (an[i]= in[i]/ma). But i
> couldn't figure out how this happens. I mean the while index "i = 1"
> in the first for loop, i can reach the i+2047th sample in the second
> for loop.
> 
> Is there a buffer for every block in gnuradio. If yes what is the size
> of the buffer?
> 
> I hope i would explain it clear.
> 
> Mehmet.
> 
> _______________________________________________
> Discuss-gnuradio mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/discuss-gnuradio

-- 
Karlsruhe Institute of Technology (KIT)
Communications Engineering Lab (CEL)

Dipl.-Ing. Martin Braun
Research Associate

Kaiserstraße 12
Building 05.01
76131 Karlsruhe

Phone: +49 721 608-43790
Fax: +49 721 608-46071
www.cel.kit.edu

KIT -- University of the State of Baden-Württemberg and
National Laboratory of the Helmholtz Association

Attachment: pgp9js7lHgiT9.pgp
Description: PGP signature


reply via email to

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