[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## [Discuss-gnuradio] Frame Based C++ code structure question

**From**: |
mehmet kabasakal |

**Subject**: |
[Discuss-gnuradio] Frame Based C++ code structure question |

**Date**: |
Fri, 11 Mar 2011 11:06:31 +0200 |

Hi List,
I am trying to write some C++ blocks that makes calculations over 2048
point frames.
For ex. i need to take the 2048 point fft of the frame(contains 2048
points) and also
i need the index of these points, i mean where the center frequency is
(at which point).
Or i need to make calculations with the phase values of the frame and
accumulate these
phase values then find a value for each frame.
As i told, i want to make the calculations for each frame and find a
value for each frame again
without losing the index within 2048 points.
I write some codes but i thought i lose the index. Because i should
find the solutions for every
2048 points but it is not. I have to be sure especially with this.
I used gr_sync_block structure with stream inputs.
Then i tried to use vector inputs but can not make the code run
because of the dimension errors.
Can you make some suggestions about this code structure.
Here is one of my codes.
Mehmet.
int
gr_sigma_apdp_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 *out1 = (float *) output_items[0];
float *out2 = (float *) output_items[1];
float A = 0.0;
float B = 0.0;
float D = 0.0;
float ma = 0.0;
float inNL[noutput_items];
int a = 0;
int C = 2048;
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;
}
inNL[i] = in[i]-ma;
A = inNL[i] * inNL[i] + A;
B = fabs(inNL[i]) + B;
D = inNL[i] + D;
count = count + 1;
if (count % C == 0) {
out1[i] = sqrt(A/C - (B/C * B/C));
out2[i] = sqrt(A/C - (D/C * D/C));
A = 0.0;
B = 0.0;
D = 0.0;
a = a + 1;
}
else {
out1[i] = 0;
out2[i] = 0;
}
}
// Tell runtime system how many output items we produced.
return noutput_items;
}

[Prev in Thread] |
**Current Thread** |
[Next in Thread] |

**[Discuss-gnuradio] Frame Based C++ code structure question**,
*mehmet kabasakal* **<=**