[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Discuss-gnuradio] Please identify this algorithm
From: |
Dennis Glatting |
Subject: |
[Discuss-gnuradio] Please identify this algorithm |
Date: |
Wed, 20 Jan 2016 14:31:22 -0800 |
Newbie alert: I am not a signal processing expert.
I am looking at this chunk of code and cannot identify the algorithm in
my books. It's probably obvious and I am clueless. Please help identify
the algorithm so I can go off and find and read about it. The code is
using the FFTW library.
Thanks.
I have a block of /float/ samples (i.e., NOT complex I/Q) in
general_work() and will run two DFTs and one inverse DFT. I am sampling
at 48KHz and looking at a 2400Hz tone occasionally present in the
stream. Two important variables are:
SEARCH_SAMPLES = 61 * ( 48000 / 2400)
SEARCH_RANGE = (N -
SEARCH_SAMPLES)
N is a collected number of samples input to generate_work().
The first DFT is performed across a buffer where the first
SEARCH_SAMPLES of SEARCH_RANGE elements are the cos()/sin() of a 2400Hz
tone at time t (1/48000) and the remaining elements are zero. It goes
like this:
for( size_t t = 0; t < SEARCH_SAMPLES; t++ ) {
plan_a_input.get()[t][0] = d_cos2400.get()[t];
plan_a_input.get()[t][1] = d_sin2400.get()[t];
}
for( size_t t = SEARCH_SAMPLES; t < SEARCH_RANGE; t++ ) {
plan_a_input.get()[t][0] = 0;
plan_a_input.get()[t][1] = 0;
}
A DFT is then performed on "PLAN A":
plan_a = fftw_plan_dft_1d( SEARCH_RANGE,
plan_a_input.get(),
plan_a_dft.get(),
FFTW_FORWARD, FFTW_ESTIMATE);
fftw_execute( plan_a );
The second DFT, Plan B, is performed across a buffer of the samples to
general_work().
for( size_t k = 0; k < SEARCH_RANGE; k++ ) {
plan_b_input.get()[k][0] = d_dm.get()[k]; // Input samples
plan_b_input.get()[k][1] = 0.;
}
plan_b = fftw_plan_dft_1d( SEARCH_RANGE,
plan_b_input.get(),
plan_b_dft.get(),
FFTW_FORWARD, FFTW_ESTIMATE);
fftw_execute( plan_b );
That's pretty straight-forward and I have plotted the results, which
are as expected. The following is the part of the algorithm, Plan R,
when Plan A and Plan B are mixed with a little math, I do not
understand:
for( size_t k = 0; k < SEARCH_RANGE; k++ ) {
fftw_complex mul = {
( plan_a_dft.get()[k][0] * plan_b_dft.get()[k][0]) -
( plan_a_dft.get()[k][1] * plan_b_dft.get()[k][1]),
( plan_a_dft.get()[k][1] * plan_b_dft.get()[k][0]) +
( plan_a_dft.get()[k][0] * plan_b_dft.get()[k][1])
};
plan_R_input.get()[k][0] = mul[0]/(float)SEARCH_RANGE;
plan_R_input.get()[k][1] = mul[1]/(float)SEARCH_RANGE;
}
plan_R = fftw_plan_dft_1d( SEARCH_RANGE,
plan_R_input.get(),
plan_R_dft.get(),
FFTW_BACKWARD, FFTW_ESTIMATE);
fftw_execute( plan_R );
What algorithm is going on there?
- [Discuss-gnuradio] Please identify this algorithm,
Dennis Glatting <=