fun_ofdm  1.0
802.11a Physical Layer for USRP
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
fft_symbols.cpp
Go to the documentation of this file.
1 
8 #include <fftw3.h>
9 #include <cstring>
10 
11 #include "fft.h"
12 #include "fft_symbols.h"
13 
14 namespace fun
15 {
22  block("fft_symbols"),
23  m_offset(0),
24  m_ffft(64)
25  {
26  }
27 
34  {
35  if(input_buffer.size() == 0) return;
36  output_buffer.resize(0);
37 
38  // Step through the input samples
39  for(int x = 0; x < input_buffer.size(); x++)
40  {
41  // Check if this is the start of a new frame
42  if(input_buffer[x].tag == LTS1)
43  {
44  // Push the current vector to the output buffer if
45  // we've written any data to it
46  if(m_offset > 15) output_buffer.push_back(m_current_vector);
47 
48  // Start a new vector
50  m_offset = 16;
51  }
52 
53  if(input_buffer[x].tag == LTS2)
54  {
55  m_offset = 16;
56  }
57 
58  // Copy over samples past the cyclic prefix
59  if(m_offset > 15)
60  {
62  }
63 
64  // Increment the offset and reset if we're at the end of the symbol
65  m_offset++;
66  if(m_offset == 80)
67  {
70  m_offset = 0;
71  }
72  }
73 
74  // Perform forward FFT
75  for(int x = 0; x < output_buffer.size(); x++)
76  {
77  m_ffft.forward(output_buffer[x].samples);
78 
79  }
80  }
81 }
82 
83