| 95 | | ///The following input buffers and expected results are defined in header files |
| 96 | | ///float nominal_test_vector_I, nominal_test_vector_Q; |
| 97 | | ///short nominal_expected_results_I, nominal_expected_results_Q; |
| 98 | | |
| 99 | | //float to short conversion |
| 100 | | //float max_float_value = 3; //double check this value later if signal is noisy |
| 101 | | short max_short_value = 10000;//32767; |
| 102 | | //float tmp_float; |
| 103 | | unsigned int N_in = 512; //This number must match with the lenght of the input buffer |
| | 97 | ///The following input buffers and expected results are defined in header files |
| | 98 | ///float nominal_test_vector_I, nominal_test_vector_Q; |
| | 99 | ///short nominal_expected_results_I, nominal_expected_results_Q; |
| | 100 | |
| | 101 | //float to short conversion |
| | 102 | //float max_float_value = 3; //double check this value later if signal is noisy |
| | 103 | short max_short_value = 10000;//32767; |
| | 104 | //float tmp_float; |
| | 105 | unsigned int N_in = 512; //This number must match with the lenght of the input buffer |
| 116 | | char type[] = "rrcos"; ///< filter type |
| 117 | | unsigned int k = 2; ///< samples per symbol |
| 118 | | unsigned int m = 4; ///< symbol delay |
| 119 | | float beta = .25; ///< rolloff factor |
| 120 | | unsigned int Npfb = 32; ///< polyphse filter bank size |
| 121 | | |
| 122 | | unsigned int N_out = N_in/k + 2; //Need some buffer for mismatched samples per symbol |
| 123 | | short* systemOutputI = new short[N_out]; |
| 124 | | short* systemOutputQ = new short[N_out]; |
| 125 | | |
| 126 | | |
| 127 | | symbolSync.ConfigureFilterBank(type, k, m, beta, Npfb); |
| 128 | | |
| 129 | | //send test data |
| 130 | | symbolSync.SynchronizeAndDecimate( nominal_test_vector_I_short, |
| | 118 | char type[] = "rrcos"; ///< filter type |
| | 119 | unsigned int k = 2; ///< samples per symbol |
| | 120 | unsigned int m = 4; ///< symbol delay |
| | 121 | float beta = .25; ///< rolloff factor |
| | 122 | unsigned int Npfb = 32; ///< polyphse filter bank size |
| | 123 | |
| | 124 | unsigned int N_out = N_in/k + 2; //Need some buffer for mismatched samples per symbol |
| | 125 | short* systemOutputI = new short[N_out]; |
| | 126 | short* systemOutputQ = new short[N_out]; |
| | 127 | |
| | 128 | |
| | 129 | symbolSync.ConfigureFilterBank(type, k, m, beta, Npfb); |
| | 130 | |
| | 131 | //send test data |
| | 132 | symbolSync.SynchronizeAndDecimate( nominal_test_vector_I_short, |
| | 162 | |
| | 163 | // test_02 |
| | 164 | void testSymbolSynchronizationTimingOffset() |
| | 165 | { |
| | 166 | std::cout << std::endl << "testSymbolSynchronizationTimingOffset" << std::endl; |
| | 167 | SymbolSyncPolyDSP symbolSync; |
| | 168 | |
| | 169 | // Init variables shall match the values used in MATLAB to get the test vectors and |
| | 170 | // expected result |
| | 171 | unsigned int Npfb_02 = 32; |
| | 172 | unsigned int N_out_02 = N_in_02; |
| | 173 | |
| | 174 | //Need some buffer for mismatched samples per symbol |
| | 175 | short* I_out_02 = new short[N_out_02]; |
| | 176 | short* Q_out_02 = new short[N_out_02]; |
| | 177 | memset( I_out_02, 0, N_out_02*sizeof(short) ); |
| | 178 | memset( Q_out_02, 0, N_out_02*sizeof(short) ); |
| | 179 | |
| | 180 | symbolSync.ConfigureFilterBank(type_02, k_02, m_02, beta_02, Npfb_02); |
| | 181 | |
| | 182 | //send test data |
| | 183 | symbolSync.SynchronizeAndDecimate( |
| | 184 | I_in_02, |
| | 185 | Q_in_02, |
| | 186 | N_in_02, |
| | 187 | I_out_02, |
| | 188 | Q_out_02, |
| | 189 | N_out_02); |
| | 190 | |
| | 191 | //hard decision to see if we recovered the message correctly |
| | 192 | unsigned int num_correct_symbols(0); |
| | 193 | short t_min = short(Ac_02 / sqrtf(2) * 0.5); // minimum threshold |
| | 194 | short t_max = short(Ac_02 / sqrtf(2) * 1.5); // maximum threshold |
| | 195 | for(unsigned int i = 0; i<N_out_02; i++){ |
| | 196 | if ( abs(I_out_02[i])>t_min && abs(I_out_02[i])<t_max && |
| | 197 | abs(Q_out_02[i])>t_min && abs(Q_out_02[i])<t_max ) |
| | 198 | num_correct_symbols++; |
| | 199 | //std::cout << " " << I_out_02[i] << " " << Q_out_02[i] << std::endl; |
| | 200 | } |
| | 201 | |
| | 202 | std::cout << "num_correct_symbols : " << num_correct_symbols << std::endl; |
| | 203 | |
| | 204 | TS_ASSERT(num_correct_symbols > 150); |
| | 205 | |
| | 206 | delete [] I_out_02; |
| | 207 | delete [] Q_out_02; |
| | 208 | } |
| | 209 | |