1 #ifndef DEMODULATOR_H 2 #define DEMODULATOR_H 3 #include <fftw3.h> 4 #include "drmproto.h" 5 #include "drmdefs.h" 6 #include "sourcedecoder.h" 7 8 9 #define SNR_TIMEOUT 10 10 #define FACVALIDCNTR 10 11 #define SNR_MIN_DB 3 12 #define DRMNUMMODES 4 13 14 15 extern int Ts_list[DRMNUMMODES]; 16 extern int Tu_list[DRMNUMMODES]; 17 extern int Tg_list[DRMNUMMODES]; 18 extern bool FACAvailable; 19 20 class demodulator 21 { 22 public: 23 demodulator(); 24 ~demodulator(); 25 void init(); 26 bool demodulate(float *sigin, int numSamples); isTimeSync()27 bool isTimeSync() {return timeSyncFlag;} isFrequencySync()28 bool isFrequencySync() {return frequencySyncFlag;} isFrameSync()29 bool isFrameSync() {return frameSyncFlag;} isFACAvailable()30 bool isFACAvailable() {return FACAvailable;} 31 private: 32 int iterationCounter; 33 bool timeSync(); 34 bool frequencySync(); 35 bool frameSync(); 36 bool channelEstimation(); 37 int symbol_counter; 38 int N_samples_needed; 39 int SNR_time_out_counter; 40 int fac_not_valid_counter; 41 int mode_and_occupancy_code_last; 42 int rsbufwidx; 43 int symbufwidx; 44 int smp_rate_conv_fft_phase_diff; 45 float smp_rate_conv_fft_phase_offset; 46 int smp_rate_conv_in_out_delay; 47 fftwf_plan p1; 48 drmComplex ss[256], S[256]; 49 // float rs_buffer[DRMBUFSIZE]; 50 float rs_buffer[10*8000]; 51 bool doSynchronize; 52 bool timeSyncFlag; 53 bool frequencySyncFlag; 54 bool frameSyncFlag; 55 int numberOfSamples; 56 smode_info mode_block; 57 float time_offset; 58 float frequency_offset_fractional_init; 59 int time_offset_integer; 60 int counter; 61 int Ts, Tu, Tg, Tgh; 62 float freq_offset_integer; 63 int x,y, k0; 64 int symbols_per_2D_window; 65 int delta_time_offset_integer; 66 float time_offset_fractional_init; 67 float freq_offset_init; 68 float delta_time_offset_I_init; 69 float Zi[6]; 70 float symbol_temp[2 * Tu_A]; 71 float symbol_buffer[Tu_A * 2 * 26]; 72 int time_ref_cells_k[21]; 73 int time_ref_cells_theta_1024[21]; 74 int symbols_to_delay; 75 int N_symbols_needed; 76 int no_of_used_cells_per_frame_list[24]; 77 float sigmaq_noise_list[4]; 78 int gain_ref_cells_k[712]; 79 int gain_ref_cells_theta_1024[712]; 80 float gain_ref_cells_a[712]; 81 int training_cells_k[5][712]; 82 int cnt_tr_cells[5]; 83 int gain_ref_cells_per_frame; 84 int gain_ref_cells_per_y_symbols; 85 float next_pilots[2*70]; /* complex */ //joma 86 int K_min,K_max; 87 float W_symbol_blk[5][208][229]; 88 float W_symbol[208]; 89 float W_pilots_blk[5][208][205]; 90 float W_pilots[208]; 91 int SNR_timeout_counter; 92 float delta_freq_offset; 93 int mode_and_occupancy_code; 94 int carrier_per_symbol; 95 int freq_ref_cells_k[3]; 96 int freq_ref_cells_theta_1024[3]; 97 int power_boost[4]; 98 int Q_1024; 99 int gain_ref_cells_subset[5][209]; 100 int gain_ref_cells_subset_index[5][209]; 101 int cnt_next_pilot_cells[5]; 102 int next_pilot_cells_k_index[5][40]; 103 int next_pilot_cells_k[5][40]; 104 float PHI[208][208]; 105 float PHI_INV[208][208]; 106 float THETA[208]; 107 int gain_ref_cells_subset_nn[209]; 108 int training_cells_relative_index[209]; 109 int actual_pilots_relative_index[209]; 110 float normalized_training_cells[1424]; 111 float actual_pilots[458]; 112 float H[458]; 113 float delta_time_offset_I; 114 float time_offset_fractional; 115 bool initChannelEstimation; 116 }; 117 118 #endif // DEMODULATOR_H 119