void ChannelH11::InputManagement(){ static double h41[1000][300] = {0}; //load pilot data QFile file2("./pilot/pilot_100_re.txt"); if (!file2.open(QIODevice::ReadOnly | QIODevice::Text)) qDebug() << file2.errorString() <<" NO FILE"; QFile file3("./pilot/pilot_100_im.txt"); if (!file3.open(QIODevice::ReadOnly | QIODevice::Text)) qDebug() << file3.errorString() <<" NO FILE"; char str[100]; for( int i = 0 ; i < 100 ; i++){ file2.readLine(str,100); int crr = char2int(str); pilot[i][0] = crr; //qDebug() << "pilot[ "<<i<<" ][0] is :" << pilot[i][0]; file3.readLine(str,100); crr = char2int(str); pilot[i][1] = crr; //qDebug() << "pilot[ "<<i<<" ][1] is :" << pilot[i][1] << endl; }//for QFile file("h_300_1000_re.txt"); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) qDebug() << file.errorString(); int length = 1000; for( int i = 0 ; i < length ; i++ ){ for( int j = 0 ; j < 300 ; j++ ){ file.readLine(str,100); double crr = 0; crr = char2double(str); //qDebug() << "crr is :"<<crr; //h41[i][j] = crr*10; h41[i][j] = 0; } } //qDebug() << "h41[40][299] one is :"<< h41[40][299] ; pdata = &h41[0][0]; pdata2 = pdata; file.close(); }
void ChannelH21::InputManagement(){ static double h41[1000][300] = {0}; QFile file("h_300_1000_re_h21.txt"); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) qDebug() << file.errorString(); char str[100]; int length = 1000; for( int i = 0 ; i < length ; i++ ){ for( int j = 0 ; j < 300 ; j++ ){ file.readLine(str,100); double crr = 0; crr = char2double(str); //qDebug() << "crr is :"<<crr; h41[i][j] = crr*10; } } //qDebug() << "h41[40][299] one is :"<< h41[40][299] ; pdata = &h41[0][0]; pdata2 = pdata; file.close(); }
void ThroughPut::InputManagement(){ //QFile file("datain.txt"); QFile file0("./Pilot_send_data/pilot_1200_im.txt"); if (!file0.open(QIODevice::ReadOnly | QIODevice::Text)){ qDebug() << file0.errorString(); qDebug() << "Last sentence is in QPSK Inputmanagement." << endl; } //qDebug() << QObject::tr("file text:") << endl << file.readAll(); //char str[100]; char str6[100]; for( int i = 0 ; i < 1200 ; i++ ){ file0.readLine(str6,100); double crr = 0; crr = char2int(str6); //qDebug() << "pilot2[ "<< i <<"][0] is :"<<crr; pilot2[i][1] = crr; } file0.close(); QFile file5("./Pilot_send_data/pilot_1200_re.txt"); if (!file5.open(QIODevice::ReadOnly | QIODevice::Text)){ qDebug() << file5.errorString(); qDebug() << "Last sentence is in QPSK Inputmanagement." << endl; } //qDebug() << QObject::tr("file text:") << endl << file.readAll(); //char str[100]; for( int i = 0 ; i < 1200 ; i++ ){ file5.readLine(str6,100); double crr = 0; crr = char2int(str6); //qDebug() << "pilot2[ "<< i <<"][0] is :"<<crr; pilot2[i][0] = crr; } file5.close(); //QFile file("./pilot4_send_data/pilot4_1200_re.txt"); QFile file("./16qam_data_new/data_im.txt"); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)){ qDebug() << file.errorString(); qDebug() << "Last sentence is in ThroughPut Inputmanagement." << endl; } //qDebug() << QObject::tr("file text:") << endl << file.readAll(); //char str[100]; char str[100]; for( int i = 0 ; i < 1200 ; i++ ){ file.readLine(str,100); double crr = 0; crr = char2int(str); //qDebug() << "pilot4[ "<< i <<"][0] is :"<<crr; pilot4[i][0] = crr; } //qDebug() << "last one is :"<< ThroughPut[9][0] ; file.close(); //QFile file2("./pilot4_send_data/pilot4_1200_im.txt"); QFile file2("./16qam_data_new/data_re.txt"); if (!file2.open(QIODevice::ReadOnly | QIODevice::Text)){ qDebug() << file2.errorString(); qDebug() << "Last sentence is in ThroughPut Inputmanagement." << endl; } //qDebug() << QObject::tr("file text:") << endl << file2.readAll(); //char str[100]; for( int i = 0 ; i < 1200 ; i++ ){ file2.readLine(str,100); double crr = 0; crr = char2int(str); //qDebug() << "pilot4[ "<< i <<"][1] is :"<<crr; pilot4[i][1] = crr; } //qDebug() <<"apsk[0][0] is :"<< *(pdata) << endl; file2.close(); // QFile file3("./16qam_data/data_re.txt"); QFile file3("./16qam_data_new/data_re.txt"); if (!file3.open(QIODevice::ReadOnly | QIODevice::Text)){ qDebug() << file3.errorString(); qDebug() << "Last sentence is in ThroughPut Inputmanagement." << endl; } //qDebug() << QObject::tr("file text:") << endl << file.readAll(); //char str[100]; int cnt_2_500=0; for( int i = 0 ; i < 600 ; i++ ){ file3.readLine(str,100); double crr = 0; if(i%6!=0){ crr = char2double(str); // qDebug() << "re[ "<< i <<"][0] is :"<<crr; qam16_3[cnt_2_500][0] = crr; cnt_2_500++; } } //qDebug() << "last one is :"<< ThroughPut[9][0] ; file3.close(); // QFile file4("./16qam_data/data_im.txt"); QFile file4("./16qam_data_new/data_im.txt"); if (!file4.open(QIODevice::ReadOnly | QIODevice::Text)){ qDebug() << file4.errorString(); qDebug() << "Last sentence is in ThroughPut Inputmanagement." << endl; } //qDebug() << QObject::tr("file text:") << endl << file.readAll(); //char str[100]; int cnt_2_500_2; for( int i = 0 ; i < 600 ; i++ ){ file4.readLine(str,100); double crr = 0; if(i%6!=0){ crr = char2double(str); //qDebug() << "im[ "<< i <<"][0] is :"<<crr; qam16_3[cnt_2_500_2][1] = crr; cnt_2_500_2++; } } //qDebug() << "last one is :"<< ThroughPut[9][0] ; file4.close(); }
int main(int argc, char *argv[]) { FILE *fd1; FILE *fd2; wave_t *wave1; wave_t *wave2; buffer_t *buffer1; buffer_t *buffer2; int bytesread; int length = 512; if (argc < 2) { fprintf(stderr, "Usage: %s <file>\n", argv[0]); exit(EXIT_FAILURE); } // LOAD wave to compare with Square1.wav if (!(fd1 = fopen(argv[1], "rb"))) { fprintf(stderr, "Couldn't open \"%s\".\n", argv[1]); exit(EXIT_FAILURE); } if (!(wave2 = waveopen(fd1))) { fprintf(stderr, "Couldn't open \"%s\" as a .wav file.\n", argv[1]); exit(EXIT_FAILURE); } // LOAD Pulse1.wav if (!(fd2 = fopen("./wavs/Pulse1.wav", "rb"))) { fprintf(stderr, "Couldn't open \"%s\".\n", "Square1.wav"); exit(EXIT_FAILURE); } if (!(wave1 = waveopen(fd2))) { fprintf(stderr, "Couldn't open \"%s\" as a .wav file.\n", argv[1]); exit(EXIT_FAILURE); } wavegetprop(wave1, WAVE_LENGTH, &length); //length = 16; buffer1 = mkbuffer(wave1, length); buffer2 = mkbuffer(wave2, length); if (!(bytesread = getpcm(wave1, buffer1))) { fprintf(stderr, "Couldn't stream pcm data!\n"); exit(EXIT_FAILURE); } if (!(bytesread = getpcm(wave2, buffer2))) { fprintf(stderr, "Couldn't stream pcm data!\n"); exit(EXIT_FAILURE); } char2double(wave1, buffer1); char2double(wave2, buffer2); /*int16_t **sample; sample = (int16_t **)buffer->pcm; for(int i = 0; i < buffer->length; i++){ printf("sample %d = %i \n", i, sample[0][i]); }*/ print_waveinfo(wave1); /* Test signal processing routines --------------------------------------------------------------*/ printf("\nSIGNAL PROCESSING RESULTS:\n"); double **R = xcorr(0, buffer1, buffer2); qsort(R[1], 2*length - 1, sizeof(double), doublecmp); printf("max xcorr o/p = %f \n", R[1][2*length-2]); /* for(int i = 1024 - 300; i < 1024 + 300; i++) printf("index %d R=%f @ lag = %f \n", i, R[1][i],R[0][i]); look at the output and lag 100 should have R ~= 1;*/ /* clean up mem allocs */ free(R[0]); free(R[1]); free(R); rmbuffer(wave1, buffer1); rmbuffer(wave2, buffer2); waveclose(wave1); waveclose(wave2); fclose(fd1); fclose(fd2); return 0; }