void Waterfall::updateWaterfall(char*header,char* buffer,int length) { int i,j; int version,subversion; int offset; //qDebug() << "updateWaterfall: " << width() << ":" << height(); version=header[1]; subversion=header[2]; sampleRate=((header[9]&0xFF)<<24)+((header[10]&0xFF)<<16)+((header[11]&0xFF)<<8)+(header[12]&0xFF); if(version==2 && subversion>0) { // only in version 2.1 and above LO_offset=((header[13]&0xFF)<<8)+(header[14]&0xFF); } else { LO_offset=0; } if(samples!=NULL) { free(samples); } samples = (float*) malloc(width() * sizeof (float)); // do not rotate spectrum display. It is done by dspserver now #pragma omp parallel for schedule(static) for(i=0;i<width();i++) { samples[i] = -(buffer[i] & 0xFF); } size = length; QTimer::singleShot(0,this,SLOT(updateWaterfall_2())); }
void Waterfall::updateWaterfall(char*header,char* buffer,int length) { int i,j; int version,subversion; int offset; //qDebug() << "updateWaterfall: " << width() << ":" << height(); version=header[1]; subversion=header[2]; sampleRate=((header[9]&0xFF)<<24)+((header[10]&0xFF)<<16)+((header[11]&0xFF)<<8)+(header[12]&0xFF); if(version==2 && subversion>0) { // only in version 2.1 and above LO_offset=((header[13]&0xFF)<<8)+(header[14]&0xFF); } else { LO_offset=0; } if(samples!=NULL) { free(samples); } samples = (float*) malloc(width() * sizeof (float)); // rotate spectrum display if LO is not 0 if(LO_offset==0) { #pragma omp parallel for schedule(static) for(i=0;i<width();i++) { samples[i] = -(buffer[i] & 0xFF); } } else { float step=(float)sampleRate/(float)width(); offset=(int)((float)LO_offset/step); #pragma omp parallel for schedule(static) private(i,j) for(i=0;i<width();i++) { j=i-offset; if(j<0) j+=width(); if(j>=width()) j%=width(); samples[i] = -(buffer[j] & 0xFF); } } size = length; QTimer::singleShot(0,this,SLOT(updateWaterfall_2())); }