void PeriodogramComponent::process() { //Get a DataSet from the input DataBuffer DataSet< complex<float> >* readDataSet = NULL; getInputDataSet("input1", readDataSet); std::size_t size = readDataSet->data.size(); //Get a DataSet from the output DataBuffer DataSet< float >* writeDataSet = NULL; getOutputDataSet("output1", writeDataSet, x_blocksize); //FFT process //float *data =(float*) malloc (size*sizeof(float)); float data[2*size],PSDresult[x_blocksize]; for(int i=0;i<size;i++) { data[2*i+1]=readDataSet->data[i].real(); data[2*i]=readDataSet->data[i].imag(); } periodogram(size,x_blocksize,data,PSDresult); log10Array(PSDresult,x_blocksize); for(int i=0;i<x_blocksize;i++) { writeDataSet->data[i] = PSDresult[i]; } //Copy the timestamp and sample rate for the DataSets writeDataSet->timeStamp = readDataSet->timeStamp; writeDataSet->sampleRate = readDataSet->sampleRate; //Release the DataSets releaseInputDataSet("input1", readDataSet); releaseOutputDataSet("output1", writeDataSet); }
void SpectrogramComponent::process() { //Get a DataSet from the input DataBuffer DataSet< complex<float> >* readDataSet = NULL; getInputDataSet("input1", readDataSet); std::size_t size = readDataSet->data.size(); //Fill windows and push to spectrogram CplxVecIt it = readDataSet->data.begin(); for(;it != readDataSet->data.end(); ++it) { window_.push_back(*it); if(window_.size() == windowLength_x) processWindow(); } if(!isSink_x && isProbe_x) { //Pass data through DataSet< complex<float> >* writeDataSet = NULL; getOutputDataSet("output1", writeDataSet, size); writeDataSet->data = readDataSet->data; writeDataSet->sampleRate = readDataSet->sampleRate; writeDataSet->timeStamp = readDataSet->timeStamp; releaseOutputDataSet("output1", writeDataSet); } releaseInputDataSet("input1", readDataSet); }
void SignalScalerComponent::process() { DataSet<complex<float> >* readDataSet = NULL; DataSet<complex<float> >* writeDataSet = NULL; getInputDataSet("input1", readDataSet); size_t size = readDataSet->data.size(); getOutputDataSet("output1", writeDataSet, size); writeDataSet->timeStamp = readDataSet->timeStamp; if (factor_x == 0) { // this is equalent to: // complex<float>* it = readDataSet->data.begin(); // complex<float>* maxIt = it; // while (it != readDataSet->data.end()) // { // if (!(norm(*it) < norm(*maxIt))) maxIt = it; // it++; // } // float maxVal = abs(*maxIt); // // * First, it finds the maximum element in the readDataSet using norm<float>(_1) < norm<float>(_2) as // comparison predicate, where _1 and _2 are placeholders for the two predicate arguments (i.e., it compares // the squared magnitudes of both complex numbers). // - 'norm' is an STL template for computing the squared magnitude of complex numbers, parameterised with the complex // element type (template <class T> norm(const complex<T>& x); ) // - 'bind' creates a functor given a function and an argument, here a placeholder, i.e., it creates a // functor class with 'operator()(complex<float>)' which applies the norm<float> function to its argument. // (see http://www.boost.org/doc/libs/1_40_0/doc/html/lambda/using_library.html#lambda.introductory_examples) // * Then, it computes the absolute value of that maximum (complex number) float maxVal = abs(*max_element(readDataSet->data.begin(), readDataSet->data.end(), bind(norm<float>, _1) < bind(norm<float>, _2) )); // this is equivalent to: // complex<float>* outit = writeDataSet->data.begin(); // for (complex<float>* it = readDataSet->data.begin(); it != readDataSet->data.end(); ++it) // *outit++ = *it / maxVal * x_maximum; // it applies x / maxVal * x_maximum for each element x // in the readDataSet and writes the result into the writeDataSet (using boost::lambda) // (see http://www.boost.org/doc/libs/1_40_0/doc/html/lambda/using_library.html#lambda.introductory_examples) std::transform(readDataSet->data.begin(), readDataSet->data.end(), writeDataSet->data.begin(), _1 / maxVal * maximum_x); } else { // this applies x * x_factor for each element x in the readDataSet and writes the result to the // writeDataSet std::transform(readDataSet->data.begin(), readDataSet->data.end(), writeDataSet->data.begin(), _1 * factor_x); } releaseInputDataSet("input1", readDataSet); releaseOutputDataSet("output1", writeDataSet); }
void NullSink::process() { //Get a DataSet from the input DataBuffer DataSet< complex<float> >* readDataSet = NULL; getInputDataSet("input1", readDataSet); //std::size_t size = readDataSet->data.size(); // DO NOTHING //Release the DataSets releaseInputDataSet("input1", readDataSet); }
/// Main processing method void Dvbt1RSEncoderComponent::process() { // request input DataSet< uint8_t >* in = NULL; getInputDataSet("input1", in); // calculate sizes int insize = in ? (int) in->data.size() : 0; int numpacks = (insize + tsOffset_) / TS_PACKET_SIZE; int outsize = numpacks * RS_PACKET_SIZE; // request output DataSet< uint8_t >* out = NULL; getOutputDataSet("output1", out, outsize); // print debug info if(debug_x) LOG(LINFO) << "in/out: " << insize + tsOffset_ << "(" << insize << "+" << tsOffset_ << ")/" << outsize; // fill the messagewords for(ByteVecIt init = in->data.begin(), outit = out->data.begin(); init < in->data.end(); init++) { // copy in reverse order rsCodeWord_[TS_PACKET_SIZE - 1 - tsOffset_] = *init; // trigger encoding if(++tsOffset_ == TS_PACKET_SIZE) { int status = packetEncode(rsCodeWord_, rsCodeWord_ + T1_KK); if (status) LOG(LERROR) << "Problem encoding a R-S word"; // copy information part for(int b = 0; b < TS_PACKET_SIZE; b++, outit++) *outit = rsCodeWord_[TS_PACKET_SIZE - 1 - b]; // copy parity part for(int b = 0; b < T1_NN_KK; b++, outit++) *outit = rsCodeWord_[T1_NN - 1 - b]; // reset TS pointer tsOffset_ = 0; } } //Copy the timestamp and sample rate for the DataSets out->timeStamp = in->timeStamp; out->sampleRate = in->sampleRate; // release input and output releaseInputDataSet("input1", in); releaseOutputDataSet("output1", out); }
void PfbSynthesizerComponent::process() { //Get input DataSets std::size_t curSize = 0; vector< DataSet< complex<float> >* > inSets(nChans_x); for(int i=0;i<nChans_x;i++) { stringstream ss; ss << "input"; ss << i; getInputDataSet(ss.str(), inSets[i]); std::size_t s = inSets[i]->data.size(); if(s != curSize && curSize > 0) LOG(LWARNING) << "Input channel sizes do not match."; curSize = s; } //Get output DataSet DataSet< complex<float> >* writeDataSet = NULL; getOutputDataSet("output1", writeDataSet, curSize*nChans_x); writeDataSet->sampleRate = inSets[0]->sampleRate*nChans_x; writeDataSet->timeStamp = inSets[0]->timeStamp; // Execute the synthesizer for(int i=0;i<curSize;i++) { for (int j=0; j<nChans_x; j++) buf[j] = inSets[j]->data[i]; firpfbch_crcf_synthesizer_execute(channelizer, &buf[0], &outBuf[0]); copy(outBuf.begin(), outBuf.end(), writeDataSet->data.begin()+i*nChans_x); } // mix signal down for(int i=0;i<writeDataSet->data.size();i++) { complex<float>* x = &writeDataSet->data[i]; nco_crcf_mix_down(nco, *x, x); nco_crcf_step(nco); } //Release the DataSets for(int i=0;i<nChans_x;i++) { stringstream ss; ss << "input"; ss << i; releaseInputDataSet(ss.str(), inSets[i]); } releaseOutputDataSet("output1", writeDataSet); }
void GateComponent::process() { //Get a DataSet from the input DataBuffer DataSet< complex<float> >* readDataSet = NULL; getInputDataSet("input1", readDataSet); size_t inputSize = readDataSet->data.size(); if(open_x) //Gate is open { nData_ += inputSize; if(nData_ > dataLimit_x) { //We've exceeded the limit - close the gate open_x = false; if(buffer_x) gateBuffer_.push_back(*readDataSet); releaseInputDataSet("input1", readDataSet); LOG(LINFO) << "Closed gate"; nData_ = 0; return; } if(gateBuffer_.size() > 0) flushBuffer(); //Copy input to output DataSet< complex<float> >* writeDataSet = NULL; getOutputDataSet("output1", writeDataSet, inputSize); *writeDataSet = *readDataSet; releaseOutputDataSet("output1", writeDataSet); } else // Gate is closed { if(buffer_x) gateBuffer_.push_back(*readDataSet); } releaseInputDataSet("input1", readDataSet); }
void Serial2ParaComponent::process() { //Get a DataSet from the input DataBuffer DataSet<float>* readDataSet = NULL; getInputDataSet("input1", readDataSet); if(!isfirstblock) { size_t size = readDataSet->data.size(); for(int i=0;i<size;i++) { data[block_index*inputBlocksize_x+i]=readDataSet->data[i]; } block_index++; //LOG(LINFO) << "block index " << block_index; if(block_index == factor_x) { block_index = 0; //Get a DataSet from the output DataBuffer DataSet<float>* writeDataSet = NULL; getOutputDataSet("output1", writeDataSet, outputBlocksize); for(int i=0;i<outputBlocksize;i++) { writeDataSet->data[i]=data[i]; } //Copy the timestamp and sample rate for the DataSets writeDataSet->timeStamp = readDataSet->timeStamp; writeDataSet->sampleRate = readDataSet->sampleRate; releaseOutputDataSet("output1", writeDataSet); } } //Release the DataSets releaseInputDataSet("input1", readDataSet); isfirstblock = false; }
void ExampleComponent::process() { //Get a DataSet from the input DataBuffer DataSet<uint32_t>* readDataSet = NULL; getInputDataSet("input1", readDataSet); std::size_t size = readDataSet->data.size(); //Get a DataSet from the output DataBuffer DataSet<uint32_t>* writeDataSet = NULL; getOutputDataSet("output1", writeDataSet, size); //Copy the input DataSet to the output DataSet copy(readDataSet->data.begin(), readDataSet->data.end(), writeDataSet->data.begin()); //Copy the timestamp and sample rate for the DataSets writeDataSet->timeStamp = readDataSet->timeStamp; writeDataSet->sampleRate = readDataSet->sampleRate; //Release the DataSets releaseInputDataSet("input1", readDataSet); releaseOutputDataSet("output1", writeDataSet); }
void LiquidOfdmModComponent::process() { DataSet< uint8_t >* in = NULL; getInputDataSet("input1", in); unsigned int payloadSize = (unsigned int)in->data.size(); unsigned char* payload = &in->data[0]; unsigned char header[8]; for (int i = 0; i < 8; i++) header[i] = frameHeader_x.c_str()[i] & 0xff; ofdmflexframegen_assemble(frameGenerator_, header, payload, payloadSize); unsigned int symbols = ofdmflexframegen_getframelen(frameGenerator_); unsigned int symbolSize = noSubcarriers_x + cyclicPrefixLength_x; unsigned int frameSize = symbols * symbolSize; if (debug_x) ofdmflexframegen_print(frameGenerator_); //Allocate memory for single symbol and whole frame DataSet< complex<float> >* out = NULL; getOutputDataSet("output1", out, frameSize); std::complex<float> buffer[symbolSize]; // generate frame, one OFDM symbol at a time unsigned int bytesWritten = 0; while (symbols--) { ofdmflexframegen_writesymbol(frameGenerator_, buffer); std::transform(buffer, buffer + symbolSize, out->data.begin() + bytesWritten, _1 * gain_factor_); bytesWritten += symbolSize; } out->timeStamp = in->timeStamp; // copy meta data of the frame releaseInputDataSet("input1", in); releaseOutputDataSet("output1", out); }
/// Main processing method void Dvbt1PuncturerComponent::process() { // request input DataSet< uint8_t >* in = NULL; getInputDataSet("input1", in); // calculate sizes int insize = in ? (int) in->data.size() : 0; int outsize = ((insize + punOffset_) / punPeriodIn_) * punPeriodOut_; // request output DataSet< uint8_t >* out = NULL; getOutputDataSet("output1", out, outsize); // print debug info if(debug_x) LOG(LINFO) << "in/out: " << insize + punOffset_ << "(" << insize << "+" << punOffset_ << ")/" << outsize; // iterate over input for(ByteVecIt init = in->data.begin(), outit = out->data.begin(); init < in->data.end(); init++) { // fill puncturing register punRegister_[punOffset_++] = *init; // trigger puncturing at the output if(punOffset_ == punPeriodIn_) { // reset offset punOffset_ = 0; // copy to output switch(codeRate_x) { // the puncturing matrices are hard-coded for all the five code rates case 12: *outit++ = punRegister_[0]; *outit++ = punRegister_[1]; break; case 23: *outit++ = punRegister_[0]; *outit++ = punRegister_[1]; *outit++ = punRegister_[3]; break; case 34: *outit++ = punRegister_[0]; *outit++ = punRegister_[1]; *outit++ = punRegister_[3]; *outit++ = punRegister_[4]; break; case 56: *outit++ = punRegister_[0]; *outit++ = punRegister_[1]; *outit++ = punRegister_[3]; *outit++ = punRegister_[4]; *outit++ = punRegister_[7]; *outit++ = punRegister_[8]; break; case 78: *outit++ = punRegister_[0]; *outit++ = punRegister_[1]; *outit++ = punRegister_[3]; *outit++ = punRegister_[5]; *outit++ = punRegister_[7]; *outit++ = punRegister_[8]; *outit++ = punRegister_[11]; *outit++ = punRegister_[12]; break; default: LOG(LERROR) << "Invalid puncturing rate: " << codeRate_x; } } } // Copy the timestamp and sample rate for the DataSets out->timeStamp = in->timeStamp; out->sampleRate = in->sampleRate; // release input and output releaseInputDataSet("input1", in); releaseOutputDataSet("output1", out); }
/// Main processing method void Dvbt1InterpolatorComponent::process() { // request input DataSet< Cplx > *in = NULL; getInputDataSet("input1", in); // calculate sizes int insize = in ? (int) in->data.size() : 0; int numbufs = (insize + inOffset_) / tiInsize_; int outsize = tiOutsize_ * numbufs; // print debug info if(debug_x) LOG(LINFO) << "in/out: " << insize << "/" << outsize; // request output DataSet< Cplx >* out = NULL; getOutputDataSet("output1", out, outsize); // copy for(CplxVecIt init = in->data.begin(), outit = out->data.begin(), inRegEff_ = inReg_.begin() + T1_RESAMPLE_ORDER + 1; init < in->data.end(); init++) { // copy inRegEff_[inOffset_++] = *init; // do the trick if(inOffset_ == inLength_) { // reset inOffset_ = 0; // fractional filter for(int j = 0; j < tiOutsize_; j++, outit++) { // current base point int currbp = tiBasepointIndex_[j]; // interpolate Cplx temp(0,0); for(int k = 0; k < T1_RESAMPLE_ORDER + 1; k++) { temp.real(temp.real() + inRegEff_[currbp - k].real() * tiHI_[k * tiOutsize_ + j]); temp.imag(temp.imag() + inRegEff_[currbp - k].imag() * tiHI_[k * tiOutsize_ + j]); } *outit = temp; } // copy last values at the beginning copy(inReg_.end() - (T1_RESAMPLE_ORDER + 1), inReg_.end(), inReg_.begin()); } } //Copy the timestamp and sample rate for the DataSets out->timeStamp = in->timeStamp; out->sampleRate = in->sampleRate; // not sure about this: it should change! // release input and output releaseOutputDataSet("output1", out); releaseInputDataSet("input1", in); }