My class is receiving a vector of complex floats, but the data stream packets must have the data as short. My solution is to first convert the data to short, then batch it into the packets, and send them. What would be the best method of converting this data?
void cPXGFtoWaveBase::BufferSampleData(const std::vector<std::complex<float>>& vcfSampleData, const float& fTotalGain_dB, const cFrequency& CentreFrequency, const cBandwidth& cBandwidth, const cTimeStamp& tCaptureTime, const cSampleRate& SampleRate)
{
sBufferData* pWriteElement = m_SampleBuffer.GetWriteElement();
if(pWriteElement != nullptr) {
std::copy(vcfSampleData.begin(), vcfSampleData.end(), pWriteElement->m_pData); //vector<comlex<float>> must become vector<complex<short>> or vector<short>
//other irrelevant stuff here
m_SampleBuffer.CommitWriteElement();
}
}
Aucun commentaire:
Enregistrer un commentaire