I have been playing with Soapy and an Airspy when I noticed that the FFTs on my first samples did not always came out as expected. Looking closer I noticed that the 1st few complex samples always contained some 0s and from thereon on never again. This seems a bit strange and almost like either the first buffer has some wrong data in it or I am reading it wrong. Hopefully this is something I am doing wrong.
I allocate the buffers as such:
vector<vector<char>> buffMem(1, vector<char>(SoapySDR::formatToSize("CF32") * mtu));
vector<void *> buffs(1);
for (size_t i = 0; i < 1; i++) buffs[i] = buffMem[i].data();
int flags(0);
long long timeNs(0);
vector<vector<float>> sampleBuff(5 * 2048, vector<float>(2)); // Holds the IQ samples
then read a couple of sample with:
for (int l = 0; l < 4; l++)
{
// Read stream
int elementsRead = device->readStream(st, buffs.data(), mtu, flags, timeNs);
cout << elementsRead * SoapySDR::formatToSize("CF32") << " bytes have been read. Flags = " << flags << endl;
for (int i = 0; i < buffMem[0].capacity(); i += SoapySDR::formatToSize("CF32"))
{
deciCnt++;
if (((i + 8) <= buffMem[0].capacity()) && deciCnt == 1)
{
// Bytes packed back into floats
float ival;
float qval;
unsigned char ci[] = { buffMem[0][i + 0], buffMem[0][i + 1], buffMem[0][i + 2], buffMem[0][i + 3] };
unsigned char cq[] = { buffMem[0][i + 4], buffMem[0][i + 5], buffMem[0][i + 6], buffMem[0][i + 7] };
memcpy(&qval, &cq, sizeof(qval));
memcpy(&ival, &ci, sizeof(ival));
// Store the IQ values
sampleBuff[sampleCount][0] = ival;
sampleBuff[sampleCount][1] = qval;
sampleCount++;
deciCnt = 0;
}
}
}
Thanks for this very interesting project!
I have been playing with Soapy and an Airspy when I noticed that the FFTs on my first samples did not always came out as expected. Looking closer I noticed that the 1st few complex samples always contained some 0s and from thereon on never again. This seems a bit strange and almost like either the first buffer has some wrong data in it or I am reading it wrong. Hopefully this is something I am doing wrong.
I allocate the buffers as such:
then read a couple of sample with:
I am reading 2048 (MTU) elements at a time.
Output of the first few samples
Any idea what could be the cause of this?
As a side question is there some builtin byte packing function or is this pretty much the way everyone else also do it?