Hello,
I'm working on an open source code for the Intan RDH2000 interface software.
I have two types of signals data - amplifier and auxiliary.
The amplifier is saved in the qint16 format and the auxiliary in the uqint16 format.
Moreover, the amplifier data is sampled every at each time step while the auxiliary data is sampled only at each 4th time step.
I'm trying (and so far failing) to merge these two signals type so they will both be on the same file with the same qint16 format.
About the time step, I don't mind to duplicate the auxiliary data so it will be identical for each 4 consecutive time steps.
Here is the function I'm working on, I'm new to QT and a little rusty in C++ so I would appreciate any suggestion you might have:
// Save amplifier data
bufferIndex = 0;
for (t = 0; t < SAMPLES_PER_DATA_BLOCK; ++t) {
for (i = 0; i < saveListAmplifier.size(); ++i) {
tempQint16 = (qint16)
(dataQueue.front().amplifierData[saveListAmplifier.at(i)->boardStream][saveListAmplifier.at(i)->chipChannel][t] - 32768);
dataStreamBuffer[bufferIndex++] = tempQint16 & 0x00ff; // Save qint16 in little-endian format (LSByte first)
dataStreamBuffer[bufferIndex++] = (tempQint16 & 0xff00) >> 8; // (MSByte last)
}
}
if (bufferIndex > 0) {
amplifierStream->writeRawData(dataStreamBuffer, bufferIndex); // Stream out all data at once to speed writing
numWordsWritten += saveListAmplifier.size() * SAMPLES_PER_DATA_BLOCK;
}
// Save auxiliary input data
bufferIndex = 0;
for (t = 0; t < SAMPLES_PER_DATA_BLOCK; ++t) {
tAux = 4 * qFloor((double) t / 4.0);
for (i = 0; i < saveListAuxInput.size(); ++i) {
tempQuint16 = (quint16)
dataQueue.front().auxiliaryData[saveListAuxInput.at(i)->boardStream][1][tAux + saveListAuxInput.at(i)->chipChannel + 1];
dataStreamBuffer[bufferIndex++] = tempQuint16 & 0x00ff; // Save quint16 in little-endian format (LSByte first)
dataStreamBuffer[bufferIndex++] = (tempQuint16 & 0xff00) >> 8; // (MSByte last)
}
}
if (bufferIndex > 0) {
auxInputStream->writeRawData(dataStreamBuffer, bufferIndex); // Stream out all data at once to speed writing
numWordsWritten += saveListAuxInput.size() * SAMPLES_PER_DATA_BLOCK;
}
// Save amplifier data
bufferIndex = 0;
for (t = 0; t < SAMPLES_PER_DATA_BLOCK; ++t) {
for (i = 0; i < saveListAmplifier.size(); ++i) {
tempQint16 = (qint16)
(dataQueue.front().amplifierData[saveListAmplifier.at(i)->boardStream][saveListAmplifier.at(i)->chipChannel][t] - 32768);
dataStreamBuffer[bufferIndex++] = tempQint16 & 0x00ff; // Save qint16 in little-endian format (LSByte first)
dataStreamBuffer[bufferIndex++] = (tempQint16 & 0xff00) >> 8; // (MSByte last)
}
}
if (bufferIndex > 0) {
amplifierStream->writeRawData(dataStreamBuffer, bufferIndex); // Stream out all data at once to speed writing
numWordsWritten += saveListAmplifier.size() * SAMPLES_PER_DATA_BLOCK;
}
// Save auxiliary input data
bufferIndex = 0;
for (t = 0; t < SAMPLES_PER_DATA_BLOCK; ++t) {
tAux = 4 * qFloor((double) t / 4.0);
for (i = 0; i < saveListAuxInput.size(); ++i) {
tempQuint16 = (quint16)
dataQueue.front().auxiliaryData[saveListAuxInput.at(i)->boardStream][1][tAux + saveListAuxInput.at(i)->chipChannel + 1];
dataStreamBuffer[bufferIndex++] = tempQuint16 & 0x00ff; // Save quint16 in little-endian format (LSByte first)
dataStreamBuffer[bufferIndex++] = (tempQuint16 & 0xff00) >> 8; // (MSByte last)
}
}
if (bufferIndex > 0) {
auxInputStream->writeRawData(dataStreamBuffer, bufferIndex); // Stream out all data at once to speed writing
numWordsWritten += saveListAuxInput.size() * SAMPLES_PER_DATA_BLOCK;
}
To copy to clipboard, switch view to plain text mode
With thanks,
Amir
Bookmarks