Skip to content

Commit 1646588

Browse files
committed
feat: negative index buffer reading
1 parent 34822e5 commit 1646588

1 file changed

Lines changed: 2 additions & 11 deletions

File tree

Plugins/LfpDisplayNode/LfpDisplayCanvas.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,25 +1584,16 @@ float LfpDisplaySplitter::getStd(int chan)
15841584
// use 0.1s of sample to compute Mean and Std
15851585
float totalPoints = 0.1 * sampleRate;
15861586

1587-
//LOGD("DisplayBufferIndex ", displayBufferIndex[chan], " - ", totalPoints, " points required");
1588-
1589-
// avoid crash if no signal
1590-
//if ((displayBufferIndex[chan] - totalPoints) <= 0) {
1591-
// LOGD("\tReturning ", 0);
1592-
// return 0;
1593-
//}
1594-
15951587
for (int samp = displayBufferIndex[chan] - totalPoints; samp < displayBufferIndex[chan]; samp += 1)
15961588
{
15971589
float value = 0;
15981590

1599-
if (samp >= 0)
1591+
if (samp >= 0) // read the beginning of the buffer
16001592
value = *displayBuffer->getReadPointer(chan, samp);
1601-
else
1593+
else // read the end of the buffer if negative index
16021594
value = *displayBuffer->getReadPointer(chan, displayBuffer->getNumSamples() - samp);
16031595

16041596
std += pow((value - mean),2);
1605-
//LOGD("\tval ", *displayBuffer->getReadPointer(chan, samp));
16061597
numPts++;
16071598
}
16081599
LOGD("\tReturning ", sqrt(std / numPts));

0 commit comments

Comments
 (0)